Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Strong Sauce
Jul 2, 2003

You know I am not really your father.





ive built a random starwars name generator, but the problem is text looks a bit boring. would like to spice this up by making generating a procedurally generated face to go along with the name.

does anyone have a guide on making simple 2d procgen faces? is it just a matter of having separate methods for drawing parts of the face and then randomizing certain elements to it? any help would be great.

Adbot
ADBOT LOVES YOU

No Safe Word
Feb 26, 2005

Strong Sauce posted:

ive built a random starwars name generator, but the problem is text looks a bit boring. would like to spice this up by making generating a procedurally generated face to go along with the name.

does anyone have a guide on making simple 2d procgen faces? is it just a matter of having separate methods for drawing parts of the face and then randomizing certain elements to it? any help would be great.

comedy answer: Chernoff Faces

Winty
Sep 22, 2007

Not really programming specifically, but I can't find a more relevant thread.

Say I film a real-life scene with both a 30fps camera and a 60fps camera. So I have two very similar uncompressed video files, but one has exactly twice as many frames. Now I encode them both to MPEG or whatever with the exact same settings.
Will the 60fps file be almost exactly twice as big as the 30fps file?
Or will it be less than twice as big, because there is less information contained in the way the image changes over 1/60 of a second, than in the way it changes over 1/30 of a second? If that makes sense.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Winty posted:

Will the 60fps file be almost exactly twice as big as the 30fps file?

I'm not an expert on these matters, but no, it won't be, because the full frames aren't encoded raw into the file -- as you surmised, the file is compressed so that it doesn't need to store everything. If you were to download the raw form of one of those 24-hour-long YouTube "videos" that's just a blank screen with the Enterprise engine noise on repeat, you'd get a single frame of video and the audio track and that's it.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

TooMuchAbstraction posted:

I'm not an expert on these matters, but no, it won't be, because the full frames aren't encoded raw into the file -- as you surmised, the file is compressed so that it doesn't need to store everything. If you were to download the raw form of one of those 24-hour-long YouTube "videos" that's just a blank screen with the Enterprise engine noise on repeat, you'd get a single frame of video and the audio track and that's it.

Not quite, it won't just be 1 single frame, (also not an expert) most modern video encoding uses a combination of keyframes (which effectively perfectly represents a frame, compressed) and b-frames (which contain delta information from the last keyframe). This is why you'll sometimes see video go all strange, and keep getting worse, until it snaps back to being perfect. Keyframe intervals can vary based on your encoding settings, so for your 24 hour example, it's likely there will be keyframes every few seconds.

mystes
May 31, 2006

TooMuchAbstraction posted:

I'm not an expert on these matters, but no, it won't be, because the full frames aren't encoded raw into the file -- as you surmised, the file is compressed so that it doesn't need to store everything. If you were to download the raw form of one of those 24-hour-long YouTube "videos" that's just a blank screen with the Enterprise engine noise on repeat, you'd get a single frame of video and the audio track and that's it.
Video files are usually encoded with a maximum time between independent frames (key frames) so it isn't necessary for the player to decode an arbitrarily large amount of the file when seeking. As a test, I downloaded an approximately 3 minute long youtube video that was just a still image, and it still had 39 I-frames, so you probably aren't going to get a 24-hour-long video with just one frame.

Edit: Oops, beaten by like 15 minutes.

Skandranon posted:

most modern video encoding uses a combination of keyframes (which effectively perfectly represents a frame, compressed) and b-frames (which contain delta information from the last keyframe)
This is close. Modern codecs have I-frames (keyframes), P-frames (which reference previous frames), and B-frames (which can reference previous and subsequent frames). Also, with P/B frames, it's not necessarily keyframes that are referenced (it would be inefficient to require this). I think with mpeg2, P-frames could only reference the previous frame, for example, which meant that decoders only had to keep one previous frame in memory. As a result, the importance of keyframes isn't necessarily just that they serve as references for B/P-frames but that they make seeking easier. For example, even with only I and P frames, and the P frames only referencing the previous frame, if there was only one I frame in the whole file, if you tried to seek half way through the video, the player would have to decode the entire thing up until that point, because every frame would depend on the previous frame going all the way back to the start.

mystes fucked around with this message at 03:09 on Jul 7, 2016

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
It doesn't help with the static image case, but h264's Recovery Point SEI makes it possible to produce streams which can be seeked in without having any keyframes. Instead there's non-keyframe points that you can seek to and start decoding from, and after X frames (where X is a value recorded in the stream) the image will have converged to the correct one and no more frames will reference things from before the recovery point.

FAT32 SHAMER
Aug 16, 2012



here's a dumb git question: when I commit from my vps, the commits are listed as being from the username (root) instead of being under my GitHub username



I tried using git config --global user.name "timothyjimothy" and git config --global user.email $my_email_address but it still commits as root. any ideas why?

EDIT: I was able to user my GitHub credentials by using git config --global --unset-all user.name and git config --global --unset-all user.email, then my test commit worked, so hopefully it stays that way :D

FAT32 SHAMER fucked around with this message at 08:15 on Jul 7, 2016

nielsm
Jun 1, 2009



Why are you working as root

FAT32 SHAMER
Aug 16, 2012



nielsm posted:

Why are you working as root

its what ovh sent me when i got my cheapo vps from them and I have very little idea what i'm doing other than ssh'ing into it and hosting a script from it :shobon:

in fact it's the only way they really tell you how to log into your vps:
https://www.ovh.com/us/g1260.how_to_log_in_to_your_vps

FAT32 SHAMER fucked around with this message at 09:41 on Jul 7, 2016

sarehu
Apr 20, 2007

(call/cc call/cc)
git config --global will put the configuration in ~/.gitconfig for whatever user you're logged in as at the time. That means /root/.gitconfig if you do that command while you're the root user. For non-root users, it'll be in /home/username/.gitconfig (on Linux) or /Users/username/.gitconfig (on OS X) or in some crazy location (on Windows). The configuration does not follow the repository, it does not affect commits made on remote machines, commits made while logged in as another user, etc.

wargames
Mar 16, 2008

official yospos cat censor
This is not worth its own thread but is involved, my coding skill level is basically zero, but my overall computer knowledge is fairly ok. I've managed to bang together a website, I self host a wordpress site, I run mybb forums, doku wiki, and soon rocket chat on this site. Right now I have wordpress doing my auth for the site. I have mybbsync plugin inside wordpress so when you go to login on mybb wordpress pushes the info into the mybb sqldb. question is how do I make it so they just sign into the website and click on the forums and have them auto login? This can also be asked of dokuwiki I have the wordpress auth plug for dokuwiki, I would like a SSO just don't know how to go about that. pretty sure I am making no sense at 3am but i am stumped.

mystes
May 31, 2006

wargames posted:

This is not worth its own thread but is involved, my coding skill level is basically zero, but my overall computer knowledge is fairly ok. I've managed to bang together a website, I self host a wordpress site, I run mybb forums, doku wiki, and soon rocket chat on this site. Right now I have wordpress doing my auth for the site. I have mybbsync plugin inside wordpress so when you go to login on mybb wordpress pushes the info into the mybb sqldb. question is how do I make it so they just sign into the website and click on the forums and have them auto login? This can also be asked of dokuwiki I have the wordpress auth plug for dokuwiki, I would like a SSO just don't know how to go about that. pretty sure I am making no sense at 3am but i am stumped.
You're gong to have to either modify all the software to use the same sessions, or modify the login processes to check the sessions for the other software. Since all of these things appear to be written in the same language (PHP), it probably wouldn't be insanely difficult to do the former (mostly cut and paste, probably), but you're going to need more than zero coding ability.

Ideally, if the sites only store a session ID in their cookies, and have some sort of session database is just a simple mapping of session ID to user ID, then you would just need to change the functions that check the session and that get the username to use the equivalent from wordpress. This way there wouldn't even be a separate login process. Being logged into wordpress would mean being logged into the other software as well.

However, there are going to be lots of annoying details in terms of synchronizing user databases (the different programs will probably have their own database schemas for user information, etc., and you might have to translate user numbers if the programs pass them around internally) and it's probably going to be a pain to get everything working perfectly.

mystes fucked around with this message at 13:04 on Jul 8, 2016

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Winty posted:

Not really programming specifically, but I can't find a more relevant thread.

Say I film a real-life scene with both a 30fps camera and a 60fps camera. So I have two very similar uncompressed video files, but one has exactly twice as many frames. Now I encode them both to MPEG or whatever with the exact same settings.
Will the 60fps file be almost exactly twice as big as the 30fps file?
Or will it be less than twice as big, because there is less information contained in the way the image changes over 1/60 of a second, than in the way it changes over 1/30 of a second? If that makes sense.

I'm reading this article right now and it covers some of that stuff

https://bengarney.com/2016/06/25/video-conference-part-1-these-things-suck/

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

wargames posted:

This is not worth its own thread but is involved, my coding skill level is basically zero, but my overall computer knowledge is fairly ok. I've managed to bang together a website, I self host a wordpress site, I run mybb forums, doku wiki, and soon rocket chat on this site. Right now I have wordpress doing my auth for the site. I have mybbsync plugin inside wordpress so when you go to login on mybb wordpress pushes the info into the mybb sqldb. question is how do I make it so they just sign into the website and click on the forums and have them auto login? This can also be asked of dokuwiki I have the wordpress auth plug for dokuwiki, I would like a SSO just don't know how to go about that. pretty sure I am making no sense at 3am but i am stumped.

It might be easier in the end to rebuild the entire world around what you want. Namely, find new websites/chat/whatever that already has Google/Facebook/whatever SSO built in. Especially if you are not a coder as you will likely do a terrible job of trying to rewrite the authentication for all those tools.

wargames
Mar 16, 2008

official yospos cat censor
Thought up a better solution, delete the registration button on the forums, if the nerds want to register for the site they can do that on the front page and sign in like the peasants they are because sso seems beyond my talents.

it is
Aug 19, 2011

by Smythe
What is the easiest way to get the r's, g's, and b's of a region of the screen? Where is the information that each jet uses to decide whether to be on or off stored?

Hughmoris
Apr 21, 2007
Let's go to the abyss!
Can anyone recommend a book or tutorial on data trees? I'm looking at writing a basic 'Scrabble Word Solver' that will tell you what words you can create with a random input of characters. It looks like the DAWG algorithm is great for this problem but I'm pretty lost as I read about it. Maybe getting a base understanding of data trees will help?

ufarn
May 30, 2009

Hughmoris posted:

Can anyone recommend a book or tutorial on data trees? I'm looking at writing a basic 'Scrabble Word Solver' that will tell you what words you can create with a random input of characters. It looks like the DAWG algorithm is great for this problem but I'm pretty lost as I read about it. Maybe getting a base understanding of data trees will help?
Maybe Bloom Filter or Trie; those are at least the go-to's for general dictionaries. I can't which one has false positives, but that should be available somewhere.

Skiena is literally an algorithm cook book, but I can't remember whether it specifically has one for dictionaries.

ToxicFrog
Apr 26, 2008


it is posted:

What is the easiest way to get the r's, g's, and b's of a region of the screen?

What OS? What language? For what purpose? Are you trying to capture part of the desktop, or video, or a running game, or...?

quote:

Where is the information that each jet uses to decide whether to be on or off stored?

Jet? :confused:

ufarn posted:

Maybe Bloom Filter or Trie; those are at least the go-to's for general dictionaries. I can't which one has false positives, but that should be available somewhere.

Bloom filters are the ones with the false positives (and also aren't trees or dictionaries; they're a compact way of representing sets).

Hughmoris
Apr 21, 2007
Let's go to the abyss!

ToxicFrog posted:

What OS? What language? For what purpose? Are you trying to capture part of the desktop, or video, or a running game, or...?

Bloom filters are the ones with the false positives (and also aren't trees or dictionaries; they're a compact way of representing sets).

I'm on Windows, writing it in Perl to use from the command line. Essentially pass the script up to 7 characters, and it will return all the words that can be made from those characters. I really don't have any exposure to trees and am trying to get a basic understanding of them to help write this script.

Jewel
May 2, 2009

I made a really weird way of solving a scrabble game under a weird environment and I'm wondering if this is a completely nuts approach or if this is a fairly common one with a name?

The gist is, I hash every dictionary word with a hash that works in any order (in this case, literally just "word.Aggregate(1, (acc, x) => acc * (int)x)", ie multiply 1 by the int value of every letter in the word, and store them in a map with the key being their hash. There's multiple words that give the same score (ie dog and god) but there's no objectively better one so I just toss them out except the first that gets added; you could use a map with List<string> being the key instead if you wanted.

So you give it a word, and it just gets every Combination of the letters, which, unlike permutations, order doesn't matter; so just every unique combination of letters, ie if you pass in "apple" it checks "a", "ap", "apl", ..., "ple", "le", "e". For each of those combinations, it hashes them, and adds whatever is in the hash dict to a "best words" list. At the end, it just grabs the word with the highest score from that small list.

Theoretically at this point you could instead, if you store every matching word in the dictionary; check the highest scoring words to see if they fit into an actual board anywhere, but I'm not interested in that.

Either way, this approach is nearly instant on a huge word list and I'm wondering if it has a name!

Nippashish
Nov 2, 2005

Let me see you dance!

Hughmoris posted:

I'm on Windows, writing it in Perl to use from the command line. Essentially pass the script up to 7 characters, and it will return all the words that can be made from those characters. I really don't have any exposure to trees and am trying to get a basic understanding of them to help write this script.

There are <6000 possible ways to arrange 7 letters into a word. I'm having a hard time thinking of a way you could do this that would not be fast enough for interactive use, so just do whatever seems convenient.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Jewel posted:

I made a really weird way of solving a scrabble game under a weird environment and I'm wondering if this is a completely nuts approach or if this is a fairly common one with a name?

The gist is, I hash every dictionary word with a hash that works in any order (in this case, literally just "word.Aggregate(1, (acc, x) => acc * (int)x)", ie multiply 1 by the int value of every letter in the word, and store them in a map with the key being their hash. There's multiple words that give the same score (ie dog and god) but there's no objectively better one so I just toss them out except the first that gets added; you could use a map with List<string> being the key instead if you wanted.

So you give it a word, and it just gets every Combination of the letters, which, unlike permutations, order doesn't matter; so just every unique combination of letters, ie if you pass in "apple" it checks "a", "ap", "apl", ..., "ple", "le", "e". For each of those combinations, it hashes them, and adds whatever is in the hash dict to a "best words" list. At the end, it just grabs the word with the highest score from that small list.

Theoretically at this point you could instead, if you store every matching word in the dictionary; check the highest scoring words to see if they fit into an actual board anywhere, but I'm not interested in that.

Either way, this approach is nearly instant on a huge word list and I'm wondering if it has a name!

This is a fairly standard approach, though you've made it a fair bit more complicated than it needs to be. Instead of multiplying the letters by ASCII values, just sort the word alphabetically (call => acll) and hash that.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Nippashish posted:

There are <6000 possible ways to arrange 7 letters into a word. I'm having a hard time thinking of a way you could do this that would not be fast enough for interactive use, so just do whatever seems convenient.

26^7 = 8031810176 :confused:

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


There could be fewer than 6000 valid Scrabble words.

Nippashish
Nov 2, 2005

Let me see you dance!

TooMuchAbstraction posted:

26^7 = 8031810176 :confused:

Hughmoris posted:

Essentially pass the script up to 7 characters, and it will return all the words that can be made from those characters.

The identities of the characters are fixed, so you only need to check permutations of them. 7! + 6! + 5! + 4! + 3! + 2! = 5912, or just under 6000.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

ultrafilter posted:

There could be fewer than 6000 valid Scrabble words.

code:
cat /usr/share/dict/words | grep -E "^.......$" | wc -l
23869
It wouldn't surprise me if not all of those were valid Scrabble words, but I very much doubt that 75% of them are invalid.

EDIT:

quote:

The identities of the characters are fixed, so you only need to check permutations of them. 7! + 6! + 5! + 4! + 3! + 2! = 5912, or just under 6000.

This however does make more sense. If you're handed a set of 7 letters then there's a much more limited number of ways to arrange them.

The Laplace Demon
Jul 23, 2009

"Oh dear! Oh dear! Heisenberg is a douche!"

TooMuchAbstraction posted:

26^7 = 8031810176 :confused:

There's 26^7 possible combinations of letters, but only 7! possible permutations of the 7 specific letters you have on your rack, which is what Nippashish meant. This doesn't take into account shorter words though, which bumps things up by a factor of almost e (funnily enough, it comes out to exactly ⌊7!×e⌋). The two blank tiles increase this even more and duplicate tiles lower it, but the combinatorics escape me at this point. Anyways, worst case search space is somewhere in the millions.

EDIT:

Nippashish posted:

The identities of the characters are fixed, so you only need to check permutations of them. 7! + 6! + 5! + 4! + 3! + 2! = 5912, or just under 6000.

The number of 6-permutations of 7 tiles (assuming all tiles are unique) is actually 7!.

The Laplace Demon fucked around with this message at 00:33 on Jul 10, 2016

Peristalsis
Apr 5, 2004
Move along.

The Laplace Demon posted:

There's 26^7 possible combinations of letters, but only 7! possible permutations of the 7 specific letters you have on your rack, which is what Nippashish meant. This doesn't take into account shorter words though, which bumps things up by a factor of almost e (funnily enough, it comes out to exactly ⌊7!×e⌋). The two blank tiles increase this even more and duplicate tiles lower it, but the combinatorics escape me at this point. Anyways, worst case search space is somewhere in the millions.

EDIT:


The number of 6-permutations of 7 tiles (assuming all tiles are unique) is actually 7!.

It has been a while since I've played scrabble, but aren't you really looking at 8+ tiles? You have use at least one tile already on the board when creating a new word, don't you? So, you probably want an algorithm A to look for words of up to 8 tiles, and then some sort of controller algorithm, B, to loop over all the letters on the board and call A on the set of a player's tiles plus the current board tile. And, of course, you need to account for places where you can use more than one tile on the board.

The Laplace Demon
Jul 23, 2009

"Oh dear! Oh dear! Heisenberg is a douche!"

Peristalsis posted:

It has been a while since I've played scrabble, but aren't you really looking at 8+ tiles? You have use at least one tile already on the board when creating a new word, don't you? So, you probably want an algorithm A to look for words of up to 8 tiles, and then some sort of controller algorithm, B, to loop over all the letters on the board and call A on the set of a player's tiles plus the current board tile. And, of course, you need to account for places where you can use more than one tile on the board.

Yup, all this analysis only applies to the first move. Writing an optimal Scrabble AI is a fun problem.

Often, the highest scoring move isn't perpendicular to existing words, but instead is parallel. The word and letter score bonuses add a lot to the game.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Jewel posted:

The gist is, I hash every dictionary word with a hash that works in any order (in this case, literally just "word.Aggregate(1, (acc, x) => acc * (int)x)", ie multiply 1 by the int value of every letter in the word, and store them in a map with the key being their hash.

Well, since the numbers aren't prime, you will get collisions. It will probably work in most cases, but yes, that's a very simple hash function.

Peristalsis
Apr 5, 2004
Move along.

The Laplace Demon posted:

Writing an optimal Scrabble AI is a fun problem.

Surely, someone has started a contest for scrabble playing programs to face off. It might be even more fun to write the program that runs the tournament. You'd have to model the board's state, dispense the tiles each turn, etc.

ArcticZombie
Sep 15, 2010
The fun part of creating a Scrabble AI isn't efficiently generating the legal moves, it's in creating an AI that plays strategically because just playing the highest scoring move available each turn is not enough to beat even the best human opponents. The approach I used for finding all legal moves for my own Scrabble solver is outlined here, using a DAWG (Directed Acyclic Word Graph) to store the words. There's a faster way to store them called a GADDAG but it's a bit more complex to implement.

a few DRUNK BONERS
Mar 25, 2016

Is there a programming language that uses =< and => instead of <= and >=?

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

a few DRUNK BONERS posted:

Is there a programming language that uses =< and => instead of <= and >=?

I don't think so? I think putting the <> part first makes parsing a lot easier.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

=> is used for things in a few languages as well

Jewel
May 2, 2009

-> is the "pointer" operator and => is the "big pointer" operator for when you're working with 64 bit types

it is
Aug 19, 2011

by Smythe

ToxicFrog posted:

What OS? What language? For what purpose? Are you trying to capture part of the desktop, or video, or a running game, or...?

Windows. I'm trying to make an AI that can press keyboard keys in relation to graphical input. I don't really care about the language, since it mostly involves shuffling arrays around, which isn't hard in any language.

I guess I'm just asking how to take like 60 screenshots a second, and it's weird that you can't just snoop on whatever is telling my monitor what colors to show me.

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

a few DRUNK BONERS posted:

Is there a programming language that uses =< and => instead of <= and >=?

Erlang uses =< and >=

I think they're inherited from prolog.

(I use neither of these languages so someone's free to tell me how wrong I am.)

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply