Showing posts with label internet things. Show all posts
Showing posts with label internet things. Show all posts

Wednesday, 21 December 2016

Retarus Charity Game is Bridges of Koningberg

Julie sent me a link to this game, and said I should play it, as it supports Techtonica, which does great things (copying from their webpage): "Free tech training with living and childcare stipends and job placement for low-income women and non-binary adults. #BridgeTheTechGap".  Great, I'm on board with all that.

The game is essentially a more complicated version of the Bridges of Koningsberg problem.  There are nodes you need to pass through, and you can't retrace steps.  I did the first 17 levels before realizing I should get back to work, so I waited until I got home to finish all the levels (and bring Techtonica above 50000 stars.  I assume everybody gets some money, and that it's not some sort of monstrous three charities enter, one charity leaves thing).  It wasn't until level 29/30 that I realized that there had to be some sort of algorithm to solve these, and not just "magical topology powers."  So I sat down to write out what I was doing with diagrams and words, to make sense of it.


Here's the board.

Nodes with only two edges must be traveled through both, obviously.

So, we can block off any route that the two-edge nodes force us to exclude.
 I ended up largely solving this from the end, because I know a path must go to the terminal node, and that immediately forces the route into the two nodes in the bottom right corner.  Knowing that the intermediate node already had two edges on the path excludes any other path from using the other two edges.
And this provides the next big hint to how the algorithm works:  Once you've blocked edges from being part of the path, you turn some nodes that were previously connected to 3+ nodes into 2-edge nodes, so you can iterate the process again.  I've labeled the first node that is downgraded like this with a star.

Another round of marking and blocking gets the pseudo-path near the start point, but there aren't any clear ways to continue at that end.

Which is good that I noticed that in the upper right, the one edge I crossed off in stage 1a is connected to another edge that is also forbidden.  This makes the one node a 2-edge.  The square path at the top is redundant, so I chose one to exclude.  This connects those two corner nodes to the straight 2-edge in the middle.

I'm not 100% sure that my solution here is unique, but I'm not redrawing my diagrams again.  In any case, my logic here says that the start can't continue straight past that first target node, as it would then either need to go down (which leads to the end), or straight (back through that 2-edge), which isn't value.  I already excluded the bottom route, so it will need to turn up.  Blocking that route forces the empty node to have 2-edges, which connects the "to-the-end" path with the "back through the straight 2-edge" path.  This blocks the down edge out of the top-center node, forcing it to be a turn.

That forces the empty node above it to have one exit blocked, and then things fall into place. 
See, 50008.
And I think that this algorithm solves any similar game, although there are two edge cases.  The first is when the grid is over connected with edges.  This should always have trivial solutions that are obvious (and the early stages have extra connectivity, and that simply means that there are multiple paths that are valid.  Path length was not a constraint).  The second problem case is when the objective is not possible because it's a true Bridges of Koningsberg problem with no solution.

Friday, 29 April 2016

Dumbing of Age characters

I read Dumbing of Age, but I don't really pay super close attention to things.  There are 1773 comics as of today, and it's hard to keep track of stories that long over a long period of time.  There are also a lot of characters that I have trouble keeping track of.  "Wait, how do you know how many comics it has?"

Today's story is all "Amber pushes Danny away because she's angry and making bad decisions."  My thought was, "Who else is Amber's friend?  Joyce, right?"

amber danny 91 0.408072 0.325
amazi-girl danny 40 0.3125 0.142857
amber ethan 60 0.269058 0.285714
amber dina 53 0.237668 0.24424
amazi-girl dorothy 24 0.1875 0.0526316
amazi-girl joyce 19 0.148438 0.0255376
amazi-girl walky 18 0.140625 0.0392157
amber joyce 30 0.134529 0.0403226
amazi-girl sal 16 0.125 0.0695652
amazi-girl amber 15 0.117188 0.0672646

Ethan, Dina, and then Dorothy maybe.  Yeah, I was wondering this enough that I wrote a bot to scrape all the comics to pull out the tags that are applied to each comic, since conveniently list all the characters appearing in that comic.  Then, I looked at the pairwise matches in that set and dumped them out in "character A", "character B", "number of appearances together", and number of appearances for each of A and B, converted here into fractions of all appearances that are together.

So that was waste of time.  I also have dates, and you can extract chapters from the urls (which I saved), so more analysis could be done (my thought was to try to do some sort of connection map), but I still haven't eaten dinner.  Also, I discovered that this comic is the only one to have no characters appearing, so had to handle that case (SOLO_APPEAR is in that with SOLO_APPEAR).

Thursday, 28 April 2016

Why is that so noisy?

Julie sent this video to me, and I was confused, because I didn't think it should saturate into noise on the third iteration.  Human voices are in the 1000 Hz range, so if the Carl doubles the frequency, three iterations only gets it to 8000 Hz, which is still well sampled by a 44 kHz sound file (the standard).  So, I did the sane thing when I got home, which is to download the video and do spectral analysis of the audio.
The human (s00), Carl A (s01), and Carl B (s02).
The human speech is mostly that tiny red peak on the left side, at about 1-2 kHz.  It's confused beyond that, but I think that second red peak (2k ish) can be plausibly shifted in the others.

Plotting everything.
The interesting thing in this one is that you can see that there are two patterns.  The dips around 11k and 13k are probably the easiest way to see that.  They're caused by the response function of the devices:
Carl A has the benefit on the first iteration to have the true voice.

Carl B.
 So I don't think it's really related to the speech frequency vs sampling rate.  I think it's just the addition of the noise in the microphone/speaker feedback.

Tuesday, 29 July 2014

"Hey, I could probably automate that in perl, and make it a game."

cat kitten sword robot space pink white bumblebee bee helmet

Code under the cut.  Rules for the game:  player one chooses an image, and the other players need to come up with descriptive words for what's on it.  Then, you run the command on the best set of words (maybe you don't want to use all of them because you end up with legos.  Maybe you get points if you only use like 1 word, but if you use 9 or more, but get legos, you lose points).  If the image itself, or the character, or an obviously "these images are related somehow" match happens, then the seekers get the point.  If not, then the player who chose the original image gets a point.  So under these rules, the Bee and Puppycat image gets a point, and I lose two points because I didn't find B&PC, and I ended up with legos when I used 10 words.


Friday, 10 January 2014

Fish sandwich is about this early, and twitter works right on tv because I see how the lazy weekend is bizarre conniving prostitutes prostitutes

-Or-
So, let's talk about Markov Chains, I guess.

This news story popped up in the RSS today, which reminded me of the long ago time in which Forum 2000 was a thing (note: Forum 2000 never worked like that.  It was all basically a mechanical turk).

I then remembered that you can download all your tweets from twitter, so blammo, I have the text corpus necessary to hack up something to do this.

So, those Markov Chains.  Here's the simple way to think of it:  starting from initial point A, there's a probability p_B that you'll move to point B, p_C that you'll move to C, etc.  However, there are also probabilities for all those points too, so you can chain things together.  Maybe go look at the wikipedia figure.  This isn't turning out to be that simple of an explanation.

In any case, if you let each "point" be a word in a tweet, then if you have a large sample of tweets from someone, you could imagine that you could construct fake tweets if you knew the probability that a given word follows another.  That's what I did in perl, and that's where the title came from.  I did a simple chain, where w_{i+1} is drawn directly from the probability distribution of words that follow word w_i.  There's a reset condition where if the set of words that follow w_i is empty, I restart the chain from the set of "words that start a tweet".  I've also forced the length of the generated string to be 140 characters, the standard tweet length (and forced everything lowercase, and removed all punctuation, etc, etc, etc).

Here are some more examples:
  • i was far the whole dinner but that @wholefoods sushi was aborted because its weird being even fucking clue what hes a cheater :-p theres no
  • hey verizon network that too hungry or more not sure that flasks were afraid the sun orbit simulator its now its someplace else too soggy as
  • happy birthday @jkru isnt helping anybody know and hes never a 12 16 garbage bags tied directly to work - british accent for being wasted its
  • rt @vgc_scott man that quote and cranky tonights dinner oh man its still preparing the oil is actively looking up a workaround to be going to
  • first time you dont want a walk an impenetrable island which is like it looks close eyes will always just woke up dry before i not having intermotrons
  • @jkru its all the music #fuckedupdream peter potomus cartoons are you your app its official word for liberty tsa approved for my implementation
  • dear this is what is terrible monsters outside who like fog and colby isnt even left there to the 100th day yay deposed monarchy ok so hopefully
Those are just nearly not gibberish enough for you to think that they're not computer generated.  The crazy thing about MCs is that they do a wonderful job of constructing sentences that are nearly grammatically correct.  This could probably be improved a lot, such as trying to pick words that have some influence from the second previous word or having it clearly mark where it's restarted the chain with a period or something.  Still, for like ten minutes of work, this isn't too bad.

Finally, an interesting sampling from printing out the chain transition probabilities:
fuck you 0.294392523364486 63 214
fuck it 0.0794392523364486 17 214
fuck fuck 0.0700934579439252 15 214
fuck yeah 0.0700934579439252 15 214
fuck up 0.0327102803738318 7 214
[...]
fuck #sandwichtweets 0.00467289719626168 1 214
fuck shitshitshitshitshitshitshitshitshitshitshitfuckshitshitfuck 0.00467289719626168 1 214
[...]
fucking ghost 0.00454545454545455 1 220
[...]
fuckity fuck 1 3 3

Friday, 8 July 2011

Did you mean: goooooooooooooooooooooooooooooooooogle

Isn't there a way to super-share pictures in Google+ so that other Google Googles can Google them with their Googles?

Ok, so that last sentence made me think of the word Google. That led me to thinking about power laws. That led to:

Yes. Yes it is. A lot of the higher number searches fall into two categories: the worst typo-squatters ever and youtube video comments/forum posts where someone is being a dick about suggesting someone search the internet to answer a question.  My original plan was to stop searching at 100-o's, since that seemed to be the appropriate number. However, since I was still getting O(log10(R)) ~ 2, I figured I would keep going until it reached zero results.  That happened, but it turns out to be a special case. When you have a search that includes a 125-character word, Google assumes you're just messing with it and refuses to do the search.

Tuesday, 15 December 2009

Everything is a powerlaw. Everything.

Alternate title: How to use Google and Twelve Years of Higher Education to Prove Useless Things.

So this, pointed me to this, which reminded me of a similar experiment that I'd done a year ago.  Khan's fine, but I like LOLcats, so instead of the number of "a"s, I counted "ol"s after the first "l".
Here are the interesting things I noticed from this data.

  1. The current distributions of lols is very similar to the distribution 18 months ago when I first considered the problem.  Other than a few wobbles, this is well described by a N_{ol}^{-3.5} power law.
  2. This distribution suggests that adding two more characters gets boring at a constant factor.
  3. There is a sharp jump in the current distribution at eleven "ol"s.  Beyond this point, the power law has an identical index. This suggests that during the last 18 months, eleven "ol"s became the new cool, but the boredom factor is still the same.
  4. The fall off in the 2008 data occurs at 50 "ol"s, which corresponds to a jump from 99 to 101 characters. I suspect this shows that something somewhere had a limit of 100 characters.  This isn't visible in the new data, because the tail of the eleven-ol cool boost is sufficient to wash out any such drop.
The khan data linked above has a powerlaw index of N_{a}^{-2.5} for the middle section, between the fall off at low N_{a} (probably just typos, and not meme-related), and the drop above 50 (no theories on this one).  Therefore, while adding "a"s, you're less likely to get bored as you are with "ol"s. I don't have a good test meme for larger letter sets, so I can't test that a three letter suffix/infix would drop off as N^{-4.5} or so.

Another interesting test was to look at the quoted phrase "N martini lunch", where the number was written out.
After a quick upswing (I assume while our luncheoneers gain courage from martini's one and two) to the peak at four (a skew point suggesting the proper number of martinis for your lunching), there's a rapid drop with a power law index of -8.  This probably represents the combination of two effects:
  1. The difficulty of drinking that much liquid during a standard lunch.
  2. The unwillingness of people to call something "lunch" when it's clearly devolved into "mid-day binge."