If you want to hack it, give it a binary de Bruijn sequence with alphabet size k=2. Since it looks to follow whichever pattern already exists, and de bruijn sequences minimize existing patterns, it always beats the game.
> Since it looks to follow whichever pattern already exists, and de bruijn sequences minimize existing patterns, it always beats the game.
I'm pretty sure this isn't true though. A de bruin sequence doesn't guarantee that the order of the n-patterns is random, only that the number of unique n-length patterns is maximized.
Indeed, the algorithm you mention puts n-subsequences with many 0's in the front, and subsequences with many 1's in the back. Sure, every n-length subsequence appears only once, but because the order of the subsequences does follow a predictable pattern, your total sequence is still pretty predictable.
This disparity isn't noticeable when n is small (you chose n=6), so you can comfortably beat the game. But pick a large n and your sequence becomes rather predictable.
Try n=20. In that case, the generated sequence S has length |S|=32,768=2^15. In the first half, there are 9098 0's and 7286 1's. In the second half these numbers are exactly the opposite. Throw this sequence into the game, and you end up with a prediction accuracy of 50%. Not worse than random, but you didn't beat the game either.
I picked n=6 in particular because the code checks the past 5 numbers so 6 means that it can't do its frequency analysis but also avoids the problem you mention. And yes, it isn't random, rather it enforces a unique sequence. Because the code looks for repetition one number at a time, a de bruijn sequence has to be pretty optimal since it attempts not to.
Also this sequence seems to work better:
0000001001000101010011010000110010110110001110101110011110111111
Ah yeah. My monitor cut off the text under the graph so I didn't know they just gave away their predictive algorithm. n=6 obviously works, cool approach!
I used http://combos.org/bruijn and pressed left for zero and right for one.
Using rule Grandmama creates close to a perfectly straight line up and to the right when you start from the first 1 in the sequence.
Try: 1001000101010011010000110010110110001110101110011110111111000000
where 1 is right and 0 is left.