How predictable are you?

The best strategy to win rock-paper-scissors is to throw random gestures. People are very bad at being unpredictable though, so it's easy to write a computer program predicting your next move and winning much more often then if it followed the mathematically best strategy.

Computer:
Human:
Ties:
...

In mozilla compatible browsers you can also use keys 1 or r for rock, 2 or p for paper, 3 or s for scissors.


Human controlled cellular automaton

While you're playing a cellular automaton is composing the game soundtrack using whatever it knows about your strategy so far. The sound track starts as soon as the computer player has memorized your first pattern and gets updated after each move. But if you stop playing the sound will continue forever.

If the pattern seems dull - it's all your fault - that's your own redundancy that's being made audible.

Another interpretation is evolution: looping is fitness function in the world of your subconscious patterns; patterns that lead to unpredictable combinations die and get substituted by mutants; pattern that leads to itself survives and loops forever if environment doesn't change. Each time you start to play again the environment (statistics of your choices) changes, and loop may break - organism has to adapt.

But some patterns are less likely to change - you either keep repeating them verbatim over and over or don't throw them very often - those will stay for long. Also, shorter loops are less likely to be broken by your maneuver - just like a fly is less likely to be shot then an elefant. As you keep on playing, computer player learns more and more of your patterns and probability of hitting and changing the statistics of a single one gets lower.


The Revenge of the Grease Monkeys

The infinite monkey theorem states that a monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type or create a particular chosen text, such as the complete works of William Shakespeare.

In this context, "almost surely" is a mathematical term with a precise meaning, and the "monkey" is not an actual monkey; rather, it is a vivid metaphor for an abstract device that produces a random sequence of letters ad infinitum.

Monkeys, it seems, are better then us at being random. As evidence, here is a tiny greasemonkey script that plays rock-paper-scissors for human and achieves much better results. You can only try it out if you have greasemonkey extension for firefox installed.

When installed, simply refresh this page and agree to cheat. The pseudo random sequence that grease monkey player uses isn't perfect, but good enough to tie in the long run or even win with a slight lead.



[geeky]

This is the third incarnation of my Rock Paper Scissors implementation. The first one was written in python and had more sophisticated (read unneccesary complex) algorithm. It also depended on curses module for python which doesn't work (properly) on windows.

Previous version was in plain javascript and featured the first boring version of human controlled cellular automaton (HCCA) that printed colored letters.

This version, arguably the most readable, is written in haxe, from which javascript is generated by haxe compiler. Sound generating HCCA is written in haxe and compiles to flash. The game talks to HCCA via haxe remoting. There is also test suite, which performs unit test of the game logic and prediction algorithm (game "AI"). Test suite compiles to neko bytecode instead of javascript, so that test can be run automatically on command line.

(Open) Source: