2048!
Towards the end of the 2048-craze era, I wrote a solver for the game that unlike other solvers that came out, had no built-in algorithm about how to play.<p>It was quite simple: It simulated games from the current position using random moves, and chose the move that resulted in the highest average end-game score. The surprising result was that even though random moves are obviously a terrible game plan (on average, random play from a given starting position lasted 40 extra moves and scored an extra of 340 points before dying), using the least bad move each time led to very good game play over all: An average game had 70000 points and lasted 3000 moves, reaching the 2048 tile 100% of time and the 4096 tile 70%.<p>Also, perhaps of interested to this crowd, I later noticed that the web version of the game had exposed JS for the board state and controls. This allowed me to write a bookmarklet version of the solver that could play the original web version directly. This was fun because many game variants came out (like Hexagon 2048, and 20Euros) which were all different games, but were based on the same controllers. The solver, being "general purpose" could play many of these variants without any tweaking.<p>Solver demo: <a href="http://ronzil.github.io/2048-AI/" rel="nofollow">http://ronzil.github.io/2048-AI/</a>
Write up: <a href="https://stackoverflow.com/questions/22342854/what-is-the-optimal-algorithm-for-the-game-2048/23853848#23853848" rel="nofollow">https://stackoverflow.com/questions/22342854/what-is-the-opt...</a>
Bookmarklet version: <a href="http://ronzil.github.io/2048AI-AllClones/" rel="nofollow">http://ronzil.github.io/2048AI-AllClones/</a>