Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the optimal blind algorithm for the game, 2048? [closed]

The game 2048 has exploded in popularity since its release in February 2014. For a description of the game and discussion of optimal algorithms, see What is the optimal algorithm for the game 2048?. Here is the source code.

A blind algorithm for 2048 is one that cannot see the board; the only feedback the algorithm receives is whether or not an attempted slide occurred (we may suppose a blocked slide produces an audible beep). A blind algorithm is practically useful for getting started in 2048 without having to give the game your undivided attention.

Here is my specific question: is there a blind algorithm for 2048 that consistently does better than a mean score of 3500 in 10^6 trials? (only post an answer you have validated)

This is the performance of the LADDER algorithm, which may be notated as (LD* RD*)* (+U). That is, one loops over "left, down repeatedly until stuck, right, down repeated until stuck" and presses up iff left, right, and down are all blocked, which occurs iff the top row(s) are completely empty and the bottom row(s) are completely full. I call this algorithm LADDER because of the letters LDDR, and because I imagine climbing down ladders like Mario in Donkey Kong. The motivation for the algorithm is to maintain an increasing gradient from top to bottom of the board, similar to many of the non-blind algorithms.

Here is a histogram for 10^6 trials of LADDER colored by top tile on the final board with bin width 32 and mean 3478.1. I generated this data by simulating the game and algorithm in Python, using probability .9 that each new tile is a 2, as in the original game. You can't see the 1024 games at this vertical scale but they are sparsely distributed between 8000 and 16000. The fractal structure relates to the number of occurrences of the top tile, second-from-top tile, and so on. By comparison, random button mashing gave a mean of about 800 in 10^4 trials.

enter image description here

like image 543
Jonathan Bloom Avatar asked Mar 30 '14 18:03

Jonathan Bloom


People also ask

What is the optimal algorithm for the game 2048?

Our algorithm is based on the Expectimax algorithm, which is itself a variation of the Minimax algorithm, but where the possible routes through our tree are weighted by the probability that they will happen.

How does the 2048 algorithm work?

The starting move with the highest average end score is chosen as the next move. With just 100 runs (i.e in memory games) per move, the AI achieves the 2048 tile 80% of the times and the 4096 tile 50% of the times. Using 10000 runs gets the 2048 tile 100%, 70% for 4096 tile, and about 1% for the 8192 tile.


1 Answers

The most important in the 2048 game is to concentrate the high numbers along the borders and not in the middle. So a very good strategy is to put everything along the bottom as long as possible. Your LADDER algorithm does this, but I'd like to concentrate more on the left side and not switch to the right side completely. This is the algorithm in pseudo code:

while(true)     {     if (down)         continue;     elseif(left)         continue;     elseif (right)         continue;     else         {         up;         down; //if forced to go up; go back down immediately         }     } 

Using your convention this would be:

((D*L)*R)U 

in words: go down as long as you can; if you cannot; go left; if you cannot go left; go right. You will rarely need to go up.

Since I won't have time shortly to implement this to use it 10⁶ times; I hope someone else can give the correct statisctics for this, but my guess is this will outperform your LADDER algorithm

like image 184
Chris Maes Avatar answered Sep 16 '22 11:09

Chris Maes