<p>I am the author of a 2048 controller that scores better than any other program mentioned in this thread. An efficient implementation of the controller is available on <a href="https://github.com/aszczepanski/2048" rel="noreferrer">github</a>. In <a href="https://github.com/wjaskowski/mastering-2048" rel="noreferrer">a separate repo</a> there is also the code used for training the controller's state evaluation function. The training method is described in the <a href="http://arxiv.org/abs/1604.05085" rel="noreferrer">paper</a>.</p>

<p>The controller uses expectimax search with a state evaluation function learned from scratch (without human 2048 expertise) by a variant of <strong>temporal difference learning</strong> (a reinforcement learning technique). The state-value  function uses an <strong>n-tuple network</strong>, which is basically a weighted linear function of patterns observed on the board. It involved more than <strong>1 billion weights</strong>, in total.</p>

<h2>Performance</h2>

<p>At 1 moves/s: <strong>609104</strong> (100 games average)</p>

<p>At 10 moves/s: <strong>589355</strong> (300 games average)</p>

<p>At 3-ply (ca. 1500 moves/s): <strong>511759</strong> (1000 games average)</p>

<p>The tile statistics for 10 moves/s are as follows:</p>

<pre><code>2048: 100%
4096: 100%
8192: 100%
16384: 97%
32768: 64%
32768,16384,8192,4096: 10%
</code></pre>

<p>(The last line means having the given tiles at the same time on the board).</p>

<p>For 3-ply:</p>

<pre><code>2048: 100%
4096: 100%
8192: 100%
16384: 96%
32768: 54%
32768,16384,8192,4096: 8%
</code></pre>

<p>However, I have never observed it obtaining the 65536 tile.</p>
What is the optimal algorithm for the game 2048?
<p>I have recently stumbled upon the game <a href="http://gabrielecirulli.github.io/2048/" rel="noreferrer">2048</a>. You merge similar tiles by moving them in any of the four directions to make "bigger" tiles. After each move, a new tile appears at random empty position with a value of either <code>2</code> or <code>4</code>. The game terminates when all the boxes are filled and there are no moves that can merge tiles, or you create a tile with a value of <code>2048</code>.</p>

<p>One, I need to follow a well-defined strategy to reach the goal. So, I thought of writing a program for it.</p>

<p>My current algorithm:</p>

<pre><code>while (!game_over) {
    for each possible move:
        count_no_of_merges_for_2-tiles and 4-tiles
    choose the move with a large number of merges
}
</code></pre>

<p>What I am doing is at any point, I will try to merge the tiles with values <code>2</code> and <code>4</code>, that is, I try to have <code>2</code> and <code>4</code> tiles, as minimum as possible. If I try it this way, all other tiles were automatically getting merged and the strategy seems good.</p>

<p>But, when I actually use this algorithm, I only get around 4000 points before the game terminates. Maximum points AFAIK is slightly more than 20,000 points which is way larger than my current score. Is there a better algorithm than the above?</p>