I have recently stumbled upon the game 2048 . 我最近偶然发现了2048游戏。 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 2
or 4
. 每次移动后,新的图块将出如今随机的空白位置,值为2
或4
。 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 2048
. 当全部盒子都装满而且没有能够合并磁贴的移动,或者您建立的值为2048
磁贴时,游戏终止。 git
One, I need to follow a well-defined strategy to reach the goal. 第一,我须要遵循明肯定义的策略才能实现目标。 So, I thought of writing a program for it. 所以,我想到了为此编写程序。 github
My current algorithm: 我当前的算法: 算法
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 }
What I am doing is at any point, I will try to merge the tiles with values 2
and 4
, that is, I try to have 2
and 4
tiles, as minimum as possible. 我正在作的是在任什么时候候,我将尝试合并值2
和4
的图块,也就是说,我尝试将2
和4
图块尽量地减小。 If I try it this way, all other tiles were automatically getting merged and the strategy seems good. 若是以这种方式尝试,全部其余磁贴将自动合并,而且该策略看起来不错。 app
But, when I actually use this algorithm, I only get around 4000 points before the game terminates. 可是,当我实际使用该算法时,在游戏终止以前我只能获得4000点。 Maximum points AFAIK is slightly more than 20,000 points which is way larger than my current score. 最高分数AFAIK略高于20,000点,这比我目前的分数还大。 Is there a better algorithm than the above? 是否有比以上更好的算法? dom