2048游戏的最佳算法是什么? - What is the optimal algorithm for the game 2048?

问题:

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 . 每次移动后,新的图块将出如今随机的空白位置,值为24 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. 我正在作的是在任什么时候候,我将尝试合并值24的图块,也就是说,我尝试将24图块尽量地减小。 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


解决方案:

参考一: https://stackoom.com/question/1VkOc/游戏的最佳算法是什么
参考二: https://oldbug.net/q/1VkOc/What-is-the-optimal-algorithm-for-the-game-2048
相关文章
相关标签/搜索