2048游戏的最佳算法是什么?

∥☆過路亽.° 提交于 2020-08-04 13:01:13

问题:

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磁贴时,游戏终止。

One, I need to follow a well-defined strategy to reach the goal. 第一,我需要遵循明确定义的策略才能实现目标。 So, I thought of writing a program for it. 因此,我想到了为此编写程序。

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. 如果以这种方式尝试,所有其他磁贴将自动合并,并且该策略看起来不错。

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? 是否有比以上更好的算法?


解决方案:

参考一: https://stackoom.com/question/1VkOc/游戏的最佳算法是什么
参考二: https://oldbug.net/q/1VkOc/What-is-the-optimal-algorithm-for-the-game-2048
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!