“面朝上”的纸牌算法

时间:2011-01-30 21:46:49

标签: algorithm path-finding brute-force

我正在设计一个以最高得分的方式解决单人纸牌游戏的程序。 该游戏在以下积分系统上得分:

10 points for moving Aces to top
9 points for moving 2s to top
8 points for moving 3s to top
7 points for moving 4s to top
6 points for moving 5s to top
5 points for moving 6s to top
4 points for moving 7s to top
3 points for moving 8s to top
2 points for moving 9s to top
1 points for moving 10s or face-cards to top
2 points for freeing a "downcard" (face-down card on the table)
2 points for moving a card from the deck to the table
-2 points deducted for moving a card from the top to the table
-20 points deducted for flipping over the deck
Putting a card back to the top after moving it from the top to the table does not give double points.

来自牌组的牌一次翻转一次,玩家可以无限次翻转牌组(但是,-20点扣除仍然适用)。

我找到了各种策略指南,例如Klondike Strategy Guide for Windows Solitaire Game,但这些指南适用于真正的单人纸牌游戏,其中桌卡不知道。

我正在寻找一种算法,用于解决我称之为“面朝上”的单人纸牌游戏,在这种游戏中,我知道了牌组。 编辑:从下面的答案中给出的论文中,似乎这款游戏被称为“深思熟虑的纸牌”。

到目前为止,我的想法是:某种强制性的强迫,所有可能的动作都经过了尝试和评分;一种简单的算法,可以单独查看每一列并尝试“最佳”移动;最后是一种类似于寻路的算法,每次移动得分,找到最好的“路径”。

暴力强迫的问题在于它可能需要永远(字面意思),因为你可以无限重复移动。通过一个简单的算法,我无法做一些棘手的事情,比如重新排列两列,让所有的心和俱乐部(例如)释放出一颗孤独的心。从我所看到的,寻路将起作用,但我对这种实现如何工作感到迷茫。

2 个答案:

答案 0 :(得分:3)

您可能会发现以下论文很有帮助(似乎这已由研究团队完成。)

在RealTime中搜索Solitaire:

Solitaire:Man vs. Machine

答案 1 :(得分:1)

我要尝试的第一件事是一个天真的固定步骤先行算法,在每一步,我都会分析前面所有可能的n步骤,然后我会选择一个导致最高步骤的步骤总分。

在相同系列的伪随机包上使用不同的n值,并通过增加它来了解如何(如果有的话)得分。

如果这会带来合理的成功,下一步是将点数分配给您在评估过程中可以使用的某些位置。 (例如,可以减去'downcard'aces从它们堆顶部的距离。)

下一步可能是自适应搜索,您首先向前看固定数量的步骤,然后进一步扩展移动树的有希望的叶子。 (基本上是修剪。)

等等,有很多你可以尝试,听起来很有趣,所以尽情享受吧。

但如果一切都失败了,请组织编码竞赛。 :)