【发布时间】:2018-07-05 19:47:19
【问题描述】:
我正在考虑一个我可以实现的游戏的 AI。我的问题是为这个游戏找到一个评估函数,以便应用带有 alpha/beta 切割的 minimax 算法。 https://en.wikipedia.org/wiki/Minimax https://en.wikipedia.org/wiki/Alpha%E2%80%93beta_pruning 让我先描述一下游戏,解释一下我打算用我的 AI 实现什么,然后解决问题。
游戏:
A 2-player turn-by-turn game.
Goal is to kill opponent or have more life points at the end.
In comparison with Magic: The Gathering, you both have monsters to attack the opponent. The number is fixed, let’s say 5 each.
A monster has a fight ability (let's say between 1 and 10), and a damage ability (let's say between 1 and 5).
Each turn:
- Active player declares to his opponent which monster (he owns) engages the current fight.
- He secretly sets multipliers face down (let’s see that in next paragraph).
- Opponent declares which monster (he owns) fights against the first one, while setting multipliers the same way.
- Fight: fight ability * multipliers = final attack. Biggest attack wins and inflicts damage ability to opponent.
- Next turn, active player switch
About multipliers: you have 4 cards in hand that can double your attack (and many empty cards, so that you put 4 cards each turn on the table, and the opponent does not know if you multiplied by 1, 2, 4, 8 or 16).
Just in case: let's say we have a rule for draws to be solved.
我对 AI 的期望: 能够说出一个完美的球员是否应该在给定的位置上获胜。这意味着,对于一个可获胜的位置,人工智能应该告诉有一种方法可以导致胜利,并给出步骤(见下面的例子)。对于对手可以赢得的位置,我还没有决定,对于在所有情况下都不会导致相同获胜者的位置(它们存在;D)。
** 一个例子:**
2 rounds left to go. I have
- Monster A: fight: 5, damage: 2
- Monster B: fight: 3, damage: 4
- life: 5, 1 multiplier left, my turn to begin
My opponent has
- Monster C: fight: 2, damage: 6
- Monster D: fight: 8, damage: 1
-life: 5, 1 multiplier left
In that case, if you think about it, you win if you play well.
Solution:
You can see that if monster C wins, he inflicts 6 and I lost.
But if he loses, one my monsters will inflict at least 2, and even if monster D wins (before or after),
I won't die and I will have more life that my opponent. Victory.
That's an example of what I want the AI to find.
当然,我简化了这个例子。也许它可能会更棘手。这就是我的问题所在。
我们可以从心理上看出,当我们还剩 2 轮时,计算所有可能的决斗很简单(最后一轮不需要计算:如果双方都玩最后的乘数是确定性的)。 正如我们所说,我们还有 5 轮比赛要进行。但我的观点是,我们可以有 20 个,计算一切变得很长(就像在第一轮中试图找到最佳移动一样)。 事实上,我们不会尝试计算它。例如,在国际象棋中,位置过多会导致无法计算所有可能性。
但是,如果你关注我,国际象棋有一个解决方案——我们可以实现一个评估函数。我们怎么知道前面有 10 步,这一步会导致更好的位置?因为我们评估这个职位。我们声称如果一个位置是将军,或者如果你有更多的棋子,或者如果你控制中心等等,那么一个位置会更好......
那么,我的问题在这里:
如何评估我展示的游戏中的位置?
我的意思是,第一轮,如果我能计算出下两轮可能的移动,我会到达第 3 轮或第 4 轮的所有可能位置。但我认为这似乎没有帮助。你可以有更好的生命值,更好的牌,更多的左乘数,这一切都取决于接下来会发生什么。我看不到在一般情况下合规的优势。你呢?
N.B.1 我希望清楚,我简化了游戏规则,当然我们可以添加规则(连续 2 局获胜时的组合,适用于伤害能力的乘数...)
N.B.2 我想到了一个神经网络,但这个问题对我来说仍然很有趣。而且神经网络似乎很难解决,因为需要多轮循环(我的知识比知道神经网络中任何具有追溯作用的模型要受限得多)。
N.B.3 如果我仍然进行完整的计算分析,我认为 minimax 和 alpha/beta 削减会有所帮助,但我担心的是计算时间,这就是我在这里问这个的原因。我可能会从最后两轮位置的完整计算开始,是的。
感谢阅读,希望你和我一样觉得这个问题很刺激!
【问题讨论】:
-
您的目标是解决游戏而不是令人信服地玩游戏?
-
其实是的,因为我之前玩过^^'和我描述的差不多的版本。
-
假设没有负怪物值,你基本上只有 4*4*yourhealth*opponenthealth 可能的游戏状态。听起来像是一个非常适合动态规划的问题。
-
对于给定的一轮,还包括剩余的乘数,如果我添加它们,还有额外的规则!不过谢谢,我会调查的
-
这是一个非常有趣的问题,但我担心它对于这个特定站点可能过于宽泛或离题。是否可能有一个不同的 SE 可以吸引更多知识渊博的答案?我在想 datascience.SE 或 scicomp.SE 或 stats.SE ...
标签: algorithm artificial-intelligence minimax