Negamax - 玩家移动两次
如果满足条件,同一玩家会移动,您如何处理这种游戏?
我尝试过这样的事情,但我认为这不太正确:
function negamax(node, depth, α, β, color)
if node is a terminal node or depth = 0
return color * the heuristic value of node
else
foreach child of node
if (condition is met) // the same player moves
val := negamax(child, depth-1, α, β, color)
else
val := -negamax(child, depth-1, -β, -α, -color)
if val≥β
return val
if val≥α
α:=val
return α
How do you handle games where, if a condition is met, the same player moves ?
I tried something like this but I don't think it's quite right:
function negamax(node, depth, α, β, color)
if node is a terminal node or depth = 0
return color * the heuristic value of node
else
foreach child of node
if (condition is met) // the same player moves
val := negamax(child, depth-1, α, β, color)
else
val := -negamax(child, depth-1, -β, -α, -color)
if val≥β
return val
if val≥α
α:=val
return α
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不要尝试为此改变极小极大算法本身,而是修改游戏表示来适应。基本上有两种解决方案:
在设计与 转置表 和我不知道的文献中的 讨论您的特定问题。当我想出上面的解决方案 2 时,我感觉很聪明,但我怀疑许多其他人也发明了同样的技巧。
我应该说,正确处理极小极大系列是出乎意料的困难。用高级语言设计游戏搜索人工智能时的一个技巧是在更简单的游戏(缩小棋盘尺寸、使用井字游戏等)上测试您的搜索算法,以确保正确性。如果游戏足够小,你可以。通过手工玩游戏来确保其结果有意义;b.测试高级算法,例如 negascout,确保它们给出与 naive negamax 相同的答案。尝试将具有游戏特定行为(评估函数、棋盘表示、搜索和存储启发式等)的代码远离执行树搜索的代码也是一个好主意。
Dont try changing the minimax algorithm itself for this, instead modify the game representation to accommodate. There are basically two solutions:
I know of no literature that discuses your particular problem. I felt clever when I came up with solution 2 above, but I suspect many other people have invented the same trick.
I should say, getting the minimax family right is surprisingly hard. A trick when designing game search AIs in high level languages is to test your search algorithms on simpler games (reduced board size, use tic-tac-toe, etc) to ensure correctness. If the game is small engough you can a. make sure its results make sense by playing the game out by hand and b. test advanced algorithms like negascout by making sure they give the same answer as naive negamax. It is also a good idea to try to keep code with game specific behavior (evaluation functions, board representations, search and storage heuristics, etc) away from the code that does tree searches.
在 negamax 中,您正在探索一个树结构,其中每个节点都有与玩家的移动相对应的子节点。如果在某些情况下,玩家可以移动两次,您可能会将该玩家的“移动”视为该玩家所做的两次移动序列。更一般地说,您应该将当前游戏状态的子级视为当前玩家在轮到他们后可以进入游戏的所有可能状态。这包括一步移动可达到的所有游戏状态,以及如果玩家能够在一回合内进行两步移动则可通过两步移动达到的所有游戏状态。因此,您应该保持 negamax 的基本逻辑不变,但更新代码以生成后继状态,以处理单个玩家可以移动两次的情况。
希望这有帮助!
In negamax, you are exploring a tree structure in which each node has children corresponding to the moves made by a player. If in some case a player can move twice, you would probably want to think of the "move" for that player as the two-move sequence that player makes. More generally, you should think of the children of the current game state as all possible states that the current player can get the game into after their turn. This includes all game states reachable by one move, plus all the game states reachable in two moves if the player is able to make two moves in one turn. You should, therefore, leave the basic logic of negamax unchanged, but update your code to generate successor states to handle the case where a single player can move twice.
Hope this helps!
当条件满足时,不要减少深度。
When condition is met, don't decrement depth.