如何解决如何使用 alpha beta 修剪实现换位表
我正在尝试在我的 negamax 中实现换位表。但首先我想了解伪代码中的所有想法:
` 函数 negamax(node,depth,α,β,color) 是 alphaOrig := α
(* Transposition Table Lookup; node is the lookup key for ttEntry *)
ttEntry := transpositionTableLookup(node)
if ttEntry is valid and ttEntry.depth ≥ depth then
if ttEntry.flag = EXACT then
return ttEntry.value
else if ttEntry.flag = LOWERBOUND then
α := max(α,ttEntry.value)
else if ttEntry.flag = UPPERBOUND then
β := min(β,ttEntry.value)
if α ≥ β then
return ttEntry.value
if depth = 0 or node is a terminal node then
return color × the heuristic value of node
childNodes := generateMoves(node)
childNodes := orderMoves(childNodes)
value := −∞
for each child in childNodes do
value := max(value,−negamax(child,depth − 1,−β,−α,−color))
α := max(α,value)
if α ≥ β then
break
(* Transposition Table Store; node is the lookup key for ttEntry *)
ttEntry.value := value
if value ≤ alphaOrig then
ttEntry.flag := UPPERBOUND
else if value ≥ β then
ttEntry.flag := LOWERBOUND
else
ttEntry.flag := EXACT
ttEntry.depth := depth
transpositionTableStore(node,ttEntry)
return value
但我想知道的一件事是标志是什么?像 EXACT
、UPPERBOUND
和 LOWERBOUND
?
解决方法
在使用 alpha beta 的 Negamax 搜索中,您通常从无限窗口开始(alpha=-inf,beta=inf)。然后在搜索过程中,这个窗口由于截止值而变窄,这导致要么提高 alpha,要么降低 beta。
这些标志表明您找到了哪种类型的节点。如果您在搜索窗口中找到了一个节点(alpha = beta,上限表示分数
您可以阅读有关它的更多信息 here,这也是一个很好的页面,可以找到您对国际象棋编程所需的一切。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。