我正在尝试使用转置表来实现alpha-beta min-max prunning增强功能。我用这个伪代码作为参考:
http://people.csail.mit.edu/plaat/mtdf.html#abmem
function AlphaBetaWithMemory(n : node_type; alpha , beta , d : integer) : integer;
if retrieve(n) == OK then /* Transposition table lookup */
if n.lowerbound >= beta then return n.lowerbound;
if n.upperbound <= alpha then return n.upperbound;
alpha := max(alpha, n.lowerbound);
beta := min(beta, n.upperbound);
if d == 0 then g := evaluate(n); /* leaf node */
else if n == MAXNODE then
g := -INFINITY; a := alpha; /* save original alpha value */
c := firstchild(n);
while (g < beta) and (c != NOCHILD) do
g := max(g, AlphaBetaWithMemory(c, a, beta, d - 1));
a := max(a, g);
c := nextbrother(c);
else /* n is a MINNODE */
g := +INFINITY; b := beta; /* save original beta value */
c := firstchild(n);
while (g > alpha) and (c != NOCHILD) do
g := min(g, AlphaBetaWithMemory(c, alpha, b, d - 1));
b := min(b, g);
c := nextbrother(c);
if g <= alpha then
n.upperbound := g;
store n.upperbound;
if g > alpha and g < beta then
n.lowerbound := g;
n.upperbound := g;
store n.lowerbound, n.upperbound;
if g >= beta then
n.lowerbound := g;
store n.lowerbound;
return g;
这个算法有三个问题:
entry.depth
存储转置表条目中的信息所基于的层数。因此,只有在entry.depth >= remaining_depth
时才能使用这些信息。
逻辑是我们不想使用比“正常”搜索弱的结果。
有时,出于调试目的,条件将更改为:
entry.depth == remaining_depth
这避免了一些search instabilities。无论如何,它不保证没有换位表的搜索结果相同。alpha
更大的分数。没有办法猜测哪个动作最好。
因此,您应该在哈希表中存储仅针对下限(beta截止,即反驳移动)和精确分数(PV节点)的移动。entry.age
字段)。