16

我正在尝试使用转置表实现增强的 alpha-beta min-max 修剪。我使用这个伪代码作为参考:

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;

该算法的三个问题:

  1. 我相信我应该在每个保存的转置表条目中存储深度(= 到叶层的距离),并且仅在 entry.depth>=currentDepth (= 条目与叶层的距离更大或相等)时才使用条目。上面的伪代码中没有显示,也没有在那里讨论,我想确保我理解正确。

  2. 我想为每个位置存储最佳移动,以将其用于移动排序并在搜索停止后提取最佳移动。在纯粹的 min-max 中,哪个动作是最好的很明显,但是当使用 alpha-beta 截止值迭代时哪个动作是最好的?我可以假设给定位置的最佳移动是循环结束时找到的最佳移动(有或没有截止)吗?

  3. 在迭代深化方案中执行此算法时 - 我应该在每次深度增加之前清除转置表吗?我认为不是,我希望您使用先前迭代中存储的位置,但我不确定这些信息是否足以进行更深入的搜索(应该在检查表条目深度时)?

4

1 回答 1

8
  1. 你是对的。entry.depth存储换位表条目中的信息所基于的层数。所以你只能在entry.depth >= remaining_depth.

    逻辑是我们不想使用比“正常”搜索弱的结果。

    有时,出于调试目的,条件更改为:

    entry.depth == remaining_depth
    

    这避免了一些搜索不稳定性。无论如何,它不能保证没有转置表的搜索结果相同。

  2. 存储并不总是最好的。

    当搜索失败率很低时,没有“最佳移动”。我们唯一知道的是,没有任何动作足以产生大于 的分数alpha。没有办法猜测哪个动作最好。

    因此,您应该仅在哈希表中存储下限(beta-cutoff 即反驳移动)和精确分数(PV 节点)的移动。

  3. 不,你不应该。通过迭代加深,一次又一次地到达相同的位置,换位表可以加快搜索速度。

    您应该清除移动之间的转置表(或者,最好使用附加entry.age字段)。

于 2015-05-02T13:20:03.100 回答