C++ 带TT的AlphaBeta(MTD-f)

C++ 带TT的AlphaBeta(MTD-f),c++,algorithm,chess,minimax,alpha-beta-pruning,C++,Algorithm,Chess,Minimax,Alpha Beta Pruning,我的问题是关于塔尔帕贝塔的。在MTD-f的论文()中,alpha-beta的实现与我发现的其他()有很大不同 他们之间有什么区别 我的启发式返回一个整数,所以我没有小数,我应该特别注意吗 我知道: template <class node, class transposition_table> bound_and_action<node> alpha_beta_with_memory(node& root, depth depth, bound a

我的问题是关于塔尔帕贝塔的。在MTD-f的论文()中,alpha-beta的实现与我发现的其他()有很大不同

他们之间有什么区别

我的启发式返回一个整数,所以我没有小数,我应该特别注意吗

我知道:

template <class node, class transposition_table>
bound_and_action<node> alpha_beta_with_memory(node& root, depth depth,
        bound alpha, bound beta, transposition_table& table)
{


    auto value_in_hash = table.find(root);

    if (value_in_hash != table.end()
            && value_in_hash->second._depth > depth) { // Transposition table lookup

        auto bound_in_hash = value_in_hash->second;


        if ( bound_in_hash.lower_bound >= beta )
          return { bound_in_hash.lower_bound, root.get_action() };

        if ( bound_in_hash.upper_bound <= alpha )
          return { bound_in_hash.upper_bound, root.get_action() };


        alpha = std::max(alpha, bound_in_hash.lower_bound);
        beta = std::min(beta, bound_in_hash.upper_bound);
    }

    bound_and_action<node> ret;

    if ( depth == 0 || root.is_terminal() ) { // Leaf Node

      ret._bound = root.get_heuristic_value();
      ret._action = root.get_action();

    } else {

         list<node> children;
        root.get_children(children);

        if (root.is_max_node()) {

            ret._bound = INT_MIN;
            bound a = alpha; //Save original alpha

            for (auto child : children) {


                bound_and_action<node> possible_ret = alpha_beta_with_memory(child, depth - 1,
                                                      a, beta, table);

                if (possible_ret._bound == 1000) {
                    return {1000, root.get_action()};
                }

                if (possible_ret._bound > ret._bound ) {
                    ret._bound = possible_ret._bound;
                    ret._action = child.get_action();
                }

                a = std::max(a, ret._bound);

                if ( beta <= ret._bound ) {
                    break;    // beta cut-off
                }

            }

        } else { // if root is a min node.

            ret._bound = INT_MAX;
            bound b = beta; //Save original beta


            for (auto child : children) {


                bound_and_action <node> possible_ret = alpha_beta_with_memory(child, depth - 1,
                                                       alpha, b, table);

                if (possible_ret._bound == 1000) {
                    return {1000, root.get_action()};
                }

                if (possible_ret._bound < ret._bound) {
                    ret._bound = possible_ret._bound;
                    ret._action = child.get_action();
                }

                b = std::min(b, ret._bound);

                if ( ret._bound <= alpha ) {
                    break;    // alpha cut-off
                }

            }
        }
    }

    //
    //  ----- Transposition table storing of bounds.

    hash_struct& hash_value = table[root];

    if (hash_value._depth < depth) {
        // Fail low result implies an upper bound.
        if (ret._bound <= alpha) {
            hash_value.upper_bound = ret._bound;
        }
        // Found an accurate minimax value - will not occur if called with zero window.
        if ( ret._bound > alpha && ret._bound < beta){
          hash_value.lower_bound = ret._bound;
          hash_value.upper_bound = ret._bound;
        }

        // Fail high result implies a lower bound.
        if (ret._bound >= beta ) {
            hash_value.lower_bound = ret._bound;
        }

        hash_value._depth = depth;
        hash_value._action = ret._action;
    }

    return ret;
}
模板
用内存(节点和根、深度、,
绑定alpha、绑定beta、换位(表和表)
{
_hash=table.find(root)中的自动值_;
if(值\u在\u散列中!=table.end()
&&值\u在\u hash->second.\u depth>depth){//换位表查找
自动绑定\u-in\u-hash=值\u-in\u-hash->second;
if(绑定\u在\u散列中。下限>=beta)
返回{bound_in_hash.lower_bound,root.get_action()};
if(绑定\u在\u散列中。上限\u返回绑定){
返回边界=可能返回边界;
ret._action=child.get_action();
}
a=标准::最大值(a,反向边界);

如果(beta)mtdf版本试图通过大量使用空窗口的重新搜索来放大正确的分数。为了让它正常工作,它必须为表中的每个节点存储一个上限和一个下限。传统的alpha beta只存储一个上限或下限。使用零窗口时,值永远不会介于alpha和beta之间,因此我不需要如果使用零窗口调用,则不会出现精确的minimax值*/如果g>alpha和g