【问题标题】:Alpha beta pruning root moveAlpha beta 修剪根移动
【发布时间】:2012-04-24 12:40:55
【问题描述】:

我目前正在编写一个国际象棋引擎并且已经取得了不错的进展,但是我遇到了一个问题,并希望对这种方式提出一些意见。好吧,我的问题是我的国际象棋人工智能没有做出“最好的”举动,它似乎看不到简单的事情,比如它的棋子可能会被收回或其他什么。我的 alpha beta 修剪如下。

int Search (TREE *tree, int ply, int wtm, int alpha, int beta) { 
    if (0 == ply) { 
        return quiesce(tree, ply, wtm, alpha, beta); 
    } 

    movePointer = GenCaptures(tree, MAXPLY, wtm, moves); 
    movePointer = GenNonCaptures(tree, wtm, movePointer); 
    for (move = &moves[0]; move < movePointer; move++) { 
        MakeMove(tree, &tree->movePath[ply], wtm); 
        score = -Search(tree, ply - 1, Flip(wtm), -beta, -alpha); 
        UnmakeMove(tree, &tree->movePath[ply], wtm); 
        tree->movePath[ply].move = 0; 
        if (score >= beta) { 
            return beta; 
         } 
         if (score > alpha) { 
             alpha = score; 
         } 
    } 

我认为我的 alpha beta 修剪效果很好,因为它确实返回了合理的移动,我认为问题在于当我尝试获取我的 rootMove 时。我试图让根移动(

int searchRoot( TREE *tree, int ply, int wtm ) { 
    //int depth = 1; 
    int moves[220]; 
    int *movePointer = 0; 
    int *move = 0;
    int rootAlpha = -MATE - 1; 
    int rootValue = -MATE - 1; 
    int rootBeta = MATE + 1; 
    MOVE currentMove; 
    currentMove.move = 0; 
    currentMove.capture = 0; 
    movePointer = GenCaptures( tree, MAXPLY, wtm, moves ); 
    movePointer = GenNonCaptures( tree, wtm, movePointer ); 
    for ( move = &moves[0]; move < movePointer; move++ ) { 
        currentMove.move = *move; 
        tree->movePath[MAXPLY] = currentMove; 
        MakeMove( tree, &currentMove, wtm ); 
        int lastValue = -Search( tree, MAXPLY -1, Flip(wtm), rootAlpha, rootBeta ); 
        UnmakeMove( tree, &currentMove, wtm ); 
        if ( lastValue > rootValue ) { 
            tree->rootMove = *move; rootValue = lastValue; 
        } 
    } 
} 

任何想法都会有所帮助,谢谢。

【问题讨论】:

  • 您能获得多深 - MAXPLY 是什么?浅层搜索效果不佳。
  • 通常您希望在根节点中以与在其他节点中相同的方式处理alphabeta。在这里,您没有更新根节点中的 alpha,这会使您的搜索变慢(但不会改变结果)。
  • 您应该在 TalkChess 这样的专业论坛上提出这个问题,它可能会引起 Bob Hyatt 或同等机构的注意:talkchess.com/forum/index.php

标签: c artificial-intelligence chess alpha-beta-pruning


【解决方案1】:

您的 searchRoot 没有正确实现 negamax 的想法。你的线路

int lastValue = -Search( tree, MAXPLY -1, Flip(wtm), rootAlpha, rootBeta );

应该阅读

int lastValue = -Search( tree, MAXPLY -1, Flip(wtm), -rootBeta, -rootAlpha ); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多