我已经为我的国际象棋游戏实现了 alpha beta 算法,但是最终做出一个相当愚蠢的举动需要很多时间(4 层需要几分钟)。
我一直在努力寻找错误(我假设我犯了一个)2 天了,我非常感谢我的代码中的一些外部输入。
getMove 函数:为根节点调用,它为其所有子节点(可能的移动)调用 alphaBeta 函数,然后选择得分最高的移动。
Move AIPlayer::getMove(Board b, MoveGenerator& gen)
{
// defined constants: ALPHA=-20000 and BETA= 20000
int alpha = ALPHA;
Board bTemp(false); // test Board
Move BestMov;
int i = -1; int temp;
int len = gen.moves.getLength(); // moves is a linked list holding all legal moves
BoardCounter++; // private attribute of AIPlayer object, counts analyzed boards
Move mTemp; // mTemp is used to apply the nextmove in the list to the …
Run Code Online (Sandbox Code Playgroud) c++ algorithm chess artificial-intelligence alpha-beta-pruning