私は現在チェスエンジンを書いていて、かなり進んでいますが、問題に遭遇したので、方法についていくつか意見をお願いします. わかりました、私の問題は、私のチェス AI が「最善の」動きをしないという事実です。その駒が取り戻される可能性があるという事実などの単純なことを認識できていないようです。私のアルファベータ剪定は次のようになります。
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;
}
}
私のアルファ ベータ プルーニングは妥当な動きを返すので十分に機能すると思います。問題は 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, ¤tMove, wtm );
int lastValue = -Search( tree, MAXPLY -1, Flip(wtm), rootAlpha, rootBeta );
UnmakeMove( tree, ¤tMove, wtm );
if ( lastValue > rootValue ) {
tree->rootMove = *move; rootValue = lastValue;
}
}
}
どんなアイデアでも役に立ちます、ありがとう。