本文整理汇总了C++中MoveList::prune方法的典型用法代码示例。如果您正苦于以下问题:C++ MoveList::prune方法的具体用法?C++ MoveList::prune怎么用?C++ MoveList::prune使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoveList
的用法示例。
在下文中一共展示了MoveList::prune方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Quiescence
int Minimax::Quiescence(Board *board, GameInfo *gameInfo, int depth, int alpha, int beta) {
// Evaluate the node in its current state. If it causes a beta-cutoff, assume that there will be no move further down the
//game tree that will result in a better evaluation. Otherwise, set it as the lower bound, alpha.
int nodeEvaluation = Eval(board, gameInfo);
if (nodeEvaluation >= beta) return beta;
if (nodeEvaluation > alpha) alpha = nodeEvaluation;
MoveList moveList;
// If the node is in check, consider every move. Otherwise, just consider captures/promotions.
moveList.generate(gameInfo->turn, board, gameInfo, !MoveList::InCheck(gameInfo->turn, board));
moveList.prune((Piece::Color)!gameInfo->turn, board);
for (MoveList::iterator moveItr = moveList.begin(); moveItr != moveList.end(); moveItr++) {
Move move = *moveItr;
board->executeMove(move);
// Save any irreversible game info before making a move.
GameInfo::Irreversible irreversible(gameInfo);
gameInfo->executeMove(move);
int childEval = 0;
// If we are at depth 0, just get the score of the board (The score is negated as it is measured relative to the opposite color).
if (depth == 0) childEval = -Eval(board, gameInfo);
else childEval = -Quiescence(board, gameInfo, depth - 1, -beta, -alpha);
board->reverseMove(move);
gameInfo->reverseMove(irreversible);
if (childEval >= beta) return beta;
if (childEval > alpha) alpha = childEval;
}
return alpha;
}