0
알파 베타 제거 기능을 사용하여 Minimax를 구현하려고합니다. 이제 내 문제는 위치를 평가하고 반복에서 다음 이동으로 역 추적 (한 레벨 위로)하면 "currentBoard는"makeMove와 removeFigure 모두가 새로운 보드를 반환에도 불구하고, 초기 보드하지만 평가 잎에서 아닙니다. Minimax : 백 트랙킹을위한 보드 사본 저장
그래서 어떻게 올바른 되돌아을 위해 기존의 보드를 "저장"할 수 있습니까?시 : 보드가 단순한 해시 맵이기 때문에 이동을 취소하는 대신 복사를 사용하고 싶습니다. 따라서이 방법이 더 쉬울 것 같아요.
여기에 있습니다.
public int alphaBeta(Board currentBoard, int depth, int alpha, int beta, boolean maximisingPlayer) {
int score;
if (depth == 0) {
return Evaluator.evaluateLeaf(whichColorAmI, currentBoard);
}
else if (maximisingPlayer) {
ArrayList<Move> possibleMoves= new ArrayList<Move>();
possibleMoves=getPossibleMoves(whichColorAmI, currentBoard);
for (Move iterMoveForMe : possibleMoves) {
if(currentBoard.figureAt(iterMoveForMe.to)!=null){
currentBoard = currentBoard.removeFigure(iterMoveForMe.to);
}
currentBoard= currentBoard.moveFigure(iterMoveForMe.from, iterMoveForMe.to);
score = alphaBeta(currentBoard, depth-1, alpha, beta, false);
if(score>=alpha){
alpha=score;
if(depth==initialDepth){
moveToMake=iterMoveForMe;
}
}
if (alpha>=beta) {
break;
}
}
return alpha;
}
else {[Minimizer...]
}
체스에 인공 지능을 쓰는 동안 나는 비슷한 문제가있었습니다. 내 솔 루션이 정확한지 확실하지 않지만 보드의 요소에 대한 방어적인 사본을 만들었습니다. –