我正在制作Mancala-AI。我的问题是条件为
的If语句的内容botChoice <= 5 && usedBoardState[botChoice] == 1 && usedBoardState[12-botChoice] >= 1
即使在许多情况下它应该是没有运行。如果您对我的代码有任何疑问,请随时询问,因为我是初学者业余编码员。
int[] staticBoardState = new int[14];
for(int f = 0; f <= 13; f++) {
staticBoardState[f] = boardState[f];
}
double[] movePoints = new double[6];
int scorePoints;
int freeTurnPoints;
int buildupPoints;
int emptyPoints;
int capturePoints;
double bestMovePoints;
int bestMove;
for(int f = 0; f <= 5; f++) {
capturePoints = 0;
int[] usedBoardState = new int[14];
for(int g = 0; g <= 13; g++) {
usedBoardState[f] = staticBoardState[f];
}
int initialScore = usedBoardState[6];
int botChoice = f;
int botHole = usedBoardState[botChoice];
usedBoardState[botChoice] = 0;
for(int g = 0; g < botHole; g++) {
botChoice++;
if(botChoice>12) {
botChoice = 0;
}
usedBoardState[botChoice]++;
}
if(botChoice<=5 && usedBoardState[botChoice]==1 && usedBoardState[12-botChoice]>=1) {
capturePoints += usedBoardState[12 - botChoice] + 1;
usedBoardState[6] += usedBoardState[12 - botChoice] + 1;
usedBoardState[botChoice] = 0;
usedBoardState[12 - botChoice] = 0;
}
scorePoints = usedBoardState[6] - initialScore;
if(botChoice==6) {
freeTurnPoints = 1;
} else {
freeTurnPoints = 0;
}
if(usedBoardState[botChoice]==0) {
emptyPoints = -100;
} else {
emptyPoints = 0;
}
movePoints[f] = scorePoints + capturePoints + (3 * freeTurnPoints) + emptyPoints;
}
for(int f = 0; f <=5; f++) {
System.out.println(movePoints[f] + " ");
}
bestMovePoints = movePoints[0];
bestMove = 0;
for(int f = 1; f <= 5; f++) {
if(movePoints[f]>bestMovePoints) {
bestMovePoints = movePoints[f];
bestMove = f;
}
}
return bestMove;
感谢任何帮助。谢谢!