我正在創建的國際象棋中的運動有一個問題。下面是一個檢查,如果一招是有效的方法:國際象棋比賽中的典當運動 - 爪哇
public boolean isMove(int row, int col, Pawn[][] board){
Pawn p = board[row][col];
int direction = 1;
if (this.color=='w') {
direction = -1;
}
if (p == null && this.col == col && ((this.row + direction) == row) || (this.row + 2 * direction) == row && ! this.hasMoved) { //can move
return true;
}
else if (p != null && p.color != this.color && row == (this.row + direction) && (col == (this.col - 1) || col == (this.col + 1))) { // can capture
return true;
}
return false;
}
這裏有一些產出,我越來越:
此舉不應該是有效的,但還沒有它允許移動到那個廣場。我在考慮上面發佈的方法存在問題。
你有調試過嗎? –