flutter: 完成 removeBanStones()

This commit is contained in:
Calcitem 2020-11-15 12:59:17 +08:00
parent 20c33939bd
commit 77208226c1
1 changed files with 51 additions and 1 deletions

View File

@ -199,9 +199,42 @@ class Position {
}
currentSquare = s;
/*
int n = addMills(currentSquare);
//int n = addMills(currentSquare);
if (n == 0) {
assert(pieceCountInHand[Color.black] >= 0 &&
pieceCountInHand[Color.white] >= 0);
if (pieceCountInHand[Color.black] == 0 &&
pieceCountInHand[Color.white] == 0) {
if (checkGameoverCondition()) {
return true;
}
phase = Phase.moving;
action = Act.select;
if (rule.hasBannedLocations) {
removeBanStones();
}
if (!rule.isDefenderMoveFirst) {
changeSideToMove();
}
if (checkGameoverCondition()) {
return true;
}
} else {
changeSideToMove();
}
} else {
pieceCountNeedRemove =
rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1;
action = Act.remove;
}
*/
// TODO: pieceCountNeedRemove
print("putPiece: pt = $piece, index = $index, sq = $s");
@ -696,6 +729,23 @@ class Position {
return false;
}
void removeBanStones() {
assert(rule.hasBannedLocations);
int s = 0;
for (int f = 1; f <= fileNumber; f++) {
for (int r = 0; r < rankNumber; r++) {
s = f * rankNumber + r;
if (board[s] == Piece.ban) {
board[s] = Piece.noPiece;
_grid[squareToIndex[s]] = Piece.noPiece;
}
}
}
}
void createMillTable() {
const millTable_noObliqueLine = [
/* 0 */ [