refactor: Rename nPiecesXXX to pieceXXXCount
This commit is contained in:
parent
9670c87c3a
commit
91a06e2ed0
|
@ -65,20 +65,20 @@ Value Evaluation<T>::value()
|
||||||
{
|
{
|
||||||
Value value = VALUE_ZERO;
|
Value value = VALUE_ZERO;
|
||||||
|
|
||||||
int nPiecesInHandDiff;
|
int pieceInHandDiffCount;
|
||||||
int nPiecesOnBoardDiff;
|
int pieceOnBoardDiffCount;
|
||||||
int nPiecesNeedRemove;
|
int pieceToRemoveCount;
|
||||||
|
|
||||||
switch (pos.get_phase()) {
|
switch (pos.get_phase()) {
|
||||||
case Phase::ready:
|
case Phase::ready:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Phase::placing:
|
case Phase::placing:
|
||||||
nPiecesInHandDiff = pos.n_pieces_in_hand(BLACK) - pos.n_pieces_in_hand(WHITE);
|
pieceInHandDiffCount = pos.piece_in_hand_count(BLACK) - pos.piece_in_hand_count(WHITE);
|
||||||
value += nPiecesInHandDiff * VALUE_EACH_PIECE_INHAND;
|
value += pieceInHandDiffCount * VALUE_EACH_PIECE_INHAND;
|
||||||
|
|
||||||
nPiecesOnBoardDiff = pos.n_pieces_on_board(BLACK) - pos.n_pieces_on_board(WHITE);
|
pieceOnBoardDiffCount = pos.piece_on_board_count(BLACK) - pos.piece_on_board_count(WHITE);
|
||||||
value += nPiecesOnBoardDiff * VALUE_EACH_PIECE_ONBOARD;
|
value += pieceOnBoardDiffCount * VALUE_EACH_PIECE_ONBOARD;
|
||||||
|
|
||||||
switch (pos.get_action()) {
|
switch (pos.get_action()) {
|
||||||
case Action::select:
|
case Action::select:
|
||||||
|
@ -86,9 +86,9 @@ Value Evaluation<T>::value()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Action::remove:
|
case Action::remove:
|
||||||
nPiecesNeedRemove = (pos.side_to_move() == BLACK) ?
|
pieceToRemoveCount = (pos.side_to_move() == BLACK) ?
|
||||||
pos.n_pieces_to_remove() : -(pos.n_pieces_to_remove());
|
pos.piece_to_remove_count() : -(pos.piece_to_remove_count());
|
||||||
value += nPiecesNeedRemove * VALUE_EACH_PIECE_PLACING_NEEDREMOVE;
|
value += pieceToRemoveCount * VALUE_EACH_PIECE_PLACING_NEEDREMOVE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -97,11 +97,11 @@ Value Evaluation<T>::value()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Phase::moving:
|
case Phase::moving:
|
||||||
value = pos.n_pieces_on_board(BLACK) * VALUE_EACH_PIECE_ONBOARD -
|
value = pos.piece_on_board_count(BLACK) * VALUE_EACH_PIECE_ONBOARD -
|
||||||
pos.n_pieces_on_board(WHITE) * VALUE_EACH_PIECE_ONBOARD;
|
pos.piece_on_board_count(WHITE) * VALUE_EACH_PIECE_ONBOARD;
|
||||||
|
|
||||||
#ifdef EVALUATE_MOBILITY
|
#ifdef EVALUATE_MOBILITY
|
||||||
value += pos.get_mobility_diff(position->turn, position->nPiecesInHand[BLACK], position->nPiecesInHand[WHITE], false) * 10;
|
value += pos.get_mobility_diff(position->turn, position->pieceInHandCount[BLACK], position->pieceInHandCount[WHITE], false) * 10;
|
||||||
#endif /* EVALUATE_MOBILITY */
|
#endif /* EVALUATE_MOBILITY */
|
||||||
|
|
||||||
switch (pos.get_action()) {
|
switch (pos.get_action()) {
|
||||||
|
@ -110,9 +110,9 @@ Value Evaluation<T>::value()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Action::remove:
|
case Action::remove:
|
||||||
nPiecesNeedRemove = (pos.side_to_move() == BLACK) ?
|
pieceToRemoveCount = (pos.side_to_move() == BLACK) ?
|
||||||
pos.n_pieces_to_remove() : -(pos.n_pieces_to_remove());
|
pos.piece_to_remove_count() : -(pos.piece_to_remove_count());
|
||||||
value += nPiecesNeedRemove * VALUE_EACH_PIECE_MOVING_NEEDREMOVE;
|
value += pieceToRemoveCount * VALUE_EACH_PIECE_MOVING_NEEDREMOVE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -121,7 +121,7 @@ Value Evaluation<T>::value()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Phase::gameOver:
|
case Phase::gameOver:
|
||||||
if (pos.n_pieces_on_board(BLACK) + pos.n_pieces_on_board(WHITE) >= EFFECTIVE_SQUARE_NB) {
|
if (pos.piece_on_board_count(BLACK) + pos.piece_on_board_count(WHITE) >= EFFECTIVE_SQUARE_NB) {
|
||||||
if (rule.isBlackLoseButNotDrawWhenBoardFull) {
|
if (rule.isBlackLoseButNotDrawWhenBoardFull) {
|
||||||
value -= VALUE_MATE;
|
value -= VALUE_MATE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -134,9 +134,9 @@ Value Evaluation<T>::value()
|
||||||
value += delta;
|
value += delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (pos.n_pieces_on_board(BLACK) < rule.nPiecesAtLeast) {
|
else if (pos.piece_on_board_count(BLACK) < rule.piecesAtLeastCount) {
|
||||||
value -= VALUE_MATE;
|
value -= VALUE_MATE;
|
||||||
} else if (pos.n_pieces_on_board(WHITE) < rule.nPiecesAtLeast) {
|
} else if (pos.piece_on_board_count(WHITE) < rule.piecesAtLeastCount) {
|
||||||
value += VALUE_MATE;
|
value += VALUE_MATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ ExtMove *generate<MOVE>(Position &pos, ExtMove *moveList)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos.n_pieces_on_board(pos.side_to_move()) > rule.nPiecesAtLeast ||
|
if (pos.piece_on_board_count(pos.side_to_move()) > rule.piecesAtLeastCount ||
|
||||||
!rule.flyingAllowed) {
|
!rule.flyingAllowed) {
|
||||||
for (auto direction = MD_BEGIN; direction < MD_NB; ++direction) {
|
for (auto direction = MD_BEGIN; direction < MD_NB; ++direction) {
|
||||||
to = static_cast<Square>(MoveList<LEGAL>::adjacentSquares[from][direction]);
|
to = static_cast<Square>(MoveList<LEGAL>::adjacentSquares[from][direction]);
|
||||||
|
|
|
@ -273,9 +273,9 @@ Position &Position::set(const string &fenStr, Thread *th)
|
||||||
|
|
||||||
// 5. Black on board / Black in hand / White on board / White in hand / need to remove
|
// 5. Black on board / Black in hand / White on board / White in hand / need to remove
|
||||||
ss >> std::skipws
|
ss >> std::skipws
|
||||||
>> nPiecesOnBoard[BLACK] >> nPiecesInHand[BLACK]
|
>> pieceOnBoardCount[BLACK] >> pieceInHandCount[BLACK]
|
||||||
>> nPiecesOnBoard[WHITE] >> nPiecesInHand[WHITE]
|
>> pieceOnBoardCount[WHITE] >> pieceInHandCount[WHITE]
|
||||||
>> nPiecesNeedRemove;
|
>> pieceToRemoveCount;
|
||||||
|
|
||||||
|
|
||||||
// 6-7. Halfmove clock and fullmove number
|
// 6-7. Halfmove clock and fullmove number
|
||||||
|
@ -360,9 +360,9 @@ const string Position::fen() const
|
||||||
|
|
||||||
ss << " ";
|
ss << " ";
|
||||||
|
|
||||||
ss << nPiecesOnBoard[BLACK] << " " << nPiecesInHand[BLACK] << " "
|
ss << pieceOnBoardCount[BLACK] << " " << pieceInHandCount[BLACK] << " "
|
||||||
<< nPiecesOnBoard[WHITE] << " " << nPiecesInHand[WHITE] << " "
|
<< pieceOnBoardCount[WHITE] << " " << pieceInHandCount[WHITE] << " "
|
||||||
<< nPiecesNeedRemove << " ";
|
<< pieceToRemoveCount << " ";
|
||||||
|
|
||||||
ss << st.rule50 << " " << 1 + (gamePly - (sideToMove == BLACK)) / 2;
|
ss << st.rule50 << " " << 1 + (gamePly - (sideToMove == BLACK)) / 2;
|
||||||
|
|
||||||
|
@ -535,9 +535,9 @@ void Position::undo_move(Move m)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Adjust
|
// TODO: Adjust
|
||||||
//int nPiecesInHand[COLOR_NB]{ 0 };
|
//int pieceInHandCount[COLOR_NB]{ 0 };
|
||||||
//int nPiecesOnBoard[COLOR_NB]{ 0 };
|
//int pieceOnBoardCount[COLOR_NB]{ 0 };
|
||||||
//int nPiecesNeedRemove{ 0 };
|
//int pieceToRemoveCount{ 0 };
|
||||||
|
|
||||||
// TODO End
|
// TODO End
|
||||||
|
|
||||||
|
@ -666,17 +666,17 @@ bool Position::pos_is_ok() const
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int Position::n_pieces_on_board_count()
|
int Position::piece_on_board_count_count()
|
||||||
{
|
{
|
||||||
nPiecesOnBoard[BLACK] = nPiecesOnBoard[WHITE] = 0;
|
pieceOnBoardCount[BLACK] = pieceOnBoardCount[WHITE] = 0;
|
||||||
|
|
||||||
for (int f = 1; f < FILE_NB + 2; f++) {
|
for (int f = 1; f < FILE_NB + 2; f++) {
|
||||||
for (int r = 0; r < RANK_NB; r++) {
|
for (int r = 0; r < RANK_NB; r++) {
|
||||||
Square s = static_cast<Square>(f * RANK_NB + r);
|
Square s = static_cast<Square>(f * RANK_NB + r);
|
||||||
if (board[s] & B_STONE) {
|
if (board[s] & B_STONE) {
|
||||||
nPiecesOnBoard[BLACK]++;
|
pieceOnBoardCount[BLACK]++;
|
||||||
} else if (board[s] & W_STONE) {
|
} else if (board[s] & W_STONE) {
|
||||||
nPiecesOnBoard[WHITE]++;
|
pieceOnBoardCount[WHITE]++;
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
else if (board[s] & BAN_STONE) {
|
else if (board[s] & BAN_STONE) {
|
||||||
|
@ -685,20 +685,20 @@ int Position::n_pieces_on_board_count()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nPiecesOnBoard[BLACK] > rule.nTotalPiecesEachSide ||
|
if (pieceOnBoardCount[BLACK] > rule.nTotalPiecesEachSide ||
|
||||||
nPiecesOnBoard[WHITE] > rule.nTotalPiecesEachSide) {
|
pieceOnBoardCount[WHITE] > rule.nTotalPiecesEachSide) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nPiecesOnBoard[BLACK] + nPiecesOnBoard[WHITE];
|
return pieceOnBoardCount[BLACK] + pieceOnBoardCount[WHITE];
|
||||||
}
|
}
|
||||||
|
|
||||||
int Position::get_n_pieces_in_hand()
|
int Position::get_piece_in_hand_count()
|
||||||
{
|
{
|
||||||
nPiecesInHand[BLACK] = rule.nTotalPiecesEachSide - nPiecesOnBoard[BLACK];
|
pieceInHandCount[BLACK] = rule.nTotalPiecesEachSide - pieceOnBoardCount[BLACK];
|
||||||
nPiecesInHand[WHITE] = rule.nTotalPiecesEachSide - nPiecesOnBoard[WHITE];
|
pieceInHandCount[WHITE] = rule.nTotalPiecesEachSide - pieceOnBoardCount[WHITE];
|
||||||
|
|
||||||
return nPiecesInHand[BLACK] + nPiecesInHand[WHITE];
|
return pieceInHandCount[BLACK] + pieceInHandCount[WHITE];
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef THREEFOLD_REPETITION
|
#ifdef THREEFOLD_REPETITION
|
||||||
|
@ -726,9 +726,9 @@ bool Position::reset()
|
||||||
memset(byTypeBB, 0, sizeof(byTypeBB));
|
memset(byTypeBB, 0, sizeof(byTypeBB));
|
||||||
memset(byColorBB, 0, sizeof(byColorBB));
|
memset(byColorBB, 0, sizeof(byColorBB));
|
||||||
|
|
||||||
nPiecesOnBoard[BLACK] = nPiecesOnBoard[WHITE] = 0;
|
pieceOnBoardCount[BLACK] = pieceOnBoardCount[WHITE] = 0;
|
||||||
nPiecesInHand[BLACK] = nPiecesInHand[WHITE] = rule.nTotalPiecesEachSide;
|
pieceInHandCount[BLACK] = pieceInHandCount[WHITE] = rule.nTotalPiecesEachSide;
|
||||||
nPiecesNeedRemove = 0;
|
pieceToRemoveCount = 0;
|
||||||
millListSize = 0;
|
millListSize = 0;
|
||||||
|
|
||||||
MoveList<LEGAL>::create();
|
MoveList<LEGAL>::create();
|
||||||
|
@ -792,9 +792,9 @@ bool Position::put_piece(Square s, bool updateCmdlist)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (phase == Phase::placing) {
|
if (phase == Phase::placing) {
|
||||||
piece = (Piece)((0x01 | make_piece(sideToMove)) + rule.nTotalPiecesEachSide - nPiecesInHand[us]);
|
piece = (Piece)((0x01 | make_piece(sideToMove)) + rule.nTotalPiecesEachSide - pieceInHandCount[us]);
|
||||||
nPiecesInHand[us]--;
|
pieceInHandCount[us]--;
|
||||||
nPiecesOnBoard[us]++;
|
pieceOnBoardCount[us]++;
|
||||||
|
|
||||||
Piece pc = board[s] = piece;
|
Piece pc = board[s] = piece;
|
||||||
byTypeBB[ALL_PIECES] |= byTypeBB[type_of(pc)] |= s;
|
byTypeBB[ALL_PIECES] |= byTypeBB[type_of(pc)] |= s;
|
||||||
|
@ -811,9 +811,9 @@ bool Position::put_piece(Square s, bool updateCmdlist)
|
||||||
int n = add_mills(currentSquare);
|
int n = add_mills(currentSquare);
|
||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
assert(nPiecesInHand[BLACK] >= 0 && nPiecesInHand[WHITE] >= 0);
|
assert(pieceInHandCount[BLACK] >= 0 && pieceInHandCount[WHITE] >= 0);
|
||||||
|
|
||||||
if (nPiecesInHand[BLACK] == 0 && nPiecesInHand[WHITE] == 0) {
|
if (pieceInHandCount[BLACK] == 0 && pieceInHandCount[WHITE] == 0) {
|
||||||
if (check_if_game_is_over()) {
|
if (check_if_game_is_over()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -836,7 +836,7 @@ bool Position::put_piece(Square s, bool updateCmdlist)
|
||||||
change_side_to_move();
|
change_side_to_move();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nPiecesNeedRemove = rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1;
|
pieceToRemoveCount = rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1;
|
||||||
update_key_misc();
|
update_key_misc();
|
||||||
action = Action::remove;
|
action = Action::remove;
|
||||||
}
|
}
|
||||||
|
@ -848,7 +848,7 @@ bool Position::put_piece(Square s, bool updateCmdlist)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if illegal
|
// if illegal
|
||||||
if (nPiecesOnBoard[sideToMove] > rule.nPiecesAtLeast ||
|
if (pieceOnBoardCount[sideToMove] > rule.piecesAtLeastCount ||
|
||||||
!rule.flyingAllowed) {
|
!rule.flyingAllowed) {
|
||||||
if ((square_bb(s) & MoveList<LEGAL>::adjacentSquaresBB[currentSquare]) == 0) {
|
if ((square_bb(s) & MoveList<LEGAL>::adjacentSquaresBB[currentSquare]) == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -890,7 +890,7 @@ bool Position::put_piece(Square s, bool updateCmdlist)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nPiecesNeedRemove = rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1;
|
pieceToRemoveCount = rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1;
|
||||||
update_key_misc();
|
update_key_misc();
|
||||||
action = Action::remove;
|
action = Action::remove;
|
||||||
}
|
}
|
||||||
|
@ -909,7 +909,7 @@ bool Position::remove_piece(Square s, bool updateCmdlist)
|
||||||
if (action != Action::remove)
|
if (action != Action::remove)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (nPiecesNeedRemove <= 0)
|
if (pieceToRemoveCount <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// if piece is not their
|
// if piece is not their
|
||||||
|
@ -951,24 +951,24 @@ bool Position::remove_piece(Square s, bool updateCmdlist)
|
||||||
st.rule50 = 0; // TODO: Need to move out?
|
st.rule50 = 0; // TODO: Need to move out?
|
||||||
}
|
}
|
||||||
|
|
||||||
nPiecesOnBoard[them]--;
|
pieceOnBoardCount[them]--;
|
||||||
|
|
||||||
if (nPiecesOnBoard[them] + nPiecesInHand[them] < rule.nPiecesAtLeast) {
|
if (pieceOnBoardCount[them] + pieceInHandCount[them] < rule.piecesAtLeastCount) {
|
||||||
set_gameover(sideToMove, GameOverReason::loseReasonlessThanThree);
|
set_gameover(sideToMove, GameOverReason::loseReasonlessThanThree);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentSquare = SQ_0;
|
currentSquare = SQ_0;
|
||||||
|
|
||||||
nPiecesNeedRemove--;
|
pieceToRemoveCount--;
|
||||||
update_key_misc();
|
update_key_misc();
|
||||||
|
|
||||||
if (nPiecesNeedRemove > 0) {
|
if (pieceToRemoveCount > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (phase == Phase::placing) {
|
if (phase == Phase::placing) {
|
||||||
if (nPiecesInHand[BLACK] == 0 && nPiecesInHand[WHITE] == 0) {
|
if (pieceInHandCount[BLACK] == 0 && pieceInHandCount[WHITE] == 0) {
|
||||||
phase = Phase::moving;
|
phase = Phase::moving;
|
||||||
action = Action::select;
|
action = Action::select;
|
||||||
|
|
||||||
|
@ -1123,7 +1123,7 @@ bool Position::check_if_game_is_over()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nPiecesOnBoard[BLACK] + nPiecesOnBoard[WHITE] >= EFFECTIVE_SQUARE_NB) {
|
if (pieceOnBoardCount[BLACK] + pieceOnBoardCount[WHITE] >= EFFECTIVE_SQUARE_NB) {
|
||||||
if (rule.isBlackLoseButNotDrawWhenBoardFull) {
|
if (rule.isBlackLoseButNotDrawWhenBoardFull) {
|
||||||
set_gameover(WHITE, GameOverReason::loseReasonBoardIsFull);
|
set_gameover(WHITE, GameOverReason::loseReasonBoardIsFull);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1227,7 +1227,7 @@ Key Position::update_key_misc()
|
||||||
{
|
{
|
||||||
st.key = st.key << Zobrist::KEY_MISC_BIT >> Zobrist::KEY_MISC_BIT;
|
st.key = st.key << Zobrist::KEY_MISC_BIT >> Zobrist::KEY_MISC_BIT;
|
||||||
|
|
||||||
st.key |= static_cast<Key>(nPiecesNeedRemove) << (CHAR_BIT * sizeof(Key) - Zobrist::KEY_MISC_BIT);
|
st.key |= static_cast<Key>(pieceToRemoveCount) << (CHAR_BIT * sizeof(Key) - Zobrist::KEY_MISC_BIT);
|
||||||
|
|
||||||
return st.key;
|
return st.key;
|
||||||
}
|
}
|
||||||
|
@ -1486,7 +1486,7 @@ int Position::surrounded_empty_squares_count(Square s, bool includeFobidden)
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
if (nPiecesOnBoard[sideToMove] > rule.nPiecesAtLeast ||
|
if (pieceOnBoardCount[sideToMove] > rule.piecesAtLeastCount ||
|
||||||
!rule.flyingAllowed) {
|
!rule.flyingAllowed) {
|
||||||
Square moveSquare;
|
Square moveSquare;
|
||||||
for (MoveDirection d = MD_BEGIN; d < MD_NB; ++d) {
|
for (MoveDirection d = MD_BEGIN; d < MD_NB; ++d) {
|
||||||
|
@ -1537,11 +1537,11 @@ void Position::surrounded_pieces_count(Square s, int &nOurPieces, int &nTheirPie
|
||||||
bool Position::is_all_surrounded() const
|
bool Position::is_all_surrounded() const
|
||||||
{
|
{
|
||||||
// Full
|
// Full
|
||||||
if (nPiecesOnBoard[BLACK] + nPiecesOnBoard[WHITE] >= EFFECTIVE_SQUARE_NB)
|
if (pieceOnBoardCount[BLACK] + pieceOnBoardCount[WHITE] >= EFFECTIVE_SQUARE_NB)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Can fly
|
// Can fly
|
||||||
if (nPiecesOnBoard[sideToMove] <= rule.nPiecesAtLeast &&
|
if (pieceOnBoardCount[sideToMove] <= rule.piecesAtLeastCount &&
|
||||||
rule.flyingAllowed) {
|
rule.flyingAllowed) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,13 +142,13 @@ public:
|
||||||
|
|
||||||
static void print_board();
|
static void print_board();
|
||||||
|
|
||||||
int n_pieces_on_board_count();
|
int piece_on_board_count_count();
|
||||||
int get_n_pieces_in_hand();
|
int get_piece_in_hand_count();
|
||||||
|
|
||||||
int n_pieces_on_board(Color c);
|
int piece_on_board_count(Color c);
|
||||||
int n_pieces_in_hand(Color c);
|
int piece_in_hand_count(Color c);
|
||||||
|
|
||||||
int n_pieces_to_remove();
|
int piece_to_remove_count();
|
||||||
|
|
||||||
static bool is_star_square(Square s);
|
static bool is_star_square(Square s);
|
||||||
|
|
||||||
|
@ -178,9 +178,9 @@ public:
|
||||||
Bitboard byTypeBB[PIECE_TYPE_NB];
|
Bitboard byTypeBB[PIECE_TYPE_NB];
|
||||||
Bitboard byColorBB[COLOR_NB];
|
Bitboard byColorBB[COLOR_NB];
|
||||||
// TODO: [0] is sum of Black and White
|
// TODO: [0] is sum of Black and White
|
||||||
int nPiecesInHand[COLOR_NB]{ 0, 12, 12 }; // TODO
|
int pieceInHandCount[COLOR_NB]{ 0, 12, 12 }; // TODO
|
||||||
int nPiecesOnBoard[COLOR_NB]{ 0, 0, 0 };
|
int pieceOnBoardCount[COLOR_NB]{ 0, 0, 0 };
|
||||||
int nPiecesNeedRemove{ 0 };
|
int pieceToRemoveCount{ 0 };
|
||||||
int gamePly { 0 };
|
int gamePly { 0 };
|
||||||
Color sideToMove { NOCOLOR };
|
Color sideToMove { NOCOLOR };
|
||||||
Thread *thisThread;
|
Thread *thisThread;
|
||||||
|
@ -261,9 +261,9 @@ inline Piece Position::moved_piece(Move m) const
|
||||||
template<PieceType Pt> inline int Position::count(Color c) const
|
template<PieceType Pt> inline int Position::count(Color c) const
|
||||||
{
|
{
|
||||||
if (Pt == ON_BOARD) {
|
if (Pt == ON_BOARD) {
|
||||||
return nPiecesOnBoard[c];
|
return pieceOnBoardCount[c];
|
||||||
} else if (Pt == IN_HAND) {
|
} else if (Pt == IN_HAND) {
|
||||||
return nPiecesInHand[c];
|
return pieceInHandCount[c];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -380,19 +380,19 @@ inline const char *Position::cmd_line() const
|
||||||
return cmdline;
|
return cmdline;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int Position::n_pieces_on_board(Color c)
|
inline int Position::piece_on_board_count(Color c)
|
||||||
{
|
{
|
||||||
return nPiecesOnBoard[c];
|
return pieceOnBoardCount[c];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int Position::n_pieces_in_hand(Color c)
|
inline int Position::piece_in_hand_count(Color c)
|
||||||
{
|
{
|
||||||
return nPiecesInHand[c];
|
return pieceInHandCount[c];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int Position::n_pieces_to_remove()
|
inline int Position::piece_to_remove_count()
|
||||||
{
|
{
|
||||||
return nPiecesNeedRemove;
|
return pieceToRemoveCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #ifndef POSITION_H_INCLUDED
|
#endif // #ifndef POSITION_H_INCLUDED
|
||||||
|
|
|
@ -29,7 +29,7 @@ struct Rule
|
||||||
|
|
||||||
int nTotalPiecesEachSide; // 9 or 12
|
int nTotalPiecesEachSide; // 9 or 12
|
||||||
|
|
||||||
int nPiecesAtLeast; // Default is 3
|
int piecesAtLeastCount; // Default is 3
|
||||||
|
|
||||||
bool hasObliqueLines;
|
bool hasObliqueLines;
|
||||||
|
|
||||||
|
|
|
@ -294,7 +294,7 @@ Value search(Position *pos, Sanmill::Stack<Position> &ss, Depth depth, Depth ori
|
||||||
#endif /* TRANSPOSITION_TABLE_ENABLE */
|
#endif /* TRANSPOSITION_TABLE_ENABLE */
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (position->phase == Phase::placing && depth == 1 && pos->nPiecesNeedRemove > 0) {
|
if (position->phase == Phase::placing && depth == 1 && pos->pieceToRemoveCount > 0) {
|
||||||
depth--;
|
depth--;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -469,13 +469,13 @@ Depth Thread::adjustDepth()
|
||||||
|
|
||||||
// Can fly
|
// Can fly
|
||||||
if (rule.flyingAllowed) {
|
if (rule.flyingAllowed) {
|
||||||
if (pb == rule.nPiecesAtLeast ||
|
if (pb == rule.piecesAtLeastCount ||
|
||||||
pw == rule.nPiecesAtLeast) {
|
pw == rule.piecesAtLeastCount) {
|
||||||
d = flyingDepth;
|
d = flyingDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pb == rule.nPiecesAtLeast &&
|
if (pb == rule.piecesAtLeastCount &&
|
||||||
pw == rule.nPiecesAtLeast) {
|
pw == rule.piecesAtLeastCount) {
|
||||||
d = flyingDepth / 2;
|
d = flyingDepth / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,9 +72,9 @@ void on_nTotalPiecesEachSide(const Option &o)
|
||||||
rule.nTotalPiecesEachSide = (int)o;
|
rule.nTotalPiecesEachSide = (int)o;
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_nPiecesAtLeast(const Option &o)
|
void on_piecesAtLeastCount(const Option &o)
|
||||||
{
|
{
|
||||||
rule.nPiecesAtLeast = (int)o;
|
rule.piecesAtLeastCount = (int)o;
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_hasObliqueLines(const Option &o)
|
void on_hasObliqueLines(const Option &o)
|
||||||
|
@ -157,7 +157,7 @@ void init(OptionsMap &o)
|
||||||
|
|
||||||
// Rules
|
// Rules
|
||||||
o["nTotalPiecesEachSide"] << Option(12, 6, 12, on_nTotalPiecesEachSide);
|
o["nTotalPiecesEachSide"] << Option(12, 6, 12, on_nTotalPiecesEachSide);
|
||||||
o["nPiecesAtLeast"] << Option(3, 3, 5, on_nPiecesAtLeast);
|
o["piecesAtLeastCount"] << Option(3, 3, 5, on_piecesAtLeastCount);
|
||||||
o["hasObliqueLines"] << Option(true, on_hasObliqueLines);
|
o["hasObliqueLines"] << Option(true, on_hasObliqueLines);
|
||||||
o["hasBannedLocations"] << Option(true, on_hasBannedLocations);
|
o["hasBannedLocations"] << Option(true, on_hasBannedLocations);
|
||||||
o["isDefenderMoveFirst"] << Option(true, on_isDefenderMoveFirst);
|
o["isDefenderMoveFirst"] << Option(true, on_isDefenderMoveFirst);
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Config {
|
||||||
|
|
||||||
// Rules
|
// Rules
|
||||||
static int nTotalPiecesEachSide = 12;
|
static int nTotalPiecesEachSide = 12;
|
||||||
static int nPiecesAtLeast = 3;
|
static int piecesAtLeastCount = 3;
|
||||||
static bool hasObliqueLines = true;
|
static bool hasObliqueLines = true;
|
||||||
static bool hasBannedLocations = true;
|
static bool hasBannedLocations = true;
|
||||||
static bool isDefenderMoveFirst = true;
|
static bool isDefenderMoveFirst = true;
|
||||||
|
@ -69,8 +69,8 @@ class Config {
|
||||||
// Rules
|
// Rules
|
||||||
rule.nTotalPiecesEachSide =
|
rule.nTotalPiecesEachSide =
|
||||||
Config.nTotalPiecesEachSide = profile['nTotalPiecesEachSide'] ?? 12;
|
Config.nTotalPiecesEachSide = profile['nTotalPiecesEachSide'] ?? 12;
|
||||||
rule.nPiecesAtLeast =
|
rule.piecesAtLeastCount =
|
||||||
Config.nPiecesAtLeast = profile['nPiecesAtLeast'] ?? 3;
|
Config.piecesAtLeastCount = profile['piecesAtLeastCount'] ?? 3;
|
||||||
rule.hasObliqueLines =
|
rule.hasObliqueLines =
|
||||||
Config.hasObliqueLines = profile['hasObliqueLines'] ?? true;
|
Config.hasObliqueLines = profile['hasObliqueLines'] ?? true;
|
||||||
rule.hasBannedLocations =
|
rule.hasBannedLocations =
|
||||||
|
@ -115,7 +115,7 @@ class Config {
|
||||||
|
|
||||||
// Rules
|
// Rules
|
||||||
profile['nTotalPiecesEachSide'] = Config.nTotalPiecesEachSide;
|
profile['nTotalPiecesEachSide'] = Config.nTotalPiecesEachSide;
|
||||||
profile['nPiecesAtLeast'] = Config.nPiecesAtLeast;
|
profile['piecesAtLeastCount'] = Config.piecesAtLeastCount;
|
||||||
profile['hasObliqueLines'] = Config.hasObliqueLines;
|
profile['hasObliqueLines'] = Config.hasObliqueLines;
|
||||||
profile['hasBannedLocations'] = Config.hasBannedLocations;
|
profile['hasBannedLocations'] = Config.hasBannedLocations;
|
||||||
profile['isDefenderMoveFirst'] = Config.isDefenderMoveFirst;
|
profile['isDefenderMoveFirst'] = Config.isDefenderMoveFirst;
|
||||||
|
|
|
@ -136,7 +136,8 @@ class NativeEngine extends AiEngine {
|
||||||
await send('setoption name Shuffling value ${Config.shufflingEnabled}');
|
await send('setoption name Shuffling value ${Config.shufflingEnabled}');
|
||||||
await send(
|
await send(
|
||||||
'setoption name nTotalPiecesEachSide value ${Config.nTotalPiecesEachSide}');
|
'setoption name nTotalPiecesEachSide value ${Config.nTotalPiecesEachSide}');
|
||||||
await send('setoption name nPiecesAtLeast value ${Config.nPiecesAtLeast}');
|
await send(
|
||||||
|
'setoption name piecesAtLeastCount value ${Config.piecesAtLeastCount}');
|
||||||
await send(
|
await send(
|
||||||
'setoption name hasObliqueLines value ${Config.hasObliqueLines}');
|
'setoption name hasObliqueLines value ${Config.hasObliqueLines}');
|
||||||
await send(
|
await send(
|
||||||
|
|
|
@ -323,8 +323,8 @@
|
||||||
"@twelvePieces": {
|
"@twelvePieces": {
|
||||||
"description": "Twelve Pieces"
|
"description": "Twelve Pieces"
|
||||||
},
|
},
|
||||||
"nPiecesAtLeast": "Pieces At Least",
|
"piecesAtLeastCount": "Pieces At Least",
|
||||||
"@nPiecesAtLeast": {
|
"@piecesAtLeastCount": {
|
||||||
"description": "Pieces At Least"
|
"description": "Pieces At Least"
|
||||||
},
|
},
|
||||||
"hasObliqueLines": "Has Oblique Lines",
|
"hasObliqueLines": "Has Oblique Lines",
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
"nTotalPiecesEachSide": "棋子数",
|
"nTotalPiecesEachSide": "棋子数",
|
||||||
"ninePieces": "九子",
|
"ninePieces": "九子",
|
||||||
"twelvePieces": "十二子",
|
"twelvePieces": "十二子",
|
||||||
"nPiecesAtLeast": "少于几个子则输棋",
|
"piecesAtLeastCount": "少于几个子则输棋",
|
||||||
"hasObliqueLines": "斜线",
|
"hasObliqueLines": "斜线",
|
||||||
"hasBannedLocations": "禁点",
|
"hasBannedLocations": "禁点",
|
||||||
"isDefenderMoveFirst": "后摆子的先走子",
|
"isDefenderMoveFirst": "后摆子的先走子",
|
||||||
|
|
|
@ -46,9 +46,9 @@ class Position {
|
||||||
|
|
||||||
GameRecorder recorder;
|
GameRecorder recorder;
|
||||||
|
|
||||||
Map<String, int> nPiecesInHand = {Color.black: -1, Color.white: -1};
|
Map<String, int> pieceInHandCount = {Color.black: -1, Color.white: -1};
|
||||||
Map<String, int> nPiecesOnBoard = {Color.black: 0, Color.white: 0};
|
Map<String, int> pieceOnBoardCount = {Color.black: 0, Color.white: 0};
|
||||||
int nPiecesNeedRemove = 0;
|
int pieceToRemoveCount = 0;
|
||||||
|
|
||||||
int gamePly = 0;
|
int gamePly = 0;
|
||||||
String _sideToMove = Color.black;
|
String _sideToMove = Color.black;
|
||||||
|
@ -102,9 +102,9 @@ class Position {
|
||||||
|
|
||||||
recorder = other.recorder;
|
recorder = other.recorder;
|
||||||
|
|
||||||
nPiecesInHand = other.nPiecesInHand;
|
pieceInHandCount = other.pieceInHandCount;
|
||||||
nPiecesOnBoard = other.nPiecesOnBoard;
|
pieceOnBoardCount = other.pieceOnBoardCount;
|
||||||
nPiecesNeedRemove = other.nPiecesNeedRemove;
|
pieceToRemoveCount = other.pieceToRemoveCount;
|
||||||
|
|
||||||
gamePly = other.gamePly;
|
gamePly = other.gamePly;
|
||||||
|
|
||||||
|
@ -242,15 +242,15 @@ class Position {
|
||||||
|
|
||||||
ss += " ";
|
ss += " ";
|
||||||
|
|
||||||
ss += nPiecesOnBoard[Color.black].toString() +
|
ss += pieceOnBoardCount[Color.black].toString() +
|
||||||
" " +
|
" " +
|
||||||
nPiecesInHand[Color.black].toString() +
|
pieceInHandCount[Color.black].toString() +
|
||||||
" " +
|
" " +
|
||||||
nPiecesOnBoard[Color.white].toString() +
|
pieceOnBoardCount[Color.white].toString() +
|
||||||
" " +
|
" " +
|
||||||
nPiecesInHand[Color.white].toString() +
|
pieceInHandCount[Color.white].toString() +
|
||||||
" " +
|
" " +
|
||||||
nPiecesNeedRemove.toString() +
|
pieceToRemoveCount.toString() +
|
||||||
" ";
|
" ";
|
||||||
|
|
||||||
int sideIsBlack = _sideToMove == Color.black ? 1 : 0;
|
int sideIsBlack = _sideToMove == Color.black ? 1 : 0;
|
||||||
|
@ -370,35 +370,35 @@ class Position {
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int nPiecesOnBoardCount() {
|
int pieceOnBoardCountCount() {
|
||||||
nPiecesOnBoard[Color.black] = nPiecesOnBoard[Color.white] = 0;
|
pieceOnBoardCount[Color.black] = pieceOnBoardCount[Color.white] = 0;
|
||||||
|
|
||||||
for (int f = 1; f < fileExNumber; f++) {
|
for (int f = 1; f < fileExNumber; f++) {
|
||||||
for (int r = 0; r < rankNumber; r++) {
|
for (int r = 0; r < rankNumber; r++) {
|
||||||
int s = f * rankNumber + r;
|
int s = f * rankNumber + r;
|
||||||
if (board[s] == Piece.blackStone) {
|
if (board[s] == Piece.blackStone) {
|
||||||
nPiecesOnBoard[Color.black]++;
|
pieceOnBoardCount[Color.black]++;
|
||||||
} else if (board[s] == Piece.whiteStone) {
|
} else if (board[s] == Piece.whiteStone) {
|
||||||
nPiecesOnBoard[Color.black]++;
|
pieceOnBoardCount[Color.black]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nPiecesOnBoard[Color.black] > rule.nTotalPiecesEachSide ||
|
if (pieceOnBoardCount[Color.black] > rule.nTotalPiecesEachSide ||
|
||||||
nPiecesOnBoard[Color.white] > rule.nTotalPiecesEachSide) {
|
pieceOnBoardCount[Color.white] > rule.nTotalPiecesEachSide) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nPiecesOnBoard[Color.black] + nPiecesOnBoard[Color.white];
|
return pieceOnBoardCount[Color.black] + pieceOnBoardCount[Color.white];
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetNPiecesInHand() {
|
int GetNPiecesInHand() {
|
||||||
nPiecesInHand[Color.black] =
|
pieceInHandCount[Color.black] =
|
||||||
rule.nTotalPiecesEachSide - nPiecesOnBoard[Color.black];
|
rule.nTotalPiecesEachSide - pieceOnBoardCount[Color.black];
|
||||||
nPiecesInHand[Color.white] =
|
pieceInHandCount[Color.white] =
|
||||||
rule.nTotalPiecesEachSide - nPiecesOnBoard[Color.white];
|
rule.nTotalPiecesEachSide - pieceOnBoardCount[Color.white];
|
||||||
|
|
||||||
return nPiecesOnBoard[Color.black] + nPiecesOnBoard[Color.white];
|
return pieceOnBoardCount[Color.black] + pieceOnBoardCount[Color.white];
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearBoard() {
|
void clearBoard() {
|
||||||
|
@ -428,12 +428,12 @@ class Position {
|
||||||
|
|
||||||
clearBoard();
|
clearBoard();
|
||||||
|
|
||||||
if (nPiecesOnBoardCount() == -1) {
|
if (pieceOnBoardCountCount() == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetNPiecesInHand();
|
GetNPiecesInHand();
|
||||||
nPiecesNeedRemove = 0;
|
pieceToRemoveCount = 0;
|
||||||
|
|
||||||
winner = Color.nobody;
|
winner = Color.nobody;
|
||||||
createMoveTable();
|
createMoveTable();
|
||||||
|
@ -456,10 +456,10 @@ class Position {
|
||||||
|
|
||||||
clearBoard();
|
clearBoard();
|
||||||
|
|
||||||
nPiecesOnBoard[Color.black] = nPiecesOnBoard[Color.white] = 0;
|
pieceOnBoardCount[Color.black] = pieceOnBoardCount[Color.white] = 0;
|
||||||
nPiecesInHand[Color.black] =
|
pieceInHandCount[Color.black] =
|
||||||
nPiecesInHand[Color.white] = rule.nTotalPiecesEachSide;
|
pieceInHandCount[Color.white] = rule.nTotalPiecesEachSide;
|
||||||
nPiecesNeedRemove = 0;
|
pieceToRemoveCount = 0;
|
||||||
|
|
||||||
currentSquare = 0;
|
currentSquare = 0;
|
||||||
int i = 0; // TODO: rule
|
int i = 0; // TODO: rule
|
||||||
|
@ -513,8 +513,8 @@ class Position {
|
||||||
|
|
||||||
if (phase == Phase.placing) {
|
if (phase == Phase.placing) {
|
||||||
piece = sideToMove();
|
piece = sideToMove();
|
||||||
nPiecesInHand[us]--;
|
pieceInHandCount[us]--;
|
||||||
nPiecesOnBoard[us]++;
|
pieceOnBoardCount[us]++;
|
||||||
|
|
||||||
_grid[index] = piece;
|
_grid[index] = piece;
|
||||||
board[s] = piece;
|
board[s] = piece;
|
||||||
|
@ -526,11 +526,11 @@ class Position {
|
||||||
int n = addMills(currentSquare);
|
int n = addMills(currentSquare);
|
||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
assert(
|
assert(pieceInHandCount[Color.black] >= 0 &&
|
||||||
nPiecesInHand[Color.black] >= 0 && nPiecesInHand[Color.white] >= 0);
|
pieceInHandCount[Color.white] >= 0);
|
||||||
|
|
||||||
if (nPiecesInHand[Color.black] == 0 &&
|
if (pieceInHandCount[Color.black] == 0 &&
|
||||||
nPiecesInHand[Color.white] == 0) {
|
pieceInHandCount[Color.white] == 0) {
|
||||||
if (checkIfGameIsOver()) {
|
if (checkIfGameIsOver()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -553,7 +553,7 @@ class Position {
|
||||||
changeSideToMove();
|
changeSideToMove();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nPiecesNeedRemove =
|
pieceToRemoveCount =
|
||||||
rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1;
|
rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1;
|
||||||
action = Act.remove;
|
action = Act.remove;
|
||||||
}
|
}
|
||||||
|
@ -563,7 +563,7 @@ class Position {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if illegal
|
// if illegal
|
||||||
if (nPiecesOnBoard[sideToMove()] > rule.nPiecesAtLeast ||
|
if (pieceOnBoardCount[sideToMove()] > rule.piecesAtLeastCount ||
|
||||||
!rule.flyingAllowed) {
|
!rule.flyingAllowed) {
|
||||||
int md;
|
int md;
|
||||||
|
|
||||||
|
@ -606,7 +606,7 @@ class Position {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nPiecesNeedRemove =
|
pieceToRemoveCount =
|
||||||
rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1;
|
rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1;
|
||||||
action = Act.remove;
|
action = Act.remove;
|
||||||
}
|
}
|
||||||
|
@ -622,7 +622,7 @@ class Position {
|
||||||
|
|
||||||
if (action != Act.remove) return false;
|
if (action != Act.remove) return false;
|
||||||
|
|
||||||
if (nPiecesNeedRemove <= 0) return false;
|
if (pieceToRemoveCount <= 0) return false;
|
||||||
|
|
||||||
// if piece is not their
|
// if piece is not their
|
||||||
if (!(Color.opponent(sideToMove()) == board[s])) return false;
|
if (!(Color.opponent(sideToMove()) == board[s])) return false;
|
||||||
|
@ -643,23 +643,25 @@ class Position {
|
||||||
cmdline = "-(" + fileOf(s).toString() + "," + rankOf(s).toString() + ")";
|
cmdline = "-(" + fileOf(s).toString() + "," + rankOf(s).toString() + ")";
|
||||||
rule50 = 0; // TODO: Need to move out?
|
rule50 = 0; // TODO: Need to move out?
|
||||||
|
|
||||||
nPiecesOnBoard[them]--;
|
pieceOnBoardCount[them]--;
|
||||||
|
|
||||||
if (nPiecesOnBoard[them] + nPiecesInHand[them] < rule.nPiecesAtLeast) {
|
if (pieceOnBoardCount[them] + pieceInHandCount[them] <
|
||||||
|
rule.piecesAtLeastCount) {
|
||||||
setGameOver(sideToMove(), GameOverReason.loseReasonlessThanThree);
|
setGameOver(sideToMove(), GameOverReason.loseReasonlessThanThree);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentSquare = 0;
|
currentSquare = 0;
|
||||||
|
|
||||||
nPiecesNeedRemove--;
|
pieceToRemoveCount--;
|
||||||
|
|
||||||
if (nPiecesNeedRemove > 0) {
|
if (pieceToRemoveCount > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (phase == Phase.placing) {
|
if (phase == Phase.placing) {
|
||||||
if (nPiecesInHand[Color.black] == 0 && nPiecesInHand[Color.white] == 0) {
|
if (pieceInHandCount[Color.black] == 0 &&
|
||||||
|
pieceInHandCount[Color.white] == 0) {
|
||||||
phase = Phase.moving;
|
phase = Phase.moving;
|
||||||
action = Act.select;
|
action = Act.select;
|
||||||
|
|
||||||
|
@ -749,7 +751,7 @@ class Position {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nPiecesOnBoard[Color.black] + nPiecesOnBoard[Color.white] >=
|
if (pieceOnBoardCount[Color.black] + pieceOnBoardCount[Color.white] >=
|
||||||
rankNumber * fileNumber) {
|
rankNumber * fileNumber) {
|
||||||
if (rule.isBlackLoseButNotDrawWhenBoardFull) {
|
if (rule.isBlackLoseButNotDrawWhenBoardFull) {
|
||||||
setGameOver(Color.white, GameOverReason.loseReasonBoardIsFull);
|
setGameOver(Color.white, GameOverReason.loseReasonBoardIsFull);
|
||||||
|
@ -1408,14 +1410,14 @@ class Position {
|
||||||
|
|
||||||
bool isAllSurrounded() {
|
bool isAllSurrounded() {
|
||||||
// Full
|
// Full
|
||||||
if (nPiecesOnBoard[Color.black] + nPiecesOnBoard[Color.white] >=
|
if (pieceOnBoardCount[Color.black] + pieceOnBoardCount[Color.white] >=
|
||||||
rankNumber * fileNumber) {
|
rankNumber * fileNumber) {
|
||||||
//print("Board is full.");
|
//print("Board is full.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can fly
|
// Can fly
|
||||||
if (nPiecesOnBoard[sideToMove()] <= rule.nPiecesAtLeast &&
|
if (pieceOnBoardCount[sideToMove()] <= rule.piecesAtLeastCount &&
|
||||||
rule.flyingAllowed) {
|
rule.flyingAllowed) {
|
||||||
//print("Can fly.");
|
//print("Can fly.");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Rule {
|
||||||
String name = "Da San Qi";
|
String name = "Da San Qi";
|
||||||
String description;
|
String description;
|
||||||
int nTotalPiecesEachSide = 12; // 9 or 12
|
int nTotalPiecesEachSide = 12; // 9 or 12
|
||||||
int nPiecesAtLeast = 3; // Default is 3
|
int piecesAtLeastCount = 3; // Default is 3
|
||||||
bool hasObliqueLines = true;
|
bool hasObliqueLines = true;
|
||||||
bool hasBannedLocations = true;
|
bool hasBannedLocations = true;
|
||||||
bool isDefenderMoveFirst = true;
|
bool isDefenderMoveFirst = true;
|
||||||
|
|
|
@ -251,7 +251,7 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||||
setNPiecesAtLeast(int value) async {
|
setNPiecesAtLeast(int value) async {
|
||||||
//
|
//
|
||||||
setState(() {
|
setState(() {
|
||||||
rule.nPiecesAtLeast = Config.nPiecesAtLeast = value;
|
rule.piecesAtLeastCount = Config.piecesAtLeastCount = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
Config.save();
|
Config.save();
|
||||||
|
|
|
@ -1537,15 +1537,15 @@ void Game::setTips()
|
||||||
|
|
||||||
switch (p.phase) {
|
switch (p.phase) {
|
||||||
case Phase::ready:
|
case Phase::ready:
|
||||||
tips = "轮到" + turnStr + "落子,剩余" + std::to_string(p.nPiecesInHand[BLACK]) + "子" +
|
tips = "轮到" + turnStr + "落子,剩余" + std::to_string(p.pieceInHandCount[BLACK]) + "子" +
|
||||||
" 比分 " + to_string(p.score[BLACK]) + ":" + to_string(p.score[WHITE]) + ", 和棋 " + to_string(p.score_draw);
|
" 比分 " + to_string(p.score[BLACK]) + ":" + to_string(p.score[WHITE]) + ", 和棋 " + to_string(p.score_draw);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Phase::placing:
|
case Phase::placing:
|
||||||
if (p.action == Action::place) {
|
if (p.action == Action::place) {
|
||||||
tips = "轮到" + turnStr + "落子,剩余" + std::to_string(p.nPiecesInHand[p.sideToMove]) + "子";
|
tips = "轮到" + turnStr + "落子,剩余" + std::to_string(p.pieceInHandCount[p.sideToMove]) + "子";
|
||||||
} else if (p.action == Action::remove) {
|
} else if (p.action == Action::remove) {
|
||||||
tips = "成三!轮到" + turnStr + "去子,需去" + std::to_string(p.nPiecesNeedRemove) + "子";
|
tips = "成三!轮到" + turnStr + "去子,需去" + std::to_string(p.pieceToRemoveCount) + "子";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1553,7 +1553,7 @@ void Game::setTips()
|
||||||
if (p.action == Action::place || p.action == Action::select) {
|
if (p.action == Action::place || p.action == Action::select) {
|
||||||
tips = "轮到" + turnStr + "选子移动";
|
tips = "轮到" + turnStr + "选子移动";
|
||||||
} else if (p.action == Action::remove) {
|
} else if (p.action == Action::remove) {
|
||||||
tips = "成三!轮到" + turnStr + "去子,需去" + std::to_string(p.nPiecesNeedRemove) + "子";
|
tips = "成三!轮到" + turnStr + "去子,需去" + std::to_string(p.pieceToRemoveCount) + "子";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue