diff --git a/src/evaluate.cpp b/src/evaluate.cpp index abf5e34c..45f63acb 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -65,20 +65,20 @@ Value Evaluation::value() { Value value = VALUE_ZERO; - int nPiecesInHandDiff; - int nPiecesOnBoardDiff; - int nPiecesNeedRemove; + int pieceInHandDiffCount; + int pieceOnBoardDiffCount; + int pieceToRemoveCount; switch (pos.get_phase()) { case Phase::ready: break; case Phase::placing: - nPiecesInHandDiff = pos.n_pieces_in_hand(BLACK) - pos.n_pieces_in_hand(WHITE); - value += nPiecesInHandDiff * VALUE_EACH_PIECE_INHAND; + pieceInHandDiffCount = pos.piece_in_hand_count(BLACK) - pos.piece_in_hand_count(WHITE); + value += pieceInHandDiffCount * VALUE_EACH_PIECE_INHAND; - nPiecesOnBoardDiff = pos.n_pieces_on_board(BLACK) - pos.n_pieces_on_board(WHITE); - value += nPiecesOnBoardDiff * VALUE_EACH_PIECE_ONBOARD; + pieceOnBoardDiffCount = pos.piece_on_board_count(BLACK) - pos.piece_on_board_count(WHITE); + value += pieceOnBoardDiffCount * VALUE_EACH_PIECE_ONBOARD; switch (pos.get_action()) { case Action::select: @@ -86,9 +86,9 @@ Value Evaluation::value() break; case Action::remove: - nPiecesNeedRemove = (pos.side_to_move() == BLACK) ? - pos.n_pieces_to_remove() : -(pos.n_pieces_to_remove()); - value += nPiecesNeedRemove * VALUE_EACH_PIECE_PLACING_NEEDREMOVE; + pieceToRemoveCount = (pos.side_to_move() == BLACK) ? + pos.piece_to_remove_count() : -(pos.piece_to_remove_count()); + value += pieceToRemoveCount * VALUE_EACH_PIECE_PLACING_NEEDREMOVE; break; default: break; @@ -97,11 +97,11 @@ Value Evaluation::value() break; case Phase::moving: - value = pos.n_pieces_on_board(BLACK) * VALUE_EACH_PIECE_ONBOARD - - pos.n_pieces_on_board(WHITE) * VALUE_EACH_PIECE_ONBOARD; + value = pos.piece_on_board_count(BLACK) * VALUE_EACH_PIECE_ONBOARD - + pos.piece_on_board_count(WHITE) * VALUE_EACH_PIECE_ONBOARD; #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 */ switch (pos.get_action()) { @@ -110,9 +110,9 @@ Value Evaluation::value() break; case Action::remove: - nPiecesNeedRemove = (pos.side_to_move() == BLACK) ? - pos.n_pieces_to_remove() : -(pos.n_pieces_to_remove()); - value += nPiecesNeedRemove * VALUE_EACH_PIECE_MOVING_NEEDREMOVE; + pieceToRemoveCount = (pos.side_to_move() == BLACK) ? + pos.piece_to_remove_count() : -(pos.piece_to_remove_count()); + value += pieceToRemoveCount * VALUE_EACH_PIECE_MOVING_NEEDREMOVE; break; default: break; @@ -121,7 +121,7 @@ Value Evaluation::value() break; 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) { value -= VALUE_MATE; } else { @@ -134,9 +134,9 @@ Value Evaluation::value() 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; - } else if (pos.n_pieces_on_board(WHITE) < rule.nPiecesAtLeast) { + } else if (pos.piece_on_board_count(WHITE) < rule.piecesAtLeastCount) { value += VALUE_MATE; } diff --git a/src/movegen.cpp b/src/movegen.cpp index 1a8c1a26..370476a9 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -60,7 +60,7 @@ ExtMove *generate(Position &pos, ExtMove *moveList) 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) { for (auto direction = MD_BEGIN; direction < MD_NB; ++direction) { to = static_cast(MoveList::adjacentSquares[from][direction]); diff --git a/src/position.cpp b/src/position.cpp index 35977611..2ecb8da4 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -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 ss >> std::skipws - >> nPiecesOnBoard[BLACK] >> nPiecesInHand[BLACK] - >> nPiecesOnBoard[WHITE] >> nPiecesInHand[WHITE] - >> nPiecesNeedRemove; + >> pieceOnBoardCount[BLACK] >> pieceInHandCount[BLACK] + >> pieceOnBoardCount[WHITE] >> pieceInHandCount[WHITE] + >> pieceToRemoveCount; // 6-7. Halfmove clock and fullmove number @@ -360,9 +360,9 @@ const string Position::fen() const ss << " "; - ss << nPiecesOnBoard[BLACK] << " " << nPiecesInHand[BLACK] << " " - << nPiecesOnBoard[WHITE] << " " << nPiecesInHand[WHITE] << " " - << nPiecesNeedRemove << " "; + ss << pieceOnBoardCount[BLACK] << " " << pieceInHandCount[BLACK] << " " + << pieceOnBoardCount[WHITE] << " " << pieceInHandCount[WHITE] << " " + << pieceToRemoveCount << " "; ss << st.rule50 << " " << 1 + (gamePly - (sideToMove == BLACK)) / 2; @@ -535,9 +535,9 @@ void Position::undo_move(Move m) } // TODO: Adjust - //int nPiecesInHand[COLOR_NB]{ 0 }; - //int nPiecesOnBoard[COLOR_NB]{ 0 }; - //int nPiecesNeedRemove{ 0 }; + //int pieceInHandCount[COLOR_NB]{ 0 }; + //int pieceOnBoardCount[COLOR_NB]{ 0 }; + //int pieceToRemoveCount{ 0 }; // 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 r = 0; r < RANK_NB; r++) { Square s = static_cast(f * RANK_NB + r); if (board[s] & B_STONE) { - nPiecesOnBoard[BLACK]++; + pieceOnBoardCount[BLACK]++; } else if (board[s] & W_STONE) { - nPiecesOnBoard[WHITE]++; + pieceOnBoardCount[WHITE]++; } #if 0 else if (board[s] & BAN_STONE) { @@ -685,20 +685,20 @@ int Position::n_pieces_on_board_count() } } - if (nPiecesOnBoard[BLACK] > rule.nTotalPiecesEachSide || - nPiecesOnBoard[WHITE] > rule.nTotalPiecesEachSide) { + if (pieceOnBoardCount[BLACK] > rule.nTotalPiecesEachSide || + pieceOnBoardCount[WHITE] > rule.nTotalPiecesEachSide) { 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]; - nPiecesInHand[WHITE] = rule.nTotalPiecesEachSide - nPiecesOnBoard[WHITE]; + pieceInHandCount[BLACK] = rule.nTotalPiecesEachSide - pieceOnBoardCount[BLACK]; + pieceInHandCount[WHITE] = rule.nTotalPiecesEachSide - pieceOnBoardCount[WHITE]; - return nPiecesInHand[BLACK] + nPiecesInHand[WHITE]; + return pieceInHandCount[BLACK] + pieceInHandCount[WHITE]; } #ifdef THREEFOLD_REPETITION @@ -726,9 +726,9 @@ bool Position::reset() memset(byTypeBB, 0, sizeof(byTypeBB)); memset(byColorBB, 0, sizeof(byColorBB)); - nPiecesOnBoard[BLACK] = nPiecesOnBoard[WHITE] = 0; - nPiecesInHand[BLACK] = nPiecesInHand[WHITE] = rule.nTotalPiecesEachSide; - nPiecesNeedRemove = 0; + pieceOnBoardCount[BLACK] = pieceOnBoardCount[WHITE] = 0; + pieceInHandCount[BLACK] = pieceInHandCount[WHITE] = rule.nTotalPiecesEachSide; + pieceToRemoveCount = 0; millListSize = 0; MoveList::create(); @@ -792,9 +792,9 @@ bool Position::put_piece(Square s, bool updateCmdlist) } if (phase == Phase::placing) { - piece = (Piece)((0x01 | make_piece(sideToMove)) + rule.nTotalPiecesEachSide - nPiecesInHand[us]); - nPiecesInHand[us]--; - nPiecesOnBoard[us]++; + piece = (Piece)((0x01 | make_piece(sideToMove)) + rule.nTotalPiecesEachSide - pieceInHandCount[us]); + pieceInHandCount[us]--; + pieceOnBoardCount[us]++; Piece pc = board[s] = piece; 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); 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()) { return true; } @@ -836,7 +836,7 @@ bool Position::put_piece(Square s, bool updateCmdlist) change_side_to_move(); } } else { - nPiecesNeedRemove = rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1; + pieceToRemoveCount = rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1; update_key_misc(); action = Action::remove; } @@ -848,7 +848,7 @@ bool Position::put_piece(Square s, bool updateCmdlist) } // if illegal - if (nPiecesOnBoard[sideToMove] > rule.nPiecesAtLeast || + if (pieceOnBoardCount[sideToMove] > rule.piecesAtLeastCount || !rule.flyingAllowed) { if ((square_bb(s) & MoveList::adjacentSquaresBB[currentSquare]) == 0) { return false; @@ -890,7 +890,7 @@ bool Position::put_piece(Square s, bool updateCmdlist) return true; } } else { - nPiecesNeedRemove = rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1; + pieceToRemoveCount = rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1; update_key_misc(); action = Action::remove; } @@ -909,7 +909,7 @@ bool Position::remove_piece(Square s, bool updateCmdlist) if (action != Action::remove) return false; - if (nPiecesNeedRemove <= 0) + if (pieceToRemoveCount <= 0) return false; // 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? } - nPiecesOnBoard[them]--; + pieceOnBoardCount[them]--; - if (nPiecesOnBoard[them] + nPiecesInHand[them] < rule.nPiecesAtLeast) { + if (pieceOnBoardCount[them] + pieceInHandCount[them] < rule.piecesAtLeastCount) { set_gameover(sideToMove, GameOverReason::loseReasonlessThanThree); return true; } currentSquare = SQ_0; - nPiecesNeedRemove--; + pieceToRemoveCount--; update_key_misc(); - if (nPiecesNeedRemove > 0) { + if (pieceToRemoveCount > 0) { return true; } if (phase == Phase::placing) { - if (nPiecesInHand[BLACK] == 0 && nPiecesInHand[WHITE] == 0) { + if (pieceInHandCount[BLACK] == 0 && pieceInHandCount[WHITE] == 0) { phase = Phase::moving; action = Action::select; @@ -1123,7 +1123,7 @@ bool Position::check_if_game_is_over() return true; } - if (nPiecesOnBoard[BLACK] + nPiecesOnBoard[WHITE] >= EFFECTIVE_SQUARE_NB) { + if (pieceOnBoardCount[BLACK] + pieceOnBoardCount[WHITE] >= EFFECTIVE_SQUARE_NB) { if (rule.isBlackLoseButNotDrawWhenBoardFull) { set_gameover(WHITE, GameOverReason::loseReasonBoardIsFull); } else { @@ -1227,7 +1227,7 @@ Key Position::update_key_misc() { st.key = st.key << Zobrist::KEY_MISC_BIT >> Zobrist::KEY_MISC_BIT; - st.key |= static_cast(nPiecesNeedRemove) << (CHAR_BIT * sizeof(Key) - Zobrist::KEY_MISC_BIT); + st.key |= static_cast(pieceToRemoveCount) << (CHAR_BIT * sizeof(Key) - Zobrist::KEY_MISC_BIT); return st.key; } @@ -1486,7 +1486,7 @@ int Position::surrounded_empty_squares_count(Square s, bool includeFobidden) int n = 0; - if (nPiecesOnBoard[sideToMove] > rule.nPiecesAtLeast || + if (pieceOnBoardCount[sideToMove] > rule.piecesAtLeastCount || !rule.flyingAllowed) { Square moveSquare; 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 { // Full - if (nPiecesOnBoard[BLACK] + nPiecesOnBoard[WHITE] >= EFFECTIVE_SQUARE_NB) + if (pieceOnBoardCount[BLACK] + pieceOnBoardCount[WHITE] >= EFFECTIVE_SQUARE_NB) return true; // Can fly - if (nPiecesOnBoard[sideToMove] <= rule.nPiecesAtLeast && + if (pieceOnBoardCount[sideToMove] <= rule.piecesAtLeastCount && rule.flyingAllowed) { return false; } diff --git a/src/position.h b/src/position.h index 1ac59bcb..14cf9e28 100644 --- a/src/position.h +++ b/src/position.h @@ -142,13 +142,13 @@ public: static void print_board(); - int n_pieces_on_board_count(); - int get_n_pieces_in_hand(); + int piece_on_board_count_count(); + int get_piece_in_hand_count(); - int n_pieces_on_board(Color c); - int n_pieces_in_hand(Color c); + int piece_on_board_count(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); @@ -178,9 +178,9 @@ public: Bitboard byTypeBB[PIECE_TYPE_NB]; Bitboard byColorBB[COLOR_NB]; // TODO: [0] is sum of Black and White - int nPiecesInHand[COLOR_NB]{ 0, 12, 12 }; // TODO - int nPiecesOnBoard[COLOR_NB]{ 0, 0, 0 }; - int nPiecesNeedRemove{ 0 }; + int pieceInHandCount[COLOR_NB]{ 0, 12, 12 }; // TODO + int pieceOnBoardCount[COLOR_NB]{ 0, 0, 0 }; + int pieceToRemoveCount{ 0 }; int gamePly { 0 }; Color sideToMove { NOCOLOR }; Thread *thisThread; @@ -261,9 +261,9 @@ inline Piece Position::moved_piece(Move m) const template inline int Position::count(Color c) const { if (Pt == ON_BOARD) { - return nPiecesOnBoard[c]; + return pieceOnBoardCount[c]; } else if (Pt == IN_HAND) { - return nPiecesInHand[c]; + return pieceInHandCount[c]; } return 0; @@ -380,19 +380,19 @@ inline const char *Position::cmd_line() const 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 diff --git a/src/rule.h b/src/rule.h index 109e992c..98dbfa96 100644 --- a/src/rule.h +++ b/src/rule.h @@ -29,7 +29,7 @@ struct Rule int nTotalPiecesEachSide; // 9 or 12 - int nPiecesAtLeast; // Default is 3 + int piecesAtLeastCount; // Default is 3 bool hasObliqueLines; diff --git a/src/search.cpp b/src/search.cpp index 7acf66f0..69b84aa3 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -294,7 +294,7 @@ Value search(Position *pos, Sanmill::Stack &ss, Depth depth, Depth ori #endif /* TRANSPOSITION_TABLE_ENABLE */ #if 0 - if (position->phase == Phase::placing && depth == 1 && pos->nPiecesNeedRemove > 0) { + if (position->phase == Phase::placing && depth == 1 && pos->pieceToRemoveCount > 0) { depth--; } #endif diff --git a/src/thread.cpp b/src/thread.cpp index 214fee08..b1c0f5c5 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -469,13 +469,13 @@ Depth Thread::adjustDepth() // Can fly if (rule.flyingAllowed) { - if (pb == rule.nPiecesAtLeast || - pw == rule.nPiecesAtLeast) { + if (pb == rule.piecesAtLeastCount || + pw == rule.piecesAtLeastCount) { d = flyingDepth; } - if (pb == rule.nPiecesAtLeast && - pw == rule.nPiecesAtLeast) { + if (pb == rule.piecesAtLeastCount && + pw == rule.piecesAtLeastCount) { d = flyingDepth / 2; } } diff --git a/src/ucioption.cpp b/src/ucioption.cpp index a6dfd9e2..c836ec6d 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -72,9 +72,9 @@ void on_nTotalPiecesEachSide(const Option &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) @@ -157,7 +157,7 @@ void init(OptionsMap &o) // Rules 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["hasBannedLocations"] << Option(true, on_hasBannedLocations); o["isDefenderMoveFirst"] << Option(true, on_isDefenderMoveFirst); diff --git a/src/ui/flutter/lib/common/config.dart b/src/ui/flutter/lib/common/config.dart index 75990ea9..3ca75383 100644 --- a/src/ui/flutter/lib/common/config.dart +++ b/src/ui/flutter/lib/common/config.dart @@ -38,7 +38,7 @@ class Config { // Rules static int nTotalPiecesEachSide = 12; - static int nPiecesAtLeast = 3; + static int piecesAtLeastCount = 3; static bool hasObliqueLines = true; static bool hasBannedLocations = true; static bool isDefenderMoveFirst = true; @@ -69,8 +69,8 @@ class Config { // Rules rule.nTotalPiecesEachSide = Config.nTotalPiecesEachSide = profile['nTotalPiecesEachSide'] ?? 12; - rule.nPiecesAtLeast = - Config.nPiecesAtLeast = profile['nPiecesAtLeast'] ?? 3; + rule.piecesAtLeastCount = + Config.piecesAtLeastCount = profile['piecesAtLeastCount'] ?? 3; rule.hasObliqueLines = Config.hasObliqueLines = profile['hasObliqueLines'] ?? true; rule.hasBannedLocations = @@ -115,7 +115,7 @@ class Config { // Rules profile['nTotalPiecesEachSide'] = Config.nTotalPiecesEachSide; - profile['nPiecesAtLeast'] = Config.nPiecesAtLeast; + profile['piecesAtLeastCount'] = Config.piecesAtLeastCount; profile['hasObliqueLines'] = Config.hasObliqueLines; profile['hasBannedLocations'] = Config.hasBannedLocations; profile['isDefenderMoveFirst'] = Config.isDefenderMoveFirst; diff --git a/src/ui/flutter/lib/engine/native_engine.dart b/src/ui/flutter/lib/engine/native_engine.dart index 13690b64..0f2dc5e4 100644 --- a/src/ui/flutter/lib/engine/native_engine.dart +++ b/src/ui/flutter/lib/engine/native_engine.dart @@ -136,7 +136,8 @@ class NativeEngine extends AiEngine { await send('setoption name Shuffling value ${Config.shufflingEnabled}'); await send( 'setoption name nTotalPiecesEachSide value ${Config.nTotalPiecesEachSide}'); - await send('setoption name nPiecesAtLeast value ${Config.nPiecesAtLeast}'); + await send( + 'setoption name piecesAtLeastCount value ${Config.piecesAtLeastCount}'); await send( 'setoption name hasObliqueLines value ${Config.hasObliqueLines}'); await send( diff --git a/src/ui/flutter/lib/l10n/intl_en.arb b/src/ui/flutter/lib/l10n/intl_en.arb index a2e2c38e..f472cecf 100644 --- a/src/ui/flutter/lib/l10n/intl_en.arb +++ b/src/ui/flutter/lib/l10n/intl_en.arb @@ -323,8 +323,8 @@ "@twelvePieces": { "description": "Twelve Pieces" }, - "nPiecesAtLeast": "Pieces At Least", - "@nPiecesAtLeast": { + "piecesAtLeastCount": "Pieces At Least", + "@piecesAtLeastCount": { "description": "Pieces At Least" }, "hasObliqueLines": "Has Oblique Lines", diff --git a/src/ui/flutter/lib/l10n/intl_zh.arb b/src/ui/flutter/lib/l10n/intl_zh.arb index 9aca1f38..5f7fce30 100644 --- a/src/ui/flutter/lib/l10n/intl_zh.arb +++ b/src/ui/flutter/lib/l10n/intl_zh.arb @@ -80,7 +80,7 @@ "nTotalPiecesEachSide": "棋子数", "ninePieces": "九子", "twelvePieces": "十二子", - "nPiecesAtLeast": "少于几个子则输棋", + "piecesAtLeastCount": "少于几个子则输棋", "hasObliqueLines": "斜线", "hasBannedLocations": "禁点", "isDefenderMoveFirst": "后摆子的先走子", diff --git a/src/ui/flutter/lib/mill/position.dart b/src/ui/flutter/lib/mill/position.dart index 8046a5c6..041ebdf4 100644 --- a/src/ui/flutter/lib/mill/position.dart +++ b/src/ui/flutter/lib/mill/position.dart @@ -46,9 +46,9 @@ class Position { GameRecorder recorder; - Map nPiecesInHand = {Color.black: -1, Color.white: -1}; - Map nPiecesOnBoard = {Color.black: 0, Color.white: 0}; - int nPiecesNeedRemove = 0; + Map pieceInHandCount = {Color.black: -1, Color.white: -1}; + Map pieceOnBoardCount = {Color.black: 0, Color.white: 0}; + int pieceToRemoveCount = 0; int gamePly = 0; String _sideToMove = Color.black; @@ -102,9 +102,9 @@ class Position { recorder = other.recorder; - nPiecesInHand = other.nPiecesInHand; - nPiecesOnBoard = other.nPiecesOnBoard; - nPiecesNeedRemove = other.nPiecesNeedRemove; + pieceInHandCount = other.pieceInHandCount; + pieceOnBoardCount = other.pieceOnBoardCount; + pieceToRemoveCount = other.pieceToRemoveCount; gamePly = other.gamePly; @@ -242,15 +242,15 @@ class Position { 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; @@ -370,35 +370,35 @@ class Position { /////////////////////////////////////////////////////////////////////////////// - int nPiecesOnBoardCount() { - nPiecesOnBoard[Color.black] = nPiecesOnBoard[Color.white] = 0; + int pieceOnBoardCountCount() { + pieceOnBoardCount[Color.black] = pieceOnBoardCount[Color.white] = 0; for (int f = 1; f < fileExNumber; f++) { for (int r = 0; r < rankNumber; r++) { int s = f * rankNumber + r; if (board[s] == Piece.blackStone) { - nPiecesOnBoard[Color.black]++; + pieceOnBoardCount[Color.black]++; } else if (board[s] == Piece.whiteStone) { - nPiecesOnBoard[Color.black]++; + pieceOnBoardCount[Color.black]++; } } } - if (nPiecesOnBoard[Color.black] > rule.nTotalPiecesEachSide || - nPiecesOnBoard[Color.white] > rule.nTotalPiecesEachSide) { + if (pieceOnBoardCount[Color.black] > rule.nTotalPiecesEachSide || + pieceOnBoardCount[Color.white] > rule.nTotalPiecesEachSide) { return -1; } - return nPiecesOnBoard[Color.black] + nPiecesOnBoard[Color.white]; + return pieceOnBoardCount[Color.black] + pieceOnBoardCount[Color.white]; } int GetNPiecesInHand() { - nPiecesInHand[Color.black] = - rule.nTotalPiecesEachSide - nPiecesOnBoard[Color.black]; - nPiecesInHand[Color.white] = - rule.nTotalPiecesEachSide - nPiecesOnBoard[Color.white]; + pieceInHandCount[Color.black] = + rule.nTotalPiecesEachSide - pieceOnBoardCount[Color.black]; + pieceInHandCount[Color.white] = + rule.nTotalPiecesEachSide - pieceOnBoardCount[Color.white]; - return nPiecesOnBoard[Color.black] + nPiecesOnBoard[Color.white]; + return pieceOnBoardCount[Color.black] + pieceOnBoardCount[Color.white]; } void clearBoard() { @@ -428,12 +428,12 @@ class Position { clearBoard(); - if (nPiecesOnBoardCount() == -1) { + if (pieceOnBoardCountCount() == -1) { return -1; } GetNPiecesInHand(); - nPiecesNeedRemove = 0; + pieceToRemoveCount = 0; winner = Color.nobody; createMoveTable(); @@ -456,10 +456,10 @@ class Position { clearBoard(); - nPiecesOnBoard[Color.black] = nPiecesOnBoard[Color.white] = 0; - nPiecesInHand[Color.black] = - nPiecesInHand[Color.white] = rule.nTotalPiecesEachSide; - nPiecesNeedRemove = 0; + pieceOnBoardCount[Color.black] = pieceOnBoardCount[Color.white] = 0; + pieceInHandCount[Color.black] = + pieceInHandCount[Color.white] = rule.nTotalPiecesEachSide; + pieceToRemoveCount = 0; currentSquare = 0; int i = 0; // TODO: rule @@ -513,8 +513,8 @@ class Position { if (phase == Phase.placing) { piece = sideToMove(); - nPiecesInHand[us]--; - nPiecesOnBoard[us]++; + pieceInHandCount[us]--; + pieceOnBoardCount[us]++; _grid[index] = piece; board[s] = piece; @@ -526,11 +526,11 @@ class Position { int n = addMills(currentSquare); if (n == 0) { - assert( - nPiecesInHand[Color.black] >= 0 && nPiecesInHand[Color.white] >= 0); + assert(pieceInHandCount[Color.black] >= 0 && + pieceInHandCount[Color.white] >= 0); - if (nPiecesInHand[Color.black] == 0 && - nPiecesInHand[Color.white] == 0) { + if (pieceInHandCount[Color.black] == 0 && + pieceInHandCount[Color.white] == 0) { if (checkIfGameIsOver()) { return true; } @@ -553,7 +553,7 @@ class Position { changeSideToMove(); } } else { - nPiecesNeedRemove = + pieceToRemoveCount = rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1; action = Act.remove; } @@ -563,7 +563,7 @@ class Position { } // if illegal - if (nPiecesOnBoard[sideToMove()] > rule.nPiecesAtLeast || + if (pieceOnBoardCount[sideToMove()] > rule.piecesAtLeastCount || !rule.flyingAllowed) { int md; @@ -606,7 +606,7 @@ class Position { return true; } } else { - nPiecesNeedRemove = + pieceToRemoveCount = rule.allowRemoveMultiPiecesWhenCloseMultiMill ? n : 1; action = Act.remove; } @@ -622,7 +622,7 @@ class Position { if (action != Act.remove) return false; - if (nPiecesNeedRemove <= 0) return false; + if (pieceToRemoveCount <= 0) return false; // if piece is not their if (!(Color.opponent(sideToMove()) == board[s])) return false; @@ -643,23 +643,25 @@ class Position { cmdline = "-(" + fileOf(s).toString() + "," + rankOf(s).toString() + ")"; 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); return true; } currentSquare = 0; - nPiecesNeedRemove--; + pieceToRemoveCount--; - if (nPiecesNeedRemove > 0) { + if (pieceToRemoveCount > 0) { return true; } 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; action = Act.select; @@ -749,7 +751,7 @@ class Position { return true; } - if (nPiecesOnBoard[Color.black] + nPiecesOnBoard[Color.white] >= + if (pieceOnBoardCount[Color.black] + pieceOnBoardCount[Color.white] >= rankNumber * fileNumber) { if (rule.isBlackLoseButNotDrawWhenBoardFull) { setGameOver(Color.white, GameOverReason.loseReasonBoardIsFull); @@ -1408,14 +1410,14 @@ class Position { bool isAllSurrounded() { // Full - if (nPiecesOnBoard[Color.black] + nPiecesOnBoard[Color.white] >= + if (pieceOnBoardCount[Color.black] + pieceOnBoardCount[Color.white] >= rankNumber * fileNumber) { //print("Board is full."); return true; } // Can fly - if (nPiecesOnBoard[sideToMove()] <= rule.nPiecesAtLeast && + if (pieceOnBoardCount[sideToMove()] <= rule.piecesAtLeastCount && rule.flyingAllowed) { //print("Can fly."); return false; diff --git a/src/ui/flutter/lib/mill/rule.dart b/src/ui/flutter/lib/mill/rule.dart index 594541af..f82132d1 100644 --- a/src/ui/flutter/lib/mill/rule.dart +++ b/src/ui/flutter/lib/mill/rule.dart @@ -20,7 +20,7 @@ class Rule { String name = "Da San Qi"; String description; int nTotalPiecesEachSide = 12; // 9 or 12 - int nPiecesAtLeast = 3; // Default is 3 + int piecesAtLeastCount = 3; // Default is 3 bool hasObliqueLines = true; bool hasBannedLocations = true; bool isDefenderMoveFirst = true; diff --git a/src/ui/flutter/lib/widgets/settings_page.dart b/src/ui/flutter/lib/widgets/settings_page.dart index 598b828b..64aefb49 100644 --- a/src/ui/flutter/lib/widgets/settings_page.dart +++ b/src/ui/flutter/lib/widgets/settings_page.dart @@ -251,7 +251,7 @@ class _SettingsPageState extends State { setNPiecesAtLeast(int value) async { // setState(() { - rule.nPiecesAtLeast = Config.nPiecesAtLeast = value; + rule.piecesAtLeastCount = Config.piecesAtLeastCount = value; }); Config.save(); diff --git a/src/ui/qt/game.cpp b/src/ui/qt/game.cpp index 4315c00b..f6cb769a 100644 --- a/src/ui/qt/game.cpp +++ b/src/ui/qt/game.cpp @@ -1537,15 +1537,15 @@ void Game::setTips() switch (p.phase) { 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); break; case Phase::placing: 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) { - tips = "成三!轮到" + turnStr + "去子,需去" + std::to_string(p.nPiecesNeedRemove) + "子"; + tips = "成三!轮到" + turnStr + "去子,需去" + std::to_string(p.pieceToRemoveCount) + "子"; } break; @@ -1553,7 +1553,7 @@ void Game::setTips() if (p.action == Action::place || p.action == Action::select) { tips = "轮到" + turnStr + "选子移动"; } else if (p.action == Action::remove) { - tips = "成三!轮到" + turnStr + "去子,需去" + std::to_string(p.nPiecesNeedRemove) + "子"; + tips = "成三!轮到" + turnStr + "去子,需去" + std::to_string(p.pieceToRemoveCount) + "子"; } break;