perfect: Add MUEHLE_NMM macron
To Fix rule diff with NMM.
This commit is contained in:
parent
0d0a277e9c
commit
6252797045
|
@ -117,7 +117,7 @@ Value Evaluation::value()
|
|||
value = VALUE_DRAW;
|
||||
}
|
||||
} else if (pos.get_action() == Action::select &&
|
||||
pos.is_all_surrounded() &&
|
||||
pos.is_all_surrounded(pos.side_to_move()) &&
|
||||
rule.isLoseButNotChangeSideWhenNoWay) {
|
||||
const Value delta = pos.side_to_move() == BLACK ? -VALUE_MATE : VALUE_MATE;
|
||||
value += delta;
|
||||
|
|
|
@ -650,6 +650,16 @@ bool Position::put_piece(Square s, bool updateRecord)
|
|||
|
||||
currentSquare = s;
|
||||
|
||||
#ifdef MUEHLE_NMM
|
||||
if (pieceInHandCount[BLACK] == 0 &&
|
||||
pieceInHandCount[WHITE] == 0 &&
|
||||
is_all_surrounded(~sideToMove, SQ_0, s)) {
|
||||
set_gameover(sideToMove, GameOverReason::loseReasonNoWay);
|
||||
//change_side_to_move();
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
const int n = mills_count(currentSquare);
|
||||
|
||||
if (n == 0
|
||||
|
@ -689,9 +699,15 @@ bool Position::put_piece(Square s, bool updateRecord)
|
|||
|
||||
} else if (phase == Phase::moving) {
|
||||
|
||||
#ifdef MUEHLE_NMM
|
||||
if (is_all_surrounded(~sideToMove, currentSquare, s)) {
|
||||
set_gameover(sideToMove, GameOverReason::loseReasonNoWay);
|
||||
}
|
||||
#else
|
||||
if (check_if_game_is_over()) {
|
||||
return true;
|
||||
}
|
||||
#endif // MUEHLE_NMM
|
||||
|
||||
// if illegal
|
||||
if (pieceOnBoardCount[sideToMove] > rule.piecesAtLeastCount ||
|
||||
|
@ -983,7 +999,7 @@ bool Position::check_if_game_is_over()
|
|||
return true;
|
||||
}
|
||||
|
||||
if (phase == Phase::moving && action == Action::select && is_all_surrounded()) {
|
||||
if (phase == Phase::moving && action == Action::select && is_all_surrounded(sideToMove)) {
|
||||
if (rule.isLoseButNotChangeSideWhenNoWay) {
|
||||
set_gameover(~sideToMove, GameOverReason::loseReasonNoWay);
|
||||
return true;
|
||||
|
@ -991,7 +1007,7 @@ bool Position::check_if_game_is_over()
|
|||
change_side_to_move(); // TODO: Need?
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1269,21 +1285,28 @@ void Position::surrounded_pieces_count(Square s, int &ourPieceCount, int &theirP
|
|||
}
|
||||
}
|
||||
|
||||
bool Position::is_all_surrounded() const
|
||||
bool Position::is_all_surrounded(Color c, Square from, Square to) const
|
||||
{
|
||||
// Full
|
||||
if (pieceOnBoardCount[BLACK] + pieceOnBoardCount[WHITE] >= EFFECTIVE_SQUARE_NB)
|
||||
return true;
|
||||
|
||||
// Can fly
|
||||
if (pieceOnBoardCount[sideToMove] <= rule.piecesAtLeastCount &&
|
||||
if (pieceOnBoardCount[c] <= rule.piecesAtLeastCount &&
|
||||
rule.mayFly) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Square s = SQ_BEGIN; s < SQ_END; s = (Square)(s + 1)) {
|
||||
if ((sideToMove & color_on(s)) &&
|
||||
(byTypeBB[ALL_PIECES] & MoveList<LEGAL>::adjacentSquaresBB[s]) != MoveList<LEGAL>::adjacentSquaresBB[s]) {
|
||||
Bitboard bb = byTypeBB[ALL_PIECES];
|
||||
|
||||
#ifdef MUEHLE_NMM
|
||||
CLEAR_BIT(bb, from);
|
||||
SET_BIT(bb, to);
|
||||
#endif // MUEHLE_NMM
|
||||
|
||||
for (Square s = SQ_BEGIN; s < SQ_END; ++s) {
|
||||
if ((c & color_on(s)) &&
|
||||
(bb & MoveList<LEGAL>::adjacentSquaresBB[s]) != MoveList<LEGAL>::adjacentSquaresBB[s]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ public:
|
|||
|
||||
int surrounded_empty_squares_count(Square s, bool includeBanned);
|
||||
void surrounded_pieces_count(Square s, int &nOurPieces, int &nTheirPieces, int &nBanned, int &nEmpty);
|
||||
bool is_all_surrounded() const;
|
||||
bool is_all_surrounded(Color c, Square from = SQ_0, Square to = SQ_0) const;
|
||||
|
||||
static void print_board();
|
||||
|
||||
|
|
|
@ -1045,18 +1045,24 @@ bool Game::command(const string &cmd, bool update /* = true */)
|
|||
gameStart();
|
||||
}
|
||||
|
||||
loggerDebug("Computer: %s\n\n", cmd.c_str());
|
||||
#ifdef MUEHLE_NMM
|
||||
if (position.get_phase() != Phase::gameOver) {
|
||||
#endif // MUEHLE_NMM
|
||||
loggerDebug("Computer: %s\n\n", cmd.c_str());
|
||||
|
||||
moveHistory.emplace_back(cmd);
|
||||
moveHistory.emplace_back(cmd);
|
||||
|
||||
if (cmd.size() > strlen("-(1,2)")) {
|
||||
posKeyHistory.push_back(position.key());
|
||||
} else {
|
||||
posKeyHistory.clear();
|
||||
if (cmd.size() > strlen("-(1,2)")) {
|
||||
posKeyHistory.push_back(position.key());
|
||||
} else {
|
||||
posKeyHistory.clear();
|
||||
}
|
||||
|
||||
if (!position.command(cmd.c_str()))
|
||||
return false;
|
||||
#ifdef MUEHLE_NMM
|
||||
}
|
||||
|
||||
if (!position.command(cmd.c_str()))
|
||||
return false;
|
||||
#endif // MUEHLE_NMM
|
||||
|
||||
sideToMove = position.side_to_move();
|
||||
|
||||
|
@ -1598,6 +1604,13 @@ void Game::setTips()
|
|||
case GameOverReason::loseReasonlessThanThree:
|
||||
break;
|
||||
case GameOverReason::loseReasonNoWay:
|
||||
#ifdef MUEHLE_NMM
|
||||
if (!isInverted) {
|
||||
turnStr = char_to_string(color_to_char(~p.sideToMove));
|
||||
} else {
|
||||
turnStr = char_to_string(color_to_char(p.sideToMove));
|
||||
}
|
||||
#endif
|
||||
reasonStr = turnStr + "无子可走被闷。";
|
||||
break;
|
||||
case GameOverReason::loseReasonResign:
|
||||
|
|
Loading…
Reference in New Issue