diff --git a/src/position.cpp b/src/position.cpp index 76c038de..cff95b93 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -370,15 +370,7 @@ const string Position::fen() const ss << " "; - // http://www.xqbase.com/protocol/pgnfen2.htm - - // Halfmove clock - - ss << st->rule50; - //ss << " "; - - // Fullmove number - //ss << moveStep; + ss << st->rule50 << " " << 1 + (gamePly - (sideToMove == BLACK)) / 2; return ss.str(); } @@ -390,10 +382,14 @@ const string Position::fen() const bool Position::do_move(Move m) { + ++st->rule50; + MoveType mt = type_of(m); switch (mt) { case MOVETYPE_REMOVE: + // Reset rule 50 counter + st->rule50 = 0; return remove_piece(static_cast(-m)); case MOVETYPE_MOVE: return move_piece(from_sq(m), to_sq(m)); diff --git a/src/position.h b/src/position.h index fea67449..91e9960e 100644 --- a/src/position.h +++ b/src/position.h @@ -193,7 +193,7 @@ public: int pieceCountInHand[COLOR_NB]{ 0 }; int pieceCountOnBoard[COLOR_NB]{ 0 }; int pieceCountNeedRemove{ 0 }; - int gamePly; + int gamePly { 0 }; Color sideToMove { NOCOLOR }; Thread *thisThread; StateInfo *st;