From b379588655fecf22e9100e55820b966e31df6146 Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sat, 5 Sep 2020 17:13:37 +0800 Subject: [PATCH] =?UTF-8?q?fen:=20rule50=20=E8=B5=8B=E5=80=BC=E4=BD=86?= =?UTF-8?q?=E6=9A=82=E6=97=B6=E6=9C=AA=E6=AD=A3=E5=B8=B8=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 按 Stockfish 的写法: ss << (" - ") << st->rule50 << " " << 1 + (gamePly - (sideToMove == BLACK)) / 2; 最后一节并非如 http://www.xqbase.com/protocol/pgnfen2.htm 所说的, 回合数(Fullmove number) 棕色那段 当前要进行到的回合数。不管白还是黑,第一步时总是以1表示, 以后黑方每走一步数字就加1。 原因待查。目前也未正常工作。 --- src/position.cpp | 14 +++++--------- src/position.h | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) 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;