}
// 5-6. Halfmove clock and fullmove number
- fen >> std::skipws >> st->rule50 >> fullMoves;
+ fen >> std::skipws >> st->rule50 >> st->gamePly;
+
+ // Convert from fullmove starting from 1 to ply starting from 0,
+ // handle also common incorrect FEN with fullmove = 0.
+ st->gamePly = Max(2 * (st->gamePly - 1), 0) + int(sideToMove == BLACK);
// Various initialisations
chess960 = isChess960;
fen << '-';
fen << (ep_square() == SQ_NONE ? " -" : " " + square_to_string(ep_square()))
- << " " << st->rule50 << " " << fullMoves;
+ << " " << st->rule50 << " " << 1 + (st->gamePly - int(sideToMove == BLACK)) / 2;
return fen.str();
}
}
-/// Position::do_setup_move() makes a permanent move on the board. It should
-/// be used when setting up a position on board. You can't undo the move.
-
-void Position::do_setup_move(Move m, StateInfo& newSt) {
-
- assert(move_is_ok(m));
-
- // Update the number of full moves after black's move
- if (sideToMove == BLACK)
- fullMoves++;
-
- do_move(m, newSt);
-
- assert(is_ok());
-}
-
-
/// Position::do_move() makes a move, and saves all information necessary
/// to a StateInfo object. The move is assumed to be legal. Pseudo-legal
/// moves should be filtered out before this function is called.
castleRightsMask[sq] = ALL_CASTLES;
}
sideToMove = WHITE;
- fullMoves = 1;
nodes = 0;
}
// Draw by repetition?
if (!SkipRepetition)
{
- int i = 4, e = Min(Min(st->gamePly, st->rule50), st->pliesFromNull);
+ int i = 4, e = Min(st->rule50, st->pliesFromNull);
if (i <= e)
{
bool pawn_is_passed(Color c, Square s) const;
// Doing and undoing moves
- void do_setup_move(Move m, StateInfo& st);
void do_move(Move m, StateInfo& st);
void do_move(Move m, StateInfo& st, const CheckInfo& ci, bool moveIsCheck);
void undo_move(Move m);
template<bool SkipRepetition> bool is_draw() const;
// Number of plies from starting position
- int startpos_ply_counter() const;
+ int game_ply() const;
// Other properties of the position
bool opposite_colored_bishops() const;
StateInfo startState;
int64_t nodes;
Color sideToMove;
- int fullMoves;
int threadID;
StateInfo* st;
int chess960;
&& pawn_is_passed(c, move_to(m));
}
-inline int Position::startpos_ply_counter() const {
- return Max(2 * (fullMoves - 1), 0) + int(sideToMove == BLACK);
+inline int Position::game_ply() const {
+ return st->gamePly;
}
inline bool Position::opposite_colored_bishops() const {
NodesSincePoll = 0;
current_search_time(get_system_time());
Limits = limits;
- TimeMgr.init(Limits, pos.startpos_ply_counter());
+ TimeMgr.init(Limits, pos.game_ply());
// Set output steram in normal or chess960 mode
cout << set960(pos.is_chess960());
}
else return;
- // Parse move list (if any)
SetupState.clear();
+ // Parse move list (if any)
while (up >> token && (m = move_from_uci(pos, token)) != MOVE_NONE)
{
SetupState.push_back(StateInfo());
- pos.do_setup_move(m, SetupState.back());
+ pos.do_move(m, SetupState.back());
}
}