mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
Account for gamePly after each move
Rename startPosPly to gamePly and increment/decrement the variable after each do/undo move. This adds a little overhead in do_move() but we will need to have the game ply during the search for the next patches now under test. Currently we don't increment gamePly in do_null_move() becuase it is not needed at the moment. Could change in the future. As a nice side effect we can now remove an hack in startpos_ply_counter(). No functional change.
This commit is contained in:
parent
5a156df719
commit
76caef8ba1
3 changed files with 13 additions and 11 deletions
|
@ -278,11 +278,11 @@ void Position::set(const string& fenStr, bool isChess960, Thread* th) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5-6. Halfmove clock and fullmove number
|
// 5-6. Halfmove clock and fullmove number
|
||||||
ss >> std::skipws >> st->rule50 >> startPosPly;
|
ss >> std::skipws >> st->rule50 >> gamePly;
|
||||||
|
|
||||||
// Convert from fullmove starting from 1 to ply starting from 0,
|
// Convert from fullmove starting from 1 to ply starting from 0,
|
||||||
// handle also common incorrect FEN with fullmove = 0.
|
// handle also common incorrect FEN with fullmove = 0.
|
||||||
startPosPly = std::max(2 * (startPosPly - 1), 0) + int(sideToMove == BLACK);
|
gamePly = std::max(2 * (gamePly - 1), 0) + int(sideToMove == BLACK);
|
||||||
|
|
||||||
st->key = compute_key();
|
st->key = compute_key();
|
||||||
st->pawnKey = compute_pawn_key();
|
st->pawnKey = compute_pawn_key();
|
||||||
|
@ -373,7 +373,7 @@ const string Position::fen() const {
|
||||||
ss << '-';
|
ss << '-';
|
||||||
|
|
||||||
ss << (ep_square() == SQ_NONE ? " - " : " " + square_to_string(ep_square()) + " ")
|
ss << (ep_square() == SQ_NONE ? " - " : " " + square_to_string(ep_square()) + " ")
|
||||||
<< st->rule50 << " " << 1 + (startPosPly - int(sideToMove == BLACK)) / 2;
|
<< st->rule50 << " " << 1 + (gamePly - int(sideToMove == BLACK)) / 2;
|
||||||
|
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
@ -735,8 +735,9 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
||||||
// Update side to move
|
// Update side to move
|
||||||
k ^= Zobrist::side;
|
k ^= Zobrist::side;
|
||||||
|
|
||||||
// Increment the 50 moves rule draw counter. Resetting it to zero in the
|
// Increment ply counters.In particular rule50 will be later reset it to zero
|
||||||
// case of a capture or a pawn move is taken care of later.
|
// in case of a capture or a pawn move.
|
||||||
|
gamePly++;
|
||||||
st->rule50++;
|
st->rule50++;
|
||||||
st->pliesFromNull++;
|
st->pliesFromNull++;
|
||||||
|
|
||||||
|
@ -1054,6 +1055,7 @@ void Position::undo_move(Move m) {
|
||||||
|
|
||||||
// Finally point our state pointer back to the previous state
|
// Finally point our state pointer back to the previous state
|
||||||
st = st->previous;
|
st = st->previous;
|
||||||
|
gamePly--;
|
||||||
|
|
||||||
assert(pos_is_ok());
|
assert(pos_is_ok());
|
||||||
}
|
}
|
||||||
|
@ -1417,7 +1419,7 @@ void Position::flip() {
|
||||||
thisThread = pos.this_thread();
|
thisThread = pos.this_thread();
|
||||||
nodes = pos.nodes_searched();
|
nodes = pos.nodes_searched();
|
||||||
chess960 = pos.is_chess960();
|
chess960 = pos.is_chess960();
|
||||||
startPosPly = pos.startpos_ply_counter();
|
gamePly = pos.game_ply();
|
||||||
|
|
||||||
for (Square s = SQ_A1; s <= SQ_H8; s++)
|
for (Square s = SQ_A1; s <= SQ_H8; s++)
|
||||||
if (!pos.is_empty(s))
|
if (!pos.is_empty(s))
|
||||||
|
|
|
@ -174,7 +174,7 @@ public:
|
||||||
|
|
||||||
// Other properties of the position
|
// Other properties of the position
|
||||||
Color side_to_move() const;
|
Color side_to_move() const;
|
||||||
int startpos_ply_counter() const;
|
int game_ply() const;
|
||||||
bool is_chess960() const;
|
bool is_chess960() const;
|
||||||
Thread* this_thread() const;
|
Thread* this_thread() const;
|
||||||
int64_t nodes_searched() const;
|
int64_t nodes_searched() const;
|
||||||
|
@ -218,7 +218,7 @@ private:
|
||||||
Bitboard castlePath[COLOR_NB][CASTLING_SIDE_NB];
|
Bitboard castlePath[COLOR_NB][CASTLING_SIDE_NB];
|
||||||
StateInfo startState;
|
StateInfo startState;
|
||||||
int64_t nodes;
|
int64_t nodes;
|
||||||
int startPosPly;
|
int gamePly;
|
||||||
Color sideToMove;
|
Color sideToMove;
|
||||||
Thread* thisThread;
|
Thread* thisThread;
|
||||||
StateInfo* st;
|
StateInfo* st;
|
||||||
|
@ -376,8 +376,8 @@ inline bool Position::is_passed_pawn_push(Move m) const {
|
||||||
&& pawn_is_passed(sideToMove, to_sq(m));
|
&& pawn_is_passed(sideToMove, to_sq(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int Position::startpos_ply_counter() const {
|
inline int Position::game_ply() const {
|
||||||
return startPosPly + st->pliesFromNull; // HACK
|
return gamePly;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Position::opposite_bishops() const {
|
inline bool Position::opposite_bishops() const {
|
||||||
|
|
|
@ -182,7 +182,7 @@ void Search::think() {
|
||||||
static PolyglotBook book; // Defined static to initialize the PRNG only once
|
static PolyglotBook book; // Defined static to initialize the PRNG only once
|
||||||
|
|
||||||
RootColor = RootPos.side_to_move();
|
RootColor = RootPos.side_to_move();
|
||||||
TimeMgr.init(Limits, RootPos.startpos_ply_counter(), RootColor);
|
TimeMgr.init(Limits, RootPos.game_ply(), RootColor);
|
||||||
|
|
||||||
if (RootMoves.empty())
|
if (RootMoves.empty())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue