mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Don't update gamePly after each move
We just need startup value to calculate available thinking time. So remove from state. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
527a2ec541
commit
03ad183384
4 changed files with 16 additions and 18 deletions
|
@ -190,11 +190,11 @@ void Position::from_fen(const string& fenStr, bool isChess960) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5-6. Halfmove clock and fullmove number
|
// 5-6. Halfmove clock and fullmove number
|
||||||
fen >> std::skipws >> st->rule50 >> st->gamePly;
|
fen >> std::skipws >> st->rule50 >> startPosPly;
|
||||||
|
|
||||||
// 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.
|
||||||
st->gamePly = Max(2 * (st->gamePly - 1), 0) + int(sideToMove == BLACK);
|
startPosPly = Max(2 * (startPosPly - 1), 0) + int(sideToMove == BLACK);
|
||||||
|
|
||||||
// Various initialisations
|
// Various initialisations
|
||||||
chess960 = isChess960;
|
chess960 = isChess960;
|
||||||
|
@ -314,7 +314,7 @@ const string Position::to_fen() const {
|
||||||
fen << '-';
|
fen << '-';
|
||||||
|
|
||||||
fen << (ep_square() == SQ_NONE ? " -" : " " + square_to_string(ep_square()))
|
fen << (ep_square() == SQ_NONE ? " -" : " " + square_to_string(ep_square()))
|
||||||
<< " " << st->rule50 << " " << 1 + (st->gamePly - int(sideToMove == BLACK)) / 2;
|
<< " " << st->rule50 << " " << 1 + (startPosPly - int(sideToMove == BLACK)) / 2;
|
||||||
|
|
||||||
return fen.str();
|
return fen.str();
|
||||||
}
|
}
|
||||||
|
@ -786,10 +786,10 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
||||||
// pointer to point to the new, ready to be updated, state.
|
// pointer to point to the new, ready to be updated, state.
|
||||||
struct ReducedStateInfo {
|
struct ReducedStateInfo {
|
||||||
Key pawnKey, materialKey;
|
Key pawnKey, materialKey;
|
||||||
int castleRights, rule50, gamePly, pliesFromNull;
|
|
||||||
Square epSquare;
|
|
||||||
Score value;
|
|
||||||
Value npMaterial[2];
|
Value npMaterial[2];
|
||||||
|
int castleRights, rule50, pliesFromNull;
|
||||||
|
Score value;
|
||||||
|
Square epSquare;
|
||||||
};
|
};
|
||||||
|
|
||||||
memcpy(&newSt, st, sizeof(ReducedStateInfo));
|
memcpy(&newSt, st, sizeof(ReducedStateInfo));
|
||||||
|
@ -803,7 +803,6 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
||||||
// Increment the 50 moves rule draw counter. Resetting it to zero in the
|
// Increment the 50 moves rule draw counter. Resetting it to zero in the
|
||||||
// case of non-reversible moves is taken care of later.
|
// case of non-reversible moves is taken care of later.
|
||||||
st->rule50++;
|
st->rule50++;
|
||||||
st->gamePly++;
|
|
||||||
st->pliesFromNull++;
|
st->pliesFromNull++;
|
||||||
|
|
||||||
if (move_is_castle(m))
|
if (move_is_castle(m))
|
||||||
|
@ -1339,7 +1338,6 @@ void Position::do_null_move(StateInfo& backupSt) {
|
||||||
sideToMove = opposite_color(sideToMove);
|
sideToMove = opposite_color(sideToMove);
|
||||||
st->epSquare = SQ_NONE;
|
st->epSquare = SQ_NONE;
|
||||||
st->rule50++;
|
st->rule50++;
|
||||||
st->gamePly++;
|
|
||||||
st->pliesFromNull = 0;
|
st->pliesFromNull = 0;
|
||||||
st->value += (sideToMove == WHITE) ? TempoValue : -TempoValue;
|
st->value += (sideToMove == WHITE) ? TempoValue : -TempoValue;
|
||||||
|
|
||||||
|
@ -1364,7 +1362,6 @@ void Position::undo_null_move() {
|
||||||
// Update the necessary information
|
// Update the necessary information
|
||||||
sideToMove = opposite_color(sideToMove);
|
sideToMove = opposite_color(sideToMove);
|
||||||
st->rule50--;
|
st->rule50--;
|
||||||
st->gamePly--;
|
|
||||||
|
|
||||||
assert(is_ok());
|
assert(is_ok());
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,10 +48,10 @@ class Position;
|
||||||
|
|
||||||
struct StateInfo {
|
struct StateInfo {
|
||||||
Key pawnKey, materialKey;
|
Key pawnKey, materialKey;
|
||||||
int castleRights, rule50, gamePly, pliesFromNull;
|
|
||||||
Square epSquare;
|
|
||||||
Score value;
|
|
||||||
Value npMaterial[2];
|
Value npMaterial[2];
|
||||||
|
int castleRights, rule50, pliesFromNull;
|
||||||
|
Score value;
|
||||||
|
Square epSquare;
|
||||||
|
|
||||||
Key key;
|
Key key;
|
||||||
Bitboard checkersBB;
|
Bitboard checkersBB;
|
||||||
|
@ -188,8 +188,8 @@ public:
|
||||||
bool is_mate() const;
|
bool is_mate() const;
|
||||||
template<bool SkipRepetition> bool is_draw() const;
|
template<bool SkipRepetition> bool is_draw() const;
|
||||||
|
|
||||||
// Number of plies from starting position
|
// Plies from start position to the beginning of search
|
||||||
int game_ply() const;
|
int startpos_ply_counter() const;
|
||||||
|
|
||||||
// Other properties of the position
|
// Other properties of the position
|
||||||
bool opposite_colored_bishops() const;
|
bool opposite_colored_bishops() const;
|
||||||
|
@ -255,6 +255,7 @@ private:
|
||||||
Square castleRookSquare[16]; // [castleRight]
|
Square castleRookSquare[16]; // [castleRight]
|
||||||
StateInfo startState;
|
StateInfo startState;
|
||||||
int64_t nodes;
|
int64_t nodes;
|
||||||
|
int startPosPly;
|
||||||
Color sideToMove;
|
Color sideToMove;
|
||||||
int threadID;
|
int threadID;
|
||||||
StateInfo* st;
|
StateInfo* st;
|
||||||
|
@ -421,8 +422,8 @@ inline bool Position::move_is_passed_pawn_push(Move m) const {
|
||||||
&& pawn_is_passed(c, move_to(m));
|
&& pawn_is_passed(c, move_to(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int Position::game_ply() const {
|
inline int Position::startpos_ply_counter() const {
|
||||||
return st->gamePly;
|
return startPosPly;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Position::opposite_colored_bishops() const {
|
inline bool Position::opposite_colored_bishops() const {
|
||||||
|
|
|
@ -393,7 +393,7 @@ bool think(Position& pos, const SearchLimits& limits, Move searchMoves[]) {
|
||||||
NodesSincePoll = 0;
|
NodesSincePoll = 0;
|
||||||
current_search_time(get_system_time());
|
current_search_time(get_system_time());
|
||||||
Limits = limits;
|
Limits = limits;
|
||||||
TimeMgr.init(Limits, pos.game_ply());
|
TimeMgr.init(Limits, pos.startpos_ply_counter());
|
||||||
|
|
||||||
// Set output steram in normal or chess960 mode
|
// Set output steram in normal or chess960 mode
|
||||||
cout << set960(pos.is_chess960());
|
cout << set960(pos.is_chess960());
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace {
|
||||||
|
|
||||||
// Keep track of position keys along the setup moves (from start position to the
|
// Keep track of position keys along the setup moves (from start position to the
|
||||||
// position just before to start searching). This is needed by draw detection.
|
// position just before to start searching). This is needed by draw detection.
|
||||||
std::vector<StateInfo> SetupState;
|
std::vector<StateInfo> SetupState(200, StateInfo());
|
||||||
|
|
||||||
// UCIParser is a class for parsing UCI input. The class
|
// UCIParser is a class for parsing UCI input. The class
|
||||||
// is actually a string stream built on a given input string.
|
// is actually a string stream built on a given input string.
|
||||||
|
|
Loading…
Add table
Reference in a new issue