mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 00:56:39 +08:00
Don't store Thread info in Position
But use the newly introduced local storage for this. A good code semplification and also the correct way to go. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -92,19 +92,17 @@ CheckInfo::CheckInfo(const Position& pos) {
|
||||
}
|
||||
|
||||
|
||||
/// Position::copy() creates a copy of 'pos'. We want the new born Position
|
||||
/// Position::operator=() creates a copy of 'pos'. We want the new born Position
|
||||
/// object do not depend on any external data so we detach state pointer from
|
||||
/// the source one.
|
||||
|
||||
void Position::copy(const Position& pos, Thread* th) {
|
||||
Position& Position::operator=(const Position& pos) {
|
||||
|
||||
memcpy(this, &pos, sizeof(Position));
|
||||
startState = *st;
|
||||
st = &startState;
|
||||
thisThread = th;
|
||||
nodes = 0;
|
||||
|
||||
assert(pos_is_ok());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +110,7 @@ void Position::copy(const Position& pos, Thread* th) {
|
||||
/// string. This function is not very robust - make sure that input FENs are
|
||||
/// correct (this is assumed to be the responsibility of the GUI).
|
||||
|
||||
void Position::from_fen(const string& fenStr, bool isChess960, Thread* th) {
|
||||
void Position::from_fen(const string& fenStr, bool isChess960) {
|
||||
/*
|
||||
A FEN string defines a particular position using only the ASCII character set.
|
||||
|
||||
@@ -228,7 +226,6 @@ void Position::from_fen(const string& fenStr, bool isChess960, Thread* th) {
|
||||
st->npMaterial[BLACK] = compute_non_pawn_material(BLACK);
|
||||
st->checkersBB = attackers_to(king_square(sideToMove)) & pieces(~sideToMove);
|
||||
chess960 = isChess960;
|
||||
thisThread = th;
|
||||
|
||||
assert(pos_is_ok());
|
||||
}
|
||||
@@ -331,7 +328,7 @@ void Position::print(Move move) const {
|
||||
|
||||
if (move)
|
||||
{
|
||||
Position p(*this, thisThread);
|
||||
Position p(*this);
|
||||
cout << "\nMove is: " << (sideToMove == BLACK ? ".." : "") << move_to_san(p, move);
|
||||
}
|
||||
|
||||
@@ -898,8 +895,8 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
||||
}
|
||||
|
||||
// Prefetch pawn and material hash tables
|
||||
prefetch((char*)thisThread->pawnTable.entries[st->pawnKey]);
|
||||
prefetch((char*)thisThread->materialTable.entries[st->materialKey]);
|
||||
prefetch((char*)Threads.this_thread()->pawnTable.entries[st->pawnKey]);
|
||||
prefetch((char*)Threads.this_thread()->materialTable.entries[st->materialKey]);
|
||||
|
||||
// Update incremental scores
|
||||
st->psqScore += psq_delta(piece, from, to);
|
||||
@@ -1541,10 +1538,9 @@ void Position::init() {
|
||||
void Position::flip() {
|
||||
|
||||
// Make a copy of current position before to start changing
|
||||
const Position pos(*this, thisThread);
|
||||
const Position pos(*this);
|
||||
|
||||
clear();
|
||||
thisThread = &pos.this_thread();
|
||||
|
||||
// Board
|
||||
for (Square s = SQ_A1; s <= SQ_H8; s++)
|
||||
|
||||
Reference in New Issue
Block a user