}
-/// 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;
}
/// 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.
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());
}
if (move)
{
- Position p(*this, thisThread);
+ Position p(*this);
cout << "\nMove is: " << (sideToMove == BLACK ? ".." : "") << move_to_san(p, move);
}
}
// 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);
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++)