#include <fstream>
#include <iostream>
+#include "bitcount.h"
#include "mersenne.h"
#include "movegen.h"
#include "movepick.h"
/// Position::copy() creates a copy of the input position.
-void Position::copy(const Position &pos) {
+void Position::copy(const Position& pos) {
memcpy(this, &pos, sizeof(Position));
+ saveState(); // detach and copy state info
}
if (pt == KING && stmAttackers)
{
assert(n < 32);
- swapList[n++] = 100;
+ swapList[n++] = QueenValueMidgame*10;
break;
}
} while (stmAttackers);
}
-/// Position::setStartState() copies the content of the argument
+/// Position::saveState() copies the content of the current state
/// inside startState and makes st point to it. This is needed
/// when the st pointee could become stale, as example because
/// the caller is about to going out of scope.
-void Position::setStartState(const StateInfo& s) {
+void Position::saveState() {
- startState = s;
+ startState = *st;
st = &startState;
+ st->previous = NULL; // as a safe guard
}
/// the white and black sides reversed. This is only useful for debugging,
/// especially for finding evaluation symmetry bugs.
-void Position::flipped_copy(const Position &pos) {
+void Position::flipped_copy(const Position& pos) {
assert(pos.is_ok());