for (size_t i = 0; i < fens.size(); ++i)
{
- StateListPtr states(new std::vector<StateInfo>(1));
+ StateListPtr states(new std::deque<StateInfo>(1));
pos.set(fens[i], Options["UCI_Chess960"], &states->back(), Threads.main());
cerr << "\nPosition: " << i + 1 << '/' << fens.size() << endl;
#include <cassert>
#include <cstddef> // For offsetof()
+#include <deque>
#include <memory> // For std::unique_ptr
#include <string>
#include <vector>
StateInfo* previous;
};
-typedef std::unique_ptr<std::vector<StateInfo>> StateListPtr;
+// In a std::deque references to elements are unaffected upon resizing
+typedef std::unique_ptr<std::deque<StateInfo>> StateListPtr;
/// Position class stores information regarding the board representation as
if (states.get())
setupStates = std::move(states); // Ownership transfer, states is now empty
+ StateInfo tmp = setupStates->back();
+
for (Thread* th : Threads)
{
th->maxPly = 0;
th->rootPos.set(pos.fen(), pos.is_chess960(), &setupStates->back(), th);
}
+ setupStates->back() = tmp; // Restore st->previous, cleared by Position::set()
+
main()->start_searching();
}
// A list to keep track of the position states along the setup moves (from the
// start position to the position just before the search starts). Needed by
// 'draw by repetition' detection.
- StateListPtr States(new std::vector<StateInfo>(1));
+ StateListPtr States(new std::deque<StateInfo>(1));
// position() is called when engine receives the "position" UCI command.
else
return;
- States = StateListPtr(new std::vector<StateInfo>(1));
+ States = StateListPtr(new std::deque<StateInfo>(1));
pos.set(fen, Options["UCI_Chess960"], &States->back(), Threads.main());
// Parse move list (if any)