Introduce StateInfo instead of UndoInfo

We don't backup anymore but use the renamed StateInfo
argument passed in do_move() to store the new position
state when doing a move.

Backup is now just revert to previous StateInfo that we know
because we store a pointer to it.
Note that now backing store is up to the caller, Position is
stateless in that regard, state is accessed through a pointer.

This patch will let us remove all the backup/restore copying,
just a pointer switch is now necessary.

Note that do_null_move() still uses StateInfo as backup.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2009-02-22 20:16:21 +01:00
parent 2f6c5f00e6
commit 8f59de48f5
6 changed files with 255 additions and 280 deletions

View File

@@ -119,9 +119,9 @@ const std::string move_to_san(const Position& pos, Move m) {
// Is the move check? We don't use pos.move_is_check(m) here, because
// Position::move_is_check doesn't detect all checks (not castling moves,
// promotions and en passant captures).
UndoInfo u;
StateInfo st;
Position p(pos);
p.do_move(m, u);
p.do_move(m, st);
if (p.is_check())
san += p.is_mate()? "#" : "+";
@@ -290,7 +290,7 @@ Move move_from_san(const Position& pos, const std::string& movestr) {
const std::string line_to_san(const Position& pos, Move line[], int startColumn, bool breakLines) {
UndoInfo u;
StateInfo st;
std::stringstream s;
std::string moveStr;
size_t length = 0;
@@ -309,9 +309,9 @@ const std::string line_to_san(const Position& pos, Move line[], int startColumn,
s << moveStr << ' ';
if (line[i] == MOVE_NULL)
p.do_null_move(u);
p.do_null_move(st);
else
p.do_move(line[i], u);
p.do_move(line[i], st);
}
return s.str();
}