summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1b0fee9)
We store it now in the same UndoInfo struct as 'previous'
field, so when doing a move we also know where to get
the previous info when undoing the back the move.
This is needed for future patches and is a nice cleanup anyway.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
// captured piece, which is taken care of later.
u = undoInfoUnion;
u.capture = NO_PIECE_TYPE;
// captured piece, which is taken care of later.
u = undoInfoUnion;
u.capture = NO_PIECE_TYPE;
// Save the current key to the history[] array, in order to be able to
// detect repetition draws.
// Save the current key to the history[] array, in order to be able to
// detect repetition draws.
if (move_is_castle(m))
do_castle_move(m);
else if (move_promotion(m))
if (move_is_castle(m))
do_castle_move(m);
else if (move_promotion(m))
- do_promotion_move(m, u);
else if (move_is_ep(m))
do_ep_move(m);
else
else if (move_is_ep(m))
do_ep_move(m);
else
/// UndoInfo object, which has been initialized in Position::do_move, is
/// used to store the captured piece (if any).
/// UndoInfo object, which has been initialized in Position::do_move, is
/// used to store the captured piece (if any).
-void Position::do_promotion_move(Move m, UndoInfo &u) {
+void Position::do_promotion_move(Move m) {
Color us, them;
Square from, to;
Color us, them;
Square from, to;
+ previous->capture = capture;
do_capture_move(m, capture, them, to);
}
do_capture_move(m, capture, them, to);
}
/// important that Position::undo_move is called with the same move and UndoInfo
/// object as the earlier call to Position::do_move.
/// important that Position::undo_move is called with the same move and UndoInfo
/// object as the earlier call to Position::do_move.
-void Position::undo_move(Move m, const UndoInfo &u) {
+void Position::undo_move(Move m) {
assert(is_ok());
assert(move_is_ok(m));
assert(is_ok());
assert(move_is_ok(m));
// Restore information from our UndoInfo object (except the captured piece,
// which is taken care of later)
// Restore information from our UndoInfo object (except the captured piece,
// which is taken care of later)
+ undoInfoUnion = *previous;
if (move_is_castle(m))
undo_castle_move(m);
else if (move_promotion(m))
if (move_is_castle(m))
undo_castle_move(m);
else if (move_promotion(m))
- undo_promotion_move(m, u);
+ undo_promotion_move(m);
else if (move_is_ep(m))
undo_ep_move(m);
else
{
Color us, them;
Square from, to;
else if (move_is_ep(m))
undo_ep_move(m);
else
{
Color us, them;
Square from, to;
- PieceType piece, capture;
us = side_to_move();
them = opposite_color(us);
us = side_to_move();
them = opposite_color(us);
pieceList[us][piece][index[to]] = from;
index[from] = index[to];
pieceList[us][piece][index[to]] = from;
index[from] = index[to];
if (capture)
{
assert(capture != KING);
if (capture)
{
assert(capture != KING);
/// function. The UndoInfo object, which has been initialized in
/// Position::do_move, is used to put back the captured piece (if any).
/// function. The UndoInfo object, which has been initialized in
/// Position::do_move, is used to put back the captured piece (if any).
-void Position::undo_promotion_move(Move m, const UndoInfo &u) {
+void Position::undo_promotion_move(Move m) {
Color us, them;
Square from, to;
Color us, them;
Square from, to;
- PieceType capture, promotion;
assert(move_is_ok(m));
assert(move_promotion(m));
assert(move_is_ok(m));
assert(move_promotion(m));
pieceCount[us][promotion]--;
pieceCount[us][PAWN]++;
pieceCount[us][promotion]--;
pieceCount[us][PAWN]++;
if (capture)
{
assert(capture != KING);
if (capture)
{
assert(capture != KING);
epSquare = SQ_NONE;
rule50 = 0;
gamePly = 0;
epSquare = SQ_NONE;
rule50 = 0;
gamePly = 0;
if (is_mate())
result = true;
if (is_mate())
result = true;
- undo_move(mlist[i].move, u2);
+ undo_move(mlist[i].move);
}
// Undo null move, if necessary
}
// Undo null move, if necessary
Move lastMove;
Value mgValue, egValue;
PieceType capture;
Move lastMove;
Value mgValue, egValue;
PieceType capture;
// Doing and undoing moves
void do_move(Move m, UndoInfo &u);
// Doing and undoing moves
void do_move(Move m, UndoInfo &u);
- void undo_move(Move m, const UndoInfo &u);
+ void undo_move(Move m);
void do_null_move(UndoInfo &u);
void undo_null_move(const UndoInfo &u);
void do_null_move(UndoInfo &u);
void undo_null_move(const UndoInfo &u);
// Helper functions for doing and undoing moves
void do_capture_move(Move m, PieceType capture, Color them, Square to);
void do_castle_move(Move m);
// Helper functions for doing and undoing moves
void do_capture_move(Move m, PieceType capture, Color them, Square to);
void do_castle_move(Move m);
- void do_promotion_move(Move m, UndoInfo &u);
+ void do_promotion_move(Move m);
void do_ep_move(Move m);
void undo_castle_move(Move m);
void do_ep_move(Move m);
void undo_castle_move(Move m);
- void undo_promotion_move(Move m, const UndoInfo &u);
+ void undo_promotion_move(Move m);
void undo_ep_move(Move m);
void find_checkers();
void undo_ep_move(Move m);
void find_checkers();
Move lastMove;
Value mgValue, egValue;
PieceType capture;
Move lastMove;
Value mgValue, egValue;
PieceType capture;
- pos.undo_move(move, u);
// Finished searching the move. If AbortSearch is true, the search
// was aborted because the user interrupted the search or because we
// Finished searching the move. If AbortSearch is true, the search
// was aborted because the user interrupted the search or because we
- pos.undo_move(move, u);
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
ss[ply].reduction = Depth(0);
value = -search(pos, ss, -(beta-1), newDepth, ply+1, true, threadID);
}
ss[ply].reduction = Depth(0);
value = -search(pos, ss, -(beta-1), newDepth, ply+1, true, threadID);
}
- pos.undo_move(move, u);
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
UndoInfo u;
pos.do_move(move, u);
Value value = -qsearch(pos, ss, -beta, -alpha, depth-OnePly, ply+1, threadID);
UndoInfo u;
pos.do_move(move, u);
Value value = -qsearch(pos, ss, -beta, -alpha, depth-OnePly, ply+1, threadID);
- pos.undo_move(move, u);
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
ss[sp->ply].reduction = Depth(0);
value = -search(pos, ss, -(sp->beta - 1), newDepth, sp->ply+1, true, threadID);
}
ss[sp->ply].reduction = Depth(0);
value = -search(pos, ss, -(sp->beta - 1), newDepth, sp->ply+1, true, threadID);
}
- pos.undo_move(move, u);
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
Threads[threadID].failHighPly1 = false;
}
}
Threads[threadID].failHighPly1 = false;
}
}
- pos.undo_move(move, u);
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
pos.do_move(moves[count].move, u);
moves[count].score = -qsearch(pos, ss, -VALUE_INFINITE, VALUE_INFINITE,
Depth(0), 1, 0);
pos.do_move(moves[count].move, u);
moves[count].score = -qsearch(pos, ss, -VALUE_INFINITE, VALUE_INFINITE,
Depth(0), 1, 0);
- pos.undo_move(moves[count].move, u);
+ pos.undo_move(moves[count].move);
moves[count].pv[0] = moves[i].move;
moves[count].pv[1] = MOVE_NONE; // FIXME
count++;
moves[count].pv[0] = moves[i].move;
moves[count].pv[1] = MOVE_NONE; // FIXME
count++;