]> git.sesse.net Git - stockfish/commit
Document index[] and pieceList[] are not invariants
authorMarco Costalba <mcostalba@gmail.com>
Mon, 31 Aug 2009 08:59:33 +0000 (10:59 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 31 Aug 2009 09:02:28 +0000 (11:02 +0200)
commit97dd7568edf74f8797e152258ebe30ecdc8bac0d
tree19087808cba729ff1c4809367fc34aee60bf1b1a
parentaf220cfd52d95e6b05539036ebf9319131dd469d
Document index[] and pieceList[] are not invariants

Array index[] and pieceList[] are not guaranteed to be
invariant to a do_move() + undo_move() sequence when a
capture move is involved.

The reason is that the captured piece is removed form
the list and substituted with the last one in do_move()
while in undo_move() is added again but at the end of
the list.

Because index[] and pieceList[] are used in move generation
to scan the pieces it means that moves will be generated
in a different order before and after a do_move() + undo_move()
sequence as, for instance, the one in Position::has_mate_threat()

After latest patches, move generation could now be invoked
also by MovePicker c'tor and this explains why order of
picked moves is different if MovePicker object is istantiated
before or after a Position::has_mate_threat() call.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/position.cpp