mirror of
https://github.com/sockspls/badfish
synced 2025-07-12 03:59:15 +00:00
In Position backup and restore contiguous data
Give the compiler one more chance to optimize the copy. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
9e1d142fdd
commit
95cfc0e306
2 changed files with 40 additions and 40 deletions
|
@ -678,24 +678,23 @@ bool Position::move_is_capture(Move m) const {
|
||||||
|
|
||||||
void Position::backup(UndoInfo& u) const {
|
void Position::backup(UndoInfo& u) const {
|
||||||
|
|
||||||
u.castleRights = castleRights;
|
|
||||||
u.epSquare = epSquare;
|
|
||||||
u.checkersBB = checkersBB;
|
|
||||||
u.key = key;
|
|
||||||
u.pawnKey = pawnKey;
|
|
||||||
u.materialKey = materialKey;
|
|
||||||
u.rule50 = rule50;
|
|
||||||
u.lastMove = lastMove;
|
|
||||||
u.mgValue = mgValue;
|
|
||||||
u.egValue = egValue;
|
|
||||||
u.capture = NO_PIECE_TYPE;
|
|
||||||
|
|
||||||
for (Color c = WHITE; c <= BLACK; c++)
|
for (Color c = WHITE; c <= BLACK; c++)
|
||||||
{
|
{
|
||||||
u.pinners[c] = pinners[c];
|
u.pinners[c] = pinners[c];
|
||||||
u.pinned[c] = pinned[c];
|
u.pinned[c] = pinned[c];
|
||||||
u.dcCandidates[c] = dcCandidates[c];
|
u.dcCandidates[c] = dcCandidates[c];
|
||||||
}
|
}
|
||||||
|
u.checkersBB = checkersBB;
|
||||||
|
u.key = key;
|
||||||
|
u.pawnKey = pawnKey;
|
||||||
|
u.materialKey = materialKey;
|
||||||
|
u.castleRights = castleRights;
|
||||||
|
u.rule50 = rule50;
|
||||||
|
u.epSquare = epSquare;
|
||||||
|
u.lastMove = lastMove;
|
||||||
|
u.mgValue = mgValue;
|
||||||
|
u.egValue = egValue;
|
||||||
|
u.capture = NO_PIECE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -704,24 +703,23 @@ void Position::backup(UndoInfo& u) const {
|
||||||
|
|
||||||
void Position::restore(const UndoInfo& u) {
|
void Position::restore(const UndoInfo& u) {
|
||||||
|
|
||||||
castleRights = u.castleRights;
|
|
||||||
epSquare = u.epSquare;
|
|
||||||
checkersBB = u.checkersBB;
|
|
||||||
key = u.key;
|
|
||||||
pawnKey = u.pawnKey;
|
|
||||||
materialKey = u.materialKey;
|
|
||||||
rule50 = u.rule50;
|
|
||||||
lastMove = u.lastMove;
|
|
||||||
mgValue = u.mgValue;
|
|
||||||
egValue = u.egValue;
|
|
||||||
// u.capture is restored in undo_move()
|
|
||||||
|
|
||||||
for (Color c = WHITE; c <= BLACK; c++)
|
for (Color c = WHITE; c <= BLACK; c++)
|
||||||
{
|
{
|
||||||
pinners[c] = u.pinners[c];
|
pinners[c] = u.pinners[c];
|
||||||
pinned[c] = u.pinned[c];
|
pinned[c] = u.pinned[c];
|
||||||
dcCandidates[c] = u.dcCandidates[c];
|
dcCandidates[c] = u.dcCandidates[c];
|
||||||
}
|
}
|
||||||
|
checkersBB = u.checkersBB;
|
||||||
|
key = u.key;
|
||||||
|
pawnKey = u.pawnKey;
|
||||||
|
materialKey = u.materialKey;
|
||||||
|
castleRights = u.castleRights;
|
||||||
|
rule50 = u.rule50;
|
||||||
|
epSquare = u.epSquare;
|
||||||
|
lastMove = u.lastMove;
|
||||||
|
mgValue = u.mgValue;
|
||||||
|
egValue = u.egValue;
|
||||||
|
// u.capture is restored in undo_move()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -80,11 +80,10 @@ enum CastleRights {
|
||||||
/// Position::undo_move), the same UndoInfo object must be passed again.
|
/// Position::undo_move), the same UndoInfo object must be passed again.
|
||||||
|
|
||||||
struct UndoInfo {
|
struct UndoInfo {
|
||||||
int castleRights;
|
Bitboard pinners[2], pinned[2], dcCandidates[2], checkersBB;
|
||||||
Square epSquare;
|
|
||||||
Bitboard checkersBB, pinners[2], pinned[2], dcCandidates[2];
|
|
||||||
Key key, pawnKey, materialKey;
|
Key key, pawnKey, materialKey;
|
||||||
int rule50;
|
int castleRights, rule50;
|
||||||
|
Square epSquare;
|
||||||
Move lastMove;
|
Move lastMove;
|
||||||
Value mgValue, egValue;
|
Value mgValue, egValue;
|
||||||
PieceType capture;
|
PieceType capture;
|
||||||
|
@ -326,8 +325,6 @@ private:
|
||||||
|
|
||||||
// Bitboards
|
// Bitboards
|
||||||
Bitboard byColorBB[2], byTypeBB[8];
|
Bitboard byColorBB[2], byTypeBB[8];
|
||||||
Bitboard checkersBB;
|
|
||||||
mutable Bitboard pinners[2], pinned[2], dcCandidates[2];
|
|
||||||
|
|
||||||
// Board
|
// Board
|
||||||
Piece board[64];
|
Piece board[64];
|
||||||
|
@ -340,16 +337,21 @@ private:
|
||||||
int index[64];
|
int index[64];
|
||||||
|
|
||||||
// Other info
|
// Other info
|
||||||
Color sideToMove;
|
|
||||||
int castleRights;
|
|
||||||
File initialKFile, initialKRFile, initialQRFile;
|
|
||||||
Square epSquare;
|
|
||||||
Square kingSquare[2];
|
Square kingSquare[2];
|
||||||
Move lastMove;
|
Color sideToMove;
|
||||||
Key key, pawnKey, materialKey, history[MaxGameLength];
|
int gamePly;
|
||||||
int rule50, gamePly;
|
Key history[MaxGameLength];
|
||||||
Value mgValue, egValue;
|
|
||||||
Value npMaterial[2];
|
Value npMaterial[2];
|
||||||
|
File initialKFile, initialKRFile, initialQRFile;
|
||||||
|
|
||||||
|
// Info backed up in do_move()
|
||||||
|
mutable Bitboard pinners[2], pinned[2], dcCandidates[2];
|
||||||
|
Bitboard checkersBB;
|
||||||
|
Key key, pawnKey, materialKey;
|
||||||
|
int castleRights, rule50;
|
||||||
|
Square epSquare;
|
||||||
|
Move lastMove;
|
||||||
|
Value mgValue, egValue;
|
||||||
|
|
||||||
// Static variables
|
// Static variables
|
||||||
static int castleRightsMask[64];
|
static int castleRightsMask[64];
|
||||||
|
|
Loading…
Add table
Reference in a new issue