mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 09:13:08 +00:00
Don't copy the key in do_move
It will be overwritten anyway. Also other little small touches that seem to increase speed more then the whole enum Score patch series :-( Optimization is really a black art. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
ef6fca98a0
commit
f35ddb04af
2 changed files with 10 additions and 7 deletions
|
@ -718,7 +718,7 @@ void Position::do_move(Move m, StateInfo& newSt, Bitboard dcCandidates) {
|
||||||
// ones which are recalculated from scratch anyway, then switch our state
|
// ones which are recalculated from scratch anyway, then switch our state
|
||||||
// pointer to point to the new, ready to be updated, state.
|
// pointer to point to the new, ready to be updated, state.
|
||||||
struct ReducedStateInfo {
|
struct ReducedStateInfo {
|
||||||
Key key, pawnKey, materialKey;
|
Key pawnKey, materialKey;
|
||||||
int castleRights, rule50, pliesFromNull;
|
int castleRights, rule50, pliesFromNull;
|
||||||
Square epSquare;
|
Square epSquare;
|
||||||
Value value;
|
Value value;
|
||||||
|
@ -758,16 +758,15 @@ void Position::do_move(Move m, StateInfo& newSt, Bitboard dcCandidates) {
|
||||||
|
|
||||||
Piece piece = piece_on(from);
|
Piece piece = piece_on(from);
|
||||||
PieceType pt = type_of_piece(piece);
|
PieceType pt = type_of_piece(piece);
|
||||||
|
PieceType capture = ep ? PAWN : type_of_piece_on(to);
|
||||||
|
|
||||||
assert(color_of_piece_on(from) == us);
|
assert(color_of_piece_on(from) == us);
|
||||||
assert(color_of_piece_on(to) == them || square_is_empty(to));
|
assert(color_of_piece_on(to) == them || square_is_empty(to));
|
||||||
assert(!(ep || pm) || piece == piece_of_color_and_type(us, PAWN));
|
assert(!(ep || pm) || piece == piece_of_color_and_type(us, PAWN));
|
||||||
assert(!pm || relative_rank(us, to) == RANK_8);
|
assert(!pm || relative_rank(us, to) == RANK_8);
|
||||||
|
|
||||||
st->capture = ep ? PAWN : type_of_piece_on(to);
|
if (capture)
|
||||||
|
do_capture_move(key, capture, them, to, ep);
|
||||||
if (st->capture)
|
|
||||||
do_capture_move(key, st->capture, them, to, ep);
|
|
||||||
|
|
||||||
// Update hash key
|
// Update hash key
|
||||||
key ^= zobrist[us][pt][from] ^ zobrist[us][pt][to];
|
key ^= zobrist[us][pt][from] ^ zobrist[us][pt][to];
|
||||||
|
@ -817,7 +816,7 @@ void Position::do_move(Move m, StateInfo& newSt, Bitboard dcCandidates) {
|
||||||
st->pawnKey ^= zobrist[us][PAWN][from] ^ zobrist[us][PAWN][to];
|
st->pawnKey ^= zobrist[us][PAWN][from] ^ zobrist[us][PAWN][to];
|
||||||
|
|
||||||
// Set en passant square, only if moved pawn can be captured
|
// Set en passant square, only if moved pawn can be captured
|
||||||
if (abs(int(to) - int(from)) == 16)
|
if ((to ^ from) == 16)
|
||||||
{
|
{
|
||||||
if (attacks_from<PAWN>(from + (us == WHITE ? DELTA_N : DELTA_S), us) & pieces(PAWN, them))
|
if (attacks_from<PAWN>(from + (us == WHITE ? DELTA_N : DELTA_S), us) & pieces(PAWN, them))
|
||||||
{
|
{
|
||||||
|
@ -830,6 +829,9 @@ void Position::do_move(Move m, StateInfo& newSt, Bitboard dcCandidates) {
|
||||||
// Update incremental scores
|
// Update incremental scores
|
||||||
st->value += pst_delta(piece, from, to);
|
st->value += pst_delta(piece, from, to);
|
||||||
|
|
||||||
|
// Set capture piece
|
||||||
|
st->capture = capture;
|
||||||
|
|
||||||
if (pm) // promotion ?
|
if (pm) // promotion ?
|
||||||
{
|
{
|
||||||
PieceType promotion = move_promotion_piece(m);
|
PieceType promotion = move_promotion_piece(m);
|
||||||
|
|
|
@ -87,12 +87,13 @@ enum Phase {
|
||||||
/// must be passed as a parameter.
|
/// must be passed as a parameter.
|
||||||
|
|
||||||
struct StateInfo {
|
struct StateInfo {
|
||||||
Key key, pawnKey, materialKey;
|
Key pawnKey, materialKey;
|
||||||
int castleRights, rule50, pliesFromNull;
|
int castleRights, rule50, pliesFromNull;
|
||||||
Square epSquare;
|
Square epSquare;
|
||||||
Score value;
|
Score value;
|
||||||
Value npMaterial[2];
|
Value npMaterial[2];
|
||||||
|
|
||||||
|
Key key;
|
||||||
PieceType capture;
|
PieceType capture;
|
||||||
Bitboard checkersBB;
|
Bitboard checkersBB;
|
||||||
StateInfo* previous;
|
StateInfo* previous;
|
||||||
|
|
Loading…
Add table
Reference in a new issue