optimize make routine
This commit is contained in:
parent
c54e2b9e1a
commit
dd9acb7295
18
Board.h
18
Board.h
|
|
@ -135,8 +135,9 @@ void make(Move m) {
|
|||
u.sq_to = m.sq_to;
|
||||
|
||||
byte piece_type = field[m.sq_from] & 0x7;
|
||||
byte color = black_moving();
|
||||
|
||||
if(u.captured || piece_type == W_PAWN) {
|
||||
if(field[m.sq_to] || piece_type == W_PAWN) {
|
||||
field[PTR_REVMOV] = 0;
|
||||
} else {
|
||||
field[PTR_REVMOV]++;
|
||||
|
|
@ -153,7 +154,7 @@ void make(Move m) {
|
|||
// We are castling! After all, a king cannot move
|
||||
// more than one position except when castling.
|
||||
// Since we don't care about legality; just do it
|
||||
byte castle_source = 0x70*black_moving();
|
||||
byte castle_source = (color ? 0x70 : 0x0);
|
||||
if(sq_diff == 2) {
|
||||
castle_source += 0x7;
|
||||
}
|
||||
|
|
@ -164,7 +165,7 @@ void make(Move m) {
|
|||
|
||||
// Handle castling rights
|
||||
// First store the current rights in the unmove
|
||||
byte our_rights = field[PTR_SIDE_AND_CASTLERIGHT] >> (1 + 2*black_moving());
|
||||
byte our_rights = field[PTR_SIDE_AND_CASTLERIGHT] >> (color ? 3 : 1);
|
||||
if(our_rights & 0b10) // kingside allowed
|
||||
u.sq_from |= 0x80;
|
||||
if(our_rights & 0b01) // queenside allowed
|
||||
|
|
@ -192,11 +193,11 @@ void make(Move m) {
|
|||
field[PTR_ENPASSANT] &&
|
||||
piece_type == W_PAWN &&
|
||||
(m.sq_to & 0x7) == (field[PTR_ENPASSANT] & 0x7) &&
|
||||
(m.sq_to & 0x70) == (0x50 - 0x30*black_moving())
|
||||
(m.sq_to & 0x70) == (color ? 0x20 : 0x50)
|
||||
) {
|
||||
// all EP-conditions are met
|
||||
// therefore, delete the EP-vurnerable pawn
|
||||
byte ep_field = m.sq_to - 16 + 32*black_moving();
|
||||
byte ep_field = m.sq_to + (color ? 16 : -16);
|
||||
field[ep_field] = P_EMPTY;
|
||||
// also put information that we did an EP-capture
|
||||
u.sq_to |= 0x08;
|
||||
|
|
@ -217,15 +218,14 @@ void make(Move m) {
|
|||
|
||||
// are we promoting?
|
||||
byte new_val = m.pc_prom & 0b1111;
|
||||
if(new_val != P_EMPTY) {
|
||||
if(m.pc_prom != P_EMPTY) {
|
||||
// promoting; indicate this in the sq_to byte in unmove.
|
||||
field[m.sq_to] = m.pc_prom;
|
||||
u.sq_to |= 0x80;
|
||||
} else {
|
||||
// not promoting; so keep the same piece type
|
||||
new_val = field[m.sq_from];
|
||||
field[m.sq_to] = field[m.sq_from];
|
||||
}
|
||||
// copy or promote our piece.
|
||||
field[m.sq_to] = new_val;
|
||||
// then delete the original copy.
|
||||
field[m.sq_from] = P_EMPTY;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue