bb: Fix crash after mirror/turn/rotate

This commit is contained in:
Calcitem 2020-12-22 00:24:20 +08:00
parent a1f4832fe0
commit 974872e226
2 changed files with 20 additions and 0 deletions

View File

@ -1837,6 +1837,18 @@ void Position::print_board()
} }
} }
void Position::reset_bb()
{
memset(byTypeBB, 0, sizeof(byTypeBB));
memset(byColorBB, 0, sizeof(byColorBB));
for (Square s = SQ_BEGIN; s < SQ_END; ++s) {
Piece pc = board[s];
byTypeBB[ALL_PIECES] |= byTypeBB[type_of(pc)] |= s;
byColorBB[color_of(pc)] |= s;
}
}
void Position::mirror(vector <string> &cmdlist, bool cmdChange /*= true*/) void Position::mirror(vector <string> &cmdlist, bool cmdChange /*= true*/)
{ {
Piece ch; Piece ch;
@ -1851,6 +1863,8 @@ void Position::mirror(vector <string> &cmdlist, bool cmdChange /*= true*/)
} }
} }
reset_bb();
uint64_t llp[3] = { 0 }; uint64_t llp[3] = { 0 };
if (move < 0) { if (move < 0) {
@ -1956,6 +1970,8 @@ void Position::turn(vector <string> &cmdlist, bool cmdChange /*= true*/)
board[RANK_NB * FILE_NB + r] = ch; board[RANK_NB * FILE_NB + r] = ch;
} }
reset_bb();
uint64_t llp[3] = { 0 }; uint64_t llp[3] = { 0 };
if (move < 0) { if (move < 0) {
@ -2156,6 +2172,8 @@ void Position::rotate(vector <string> &cmdlist, int degrees, bool cmdChange /*=
return; return;
} }
reset_bb();
uint64_t llp[3] = { 0 }; uint64_t llp[3] = { 0 };
if (move < 0) { if (move < 0) {

View File

@ -129,6 +129,8 @@ public:
void turn(std::vector <std::string> &cmdlist, bool cmdChange = true); void turn(std::vector <std::string> &cmdlist, bool cmdChange = true);
void rotate(std::vector <std::string> &cmdlist, int degrees, bool cmdChange = true); void rotate(std::vector <std::string> &cmdlist, int degrees, bool cmdChange = true);
void reset_bb();
void create_mill_table(); void create_mill_table();
int add_mills(Square s); int add_mills(Square s);
int in_how_many_mills(Square s, Color c, Square squareSelected = SQ_0); int in_how_many_mills(Square s, Color c, Square squareSelected = SQ_0);