Skip to content

Commit

Permalink
refactor: improve castling clear
Browse files Browse the repository at this point in the history
  • Loading branch information
Disservin committed Oct 19, 2024
1 parent 87e2158 commit 4a4766f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
11 changes: 1 addition & 10 deletions include/chess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1755,16 +1755,7 @@ class Board {

int clear(Color color, Side castle) {
rooks[color][static_cast<int>(castle)] = File::NO_FILE;

switch (castle) {
case Side::KING_SIDE:
return color == Color::WHITE ? 0 : 2;
case Side::QUEEN_SIDE:
return color == Color::WHITE ? 1 : 3;
default:
assert(false);
return -1;
}
return color * 2 + static_cast<int>(castle);
}

void clear(Color color) { rooks[color].fill(File::NO_FILE); }
Expand Down
11 changes: 1 addition & 10 deletions src/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,7 @@ class Board {

int clear(Color color, Side castle) {
rooks[color][static_cast<int>(castle)] = File::NO_FILE;

switch (castle) {
case Side::KING_SIDE:
return color == Color::WHITE ? 0 : 2;
case Side::QUEEN_SIDE:
return color == Color::WHITE ? 1 : 3;
default:
assert(false);
return -1;
}
return color * 2 + static_cast<int>(castle);
}

void clear(Color color) { rooks[color].fill(File::NO_FILE); }
Expand Down

0 comments on commit 4a4766f

Please sign in to comment.