Io rework #15
No files matched your search
+12
-2
@@ -58,8 +58,18 @@ void Board::SetByFen(std::string_view fen) {
|
|||||||
|
|
||||||
sideToMove = tokens[1] == "b";
|
sideToMove = tokens[1] == "b";
|
||||||
|
|
||||||
occupied = colors[White] | colors[Black];
|
for (const char piece : tokens[2]) {
|
||||||
hashKey = GetHashKey(*this);
|
if (piece == 'K') castlingRights |= whiteKingRight;
|
||||||
|
else if (piece == 'Q') castlingRights |= whiteQueenRight;
|
||||||
|
else if (piece == 'k') castlingRights |= blackKingRight;
|
||||||
|
else if (piece == 'q') castlingRights |= blackQueenRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tokens[3] != "-") enPassantTarget = parseSquare(tokens[3]);
|
||||||
|
|
||||||
|
occupied = colors[White] | colors[Black];
|
||||||
|
hashKey = GetHashKey(*this);
|
||||||
|
GenAttackMaps(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Board::PrintBoard() {
|
void Board::PrintBoard() {
|
||||||
|
|||||||
@@ -17,3 +17,12 @@ std::vector<std::string> split(std::string_view str, char delim) {
|
|||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int parseSquare(std::string_view str) {
|
||||||
|
constexpr std::string_view files = "abcdefgh";
|
||||||
|
|
||||||
|
int file = files.find(str[0]);
|
||||||
|
int rank = str[1] - '0';
|
||||||
|
|
||||||
|
return file + rank * 8;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user