Io rework #15

Merged
rektdie merged 7 commits from IO_rework into legalMovegen 2025-03-12 19:42:20 +01:00
2 changed files with 21 additions and 2 deletions
Showing only changes of commit ad6ee77a46 - Show all commits

No files matched your search

+12 -2
View File
@@ -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() {
+9
View File
@@ -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;
}