bugfix in parseSquare + rewrote parseMove

This commit is contained in:
rektdie committed 2025-03-12 16:55:36 +01:00
1 parent 7fb413fb01
commit 842cb45f38
4 files changed
+75 -98

No files matched your search

+5 -20
View File
@@ -3,26 +3,11 @@
#include <string>
#include <string_view>
#include <sstream>
#include "move.h"
#include "board.h"
std::vector<std::string> split(std::string_view str, char delim) {
std::vector<std::string> results;
std::vector<std::string> split(std::string_view str, char delim);
std::istringstream stream(std::string{str});
int parseSquare(std::string_view str);
for (std::string token{}; std::getline(stream, token, delim);) {
if (token.empty()) continue;
results.push_back(token);
}
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;
}
Move parseMove(Board &board, std::string_view str);