bugfix in parseSquare + rewrote parseMove
This commit is contained in:
1 parent
7fb413fb01
commit
842cb45f38
4 files changed
+75
-98
No files matched your search
+5
-20
@@ -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);
|
||||
Reference in new issue
Block a user