fixed parseMove | bench 4118297
This commit is contained in:
1 parent
73ce2aef55
commit
41fed91fc2
3 files changed
+21
-1
No files matched your search
@@ -69,6 +69,7 @@ void Board::SetByFen(std::string_view fen) {
|
|||||||
|
|
||||||
occupied = colors[White] | colors[Black];
|
occupied = colors[White] | colors[Black];
|
||||||
hashKey = GetHashKey(*this);
|
hashKey = GetHashKey(*this);
|
||||||
|
GenerateMoves(*this, sideToMove);
|
||||||
GenAttackMaps(*this);
|
GenAttackMaps(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +138,7 @@ void Board::ListMoves() {
|
|||||||
for (int i = 0; i < currentMoveIndex; i++) {
|
for (int i = 0; i < currentMoveIndex; i++) {
|
||||||
std::cout << i+1 << ". ";
|
std::cout << i+1 << ". ";
|
||||||
moveList[i].PrintMove();
|
moveList[i].PrintMove();
|
||||||
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-1
@@ -34,6 +34,9 @@ void ParsePosition(Board &board, std::string_view command) {
|
|||||||
board.MakeMove(parseMove(board, move));
|
board.MakeMove(parseMove(board, move));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GenerateMoves(board, board.sideToMove);
|
||||||
|
GenAttackMaps(board);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ReadParam(std::string param, std::string &command) {
|
static int ReadParam(std::string param, std::string &command) {
|
||||||
@@ -102,7 +105,7 @@ void UCILoop(Board &board) {
|
|||||||
|
|
||||||
// parse UCI "position" command
|
// parse UCI "position" command
|
||||||
if (input.find("position") != std::string::npos) {
|
if (input.find("position") != std::string::npos) {
|
||||||
ParsePosition(board, input.c_str());
|
ParsePosition(board, input);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,5 +162,10 @@ void UCILoop(Board &board) {
|
|||||||
board.PrintBoard();
|
board.PrintBoard();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (input.find("listmoves") != std::string::npos) {
|
||||||
|
board.ListMoves();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "movegen.h"
|
||||||
|
|
||||||
std::vector<std::string> split(std::string_view str, char delim) {
|
std::vector<std::string> split(std::string_view str, char delim) {
|
||||||
std::vector<std::string> results;
|
std::vector<std::string> results;
|
||||||
@@ -24,6 +25,8 @@ int parseSquare(std::string_view str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Move parseMove(Board &board, std::string_view str) {
|
Move parseMove(Board &board, std::string_view str) {
|
||||||
|
GenerateMoves(board, board.sideToMove);
|
||||||
|
|
||||||
int from = parseSquare(str.substr(0, 2));
|
int from = parseSquare(str.substr(0, 2));
|
||||||
int to = parseSquare(str.substr(2, 2));
|
int to = parseSquare(str.substr(2, 2));
|
||||||
|
|
||||||
@@ -62,6 +65,13 @@ Move parseMove(Board &board, std::string_view str) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (Move move : board.moveList) {
|
||||||
|
if (move.MoveFrom() == from && move.MoveTo() == to) {
|
||||||
|
flag = move.GetFlags();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Move(from, to, flag);
|
return Move(from, to, flag);
|
||||||
|
|||||||
Reference in new issue
Block a user