cleanup | bench 1812688

This commit is contained in:
rektdie committed 2026-02-19 15:12:17 +01:00
1 parent a9b51e384f
commit 320c43cdd3
4 files changed
+17 -16

No files matched your search

+6 -8
View File
@@ -252,11 +252,11 @@ void Board::ResetMoves() {
void Board::ListMoves() {
int moveCount = 1;
for (int i = 0; i < currentMoveIndex; i++) {
Board copy = *this;
bool isLegal = copy.MakeMove(moveList[i]);
if (IsLegal(moveList[i])) continue;
Board copy = *this;
copy.MakeMove(moveList[i]);
if (!isLegal)
continue;
std::cout << moveCount << ". ";
moveList[i].PrintMove();
@@ -348,7 +348,7 @@ void Board::Promote(int square, int pieceType, int color, bool isCapture) {
SetPiece(pieceType, square, color);
}
bool Board::MakeMove(Move move) {
void Board::MakeMove(Move move) {
// Null Move
if (!move) {
int newEpTarget = noEPTarget;
@@ -362,7 +362,7 @@ bool Board::MakeMove(Move move) {
enPassantTarget = newEpTarget;
return true;
return;
}
int newEpTarget = noEPTarget;
@@ -505,8 +505,6 @@ bool Board::MakeMove(Move move) {
}
positionIndex++;
return true;
}
bool Board::InPossibleZug() {
+1 -1
View File
@@ -68,7 +68,7 @@ public:
void RemovePiece(int piece, int square, bool color);
void Promote(int square, int pieceType, int color, bool isCapture);
bool MakeMove(Move move);
void MakeMove(Move move);
bool InPossibleZug();
+8 -5
View File
@@ -206,10 +206,11 @@ static bool IsGameOver(Board &board, SEARCH::SearchContext* ctx) {
int moveSeen = 0;
for (int i = 0; i < board.currentMoveIndex; i++) {
Board copy = board;
bool isLegal = copy.MakeMove(board.moveList[i]);
if (!isLegal) continue;
if (!board.IsLegal(board.moveList[i])) continue;
Board copy = board;
copy.MakeMove(board.moveList[i]);
moveSeen++;
}
@@ -227,12 +228,14 @@ static void PlayRandMoves(Board &board, SEARCH::SearchContext* ctx) {
MOVEGEN::GenerateMoves<All>(board, true);
std::uniform_int_distribution<int> dist(0, board.currentMoveIndex - 1);
bool isLegal = board.MakeMove(board.moveList[dist(rng)]);
if (!isLegal) {
Move currMove = board.moveList[dist(rng)];
if (!board.IsLegal(currMove)) {
count--;
continue;
}
board.MakeMove(currMove);
ctx->positionHistory[board.positionIndex] = board.hashKey;
MOVEGEN::GenerateMoves<All>(board, true);
if (IsGameOver(board, ctx)) break;
+2 -2
View File
@@ -29,9 +29,9 @@ void Perft(Board &board, int depth) {
Stopwatch sw;
for (int i = 0; i < board.currentMoveIndex; i++) {
if (!board.IsLegal(board.moveList[i])) continue;
Board copy = board;
bool isLegal = copy.MakeMove(board.moveList[i]);
if (!isLegal) continue;
copy.MakeMove(board.moveList[i]);
U64 nodeCount = HelperPerft(copy, depth - 1);
totalNodes += nodeCount;
board.moveList[i].PrintMove();