Enpassant fix #6

Merged
rektdie merged 2 commits from enpassant_fix into legalMovegen 2025-03-04 08:39:47 +01:00
2 changed files with 6 additions and 5 deletions
Showing only changes of commit 00c3be28ba - Show all commits

No files matched your search

+4 -4
View File
@@ -9,7 +9,7 @@ void Board::Init() {
void Board::Reset() { void Board::Reset() {
castlingRights = 0; castlingRights = 0;
enPassantTarget = -1; enPassantTarget = noEPTarget;
halfMoves = 0; halfMoves = 0;
fullMoves = 0; fullMoves = 0;
sideToMove = White; sideToMove = White;
@@ -229,7 +229,7 @@ void Board::PrintBoard() {
} else { } else {
std::cout << "Black\n"; std::cout << "Black\n";
} }
if (enPassantTarget >= 0) { if (enPassantTarget != noEPTarget) {
std::cout << " En Passant square: " << squareCoords[enPassantTarget] << '\n'; std::cout << " En Passant square: " << squareCoords[enPassantTarget] << '\n';
} else { } else {
std::cout << " En Passant square: None" << '\n'; std::cout << " En Passant square: None" << '\n';
@@ -433,11 +433,11 @@ void Board::MakeMove(Move move) {
sideToMove = !attackerColor; sideToMove = !attackerColor;
hashKey ^= zSide; hashKey ^= zSide;
if (enPassantTarget != -1) { if (enPassantTarget != noEPTarget) {
hashKey ^= zEnPassant[enPassantTarget % 8]; hashKey ^= zEnPassant[enPassantTarget % 8];
} }
if (newEpTarget != -1) { if (newEpTarget != noEPTarget) {
hashKey ^= zEnPassant[newEpTarget % 8]; hashKey ^= zEnPassant[newEpTarget % 8];
} }
+2 -1
View File
@@ -5,6 +5,7 @@
#include "move.h" #include "move.h"
constexpr int nullPieceType = 100; constexpr int nullPieceType = 100;
constexpr int noEPTarget = 100;
class Board { class Board {
public: public:
@@ -26,7 +27,7 @@ public:
int fullMoves = 0; int fullMoves = 0;
uint8_t castlingRights = 0; uint8_t castlingRights = 0;
int enPassantTarget = -1; int enPassantTarget = noEPTarget;
U64 hashKey = 0ULL; U64 hashKey = 0ULL;