fixed GetPieceType function

This commit is contained in:
rektdie committed 2025-03-03 20:12:06 +01:00
1 parent 5952d8ade4
commit 8e26cc1013
3 files changed
+7 -1

No files matched your search

+1 -1
View File
@@ -266,7 +266,7 @@ int Board::GetPieceType(int square) {
if (pieces[piece].IsSet(square)) return piece; if (pieces[piece].IsSet(square)) return piece;
} }
return -1; return nullPieceType;
} }
int Board::GetPieceColor(int square) { int Board::GetPieceColor(int square) {
+2
View File
@@ -4,6 +4,8 @@
#include "types.h" #include "types.h"
#include "move.h" #include "move.h"
constexpr int nullPieceType = 100;
class Board { class Board {
public: public:
Board() { Board() {
+4
View File
@@ -20,11 +20,15 @@ static int ScoreMove(Board &board, Move &move) {
const int attackerType = board.GetPieceType(move.MoveFrom()); const int attackerType = board.GetPieceType(move.MoveFrom());
const int targetType = board.GetPieceType(move.MoveTo()); const int targetType = board.GetPieceType(move.MoveTo());
if (attackerType == nullPieceType || targetType == nullPieceType) return 0;
TTEntry *current = &TTable[board.hashKey % hashSize]; TTEntry *current = &TTable[board.hashKey % hashSize];
if (current->bestMove == move) { if (current->bestMove == move) {
return 50000; return 50000;
} }
if (attackerType == -1 || targetType == -1) std::cout << "asd\n";
if (move.IsCapture()) { if (move.IsCapture()) {
return moveScoreTable[attackerType][targetType] + 10000; return moveScoreTable[attackerType][targetType] + 10000;
} else { } else {