aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/board.cpp10
-rw-r--r--src/board.hpp6
-rw-r--r--src/bot.cpp6
-rw-r--r--src/moves.cpp17
-rw-r--r--src/uci.cpp4
-rw-r--r--src/zobrist.cpp2
6 files changed, 23 insertions, 22 deletions
diff --git a/src/board.cpp b/src/board.cpp
index 4daddfd..ea0a39a 100644
--- a/src/board.cpp
+++ b/src/board.cpp
@@ -37,7 +37,7 @@ UndoMove MakeMove(Move move, Game *g) {
Piece piece = g->pieces[PositionToIndex(move.From)];
Piece piece2 = g->pieces[PositionToIndex(move.To)];
- if (piece2.type != NONE) {
+ if (piece2.type != NONEPIECE) {
if (piece2.color == g->turn) {
assert(false && "capturing friendly piece error");
}
@@ -46,7 +46,7 @@ UndoMove MakeMove(Move move, Game *g) {
// clock
g->MoveClock++;
- if (piece.type == PAWN || piece2.type != NONE) {
+ if (piece.type == PAWN || piece2.type != NONEPIECE) {
g->halfMoveClock = 0;
} else {
g->halfMoveClock++;
@@ -56,7 +56,7 @@ UndoMove MakeMove(Move move, Game *g) {
if (piece.type == PAWN && g->canEnpassant && move.To == g->enPassant) {
Position capturedPawn = move.To;
capturedPawn.rank += piece.color ? 1 : -1;
- g->pieces[PositionToIndex(capturedPawn)] = {false, NONE, false};
+ g->pieces[PositionToIndex(capturedPawn)] = {false, NONEPIECE, false};
undo.wasEnPassantCapture = true;
undo.enPassantCapturedSquare = capturedPawn;
@@ -80,12 +80,12 @@ UndoMove MakeMove(Move move, Game *g) {
// Promotions
if (piece.type == PAWN && move.To.rank == (piece.color ? 0 : 7)) {
// TODO parse the promote type from uci isntead of ignoreting it
- piece.type = move.promotion == NONE ? QUEEN : move.promotion;
+ piece.type = move.promotion == NONEPIECE ? QUEEN : move.promotion;
}
// setting the moves
g->pieces[PositionToIndex(move.To)] = piece;
- g->pieces[PositionToIndex(move.From)] = {false, NONE, false};
+ g->pieces[PositionToIndex(move.From)] = {false, NONEPIECE, false};
// post move change
diff --git a/src/board.hpp b/src/board.hpp
index 993a66d..9418571 100644
--- a/src/board.hpp
+++ b/src/board.hpp
@@ -6,7 +6,7 @@
#include <unordered_map>
enum PieceType {
- NONE,
+ NONEPIECE,
PAWN,
KNIGHT,
BISHOP,
@@ -25,7 +25,7 @@ enum GameState {
struct Piece {
bool color = 0;
- PieceType type = NONE;
+ PieceType type = NONEPIECE;
bool moved = false;
};
@@ -52,7 +52,7 @@ struct Move {
Position From;
Position To;
- PieceType promotion = NONE;
+ PieceType promotion = NONEPIECE;
bool operator==(const Move &other) const {
return From == other.From && To == other.To && promotion == other.promotion;
}
diff --git a/src/bot.cpp b/src/bot.cpp
index 02b9452..1a156a2 100644
--- a/src/bot.cpp
+++ b/src/bot.cpp
@@ -68,7 +68,7 @@ int ScoreMove(const Game *board, const Move &move) {
Piece captured = board->pieces[PositionToIndex(move.To)];
// Captures (MVV-LVA)
- if (captured.type != NONE) {
+ if (captured.type != NONEPIECE) {
static const int pieceValue[] = {
0, // NONE
20000, // KING (should never happen)
@@ -85,7 +85,7 @@ int ScoreMove(const Game *board, const Move &move) {
}
// Promotions
- if (move.promotion != NONE) {
+ if (move.promotion != NONEPIECE) {
score += 8000;
}
@@ -193,7 +193,7 @@ float EvaluateBoardForWhite(Game *b, int depth) {
for (int i = 0; i < 64; i++) {
Piece piece = b->pieces[i];
- if (piece.type == NONE)
+ if (piece.type == NONEPIECE)
continue;
int value = 0;
diff --git a/src/moves.cpp b/src/moves.cpp
index 638e01a..e1289db 100644
--- a/src/moves.cpp
+++ b/src/moves.cpp
@@ -25,7 +25,7 @@ void GenerateKnightMoves(Game *b, int from, std::vector<Move> &moves) {
if (fileDelta != 1 && fileDelta != 2) {
continue;
};
- if (b->pieces[next].type != NONE) {
+ if (b->pieces[next].type != NONEPIECE) {
if (b->pieces[next].color == b->turn) {
continue;
};
@@ -51,7 +51,7 @@ void GeneratePawnMoves(Game *b, int from, std::vector<Move> &moves) {
}
// if piece it want to move to is none and it as legal move
- if (b->pieces[next].type == NONE) {
+ if (b->pieces[next].type == NONEPIECE) {
if (position.rank + (pawn.color ? -1 : 1) == 0 ||
position.rank + (pawn.color ? -1 : 1) == 7) {
moves.push_back({position, IndexToPosition(next), QUEEN});
@@ -64,7 +64,8 @@ void GeneratePawnMoves(Game *b, int from, std::vector<Move> &moves) {
int startingRank = pawn.color ? 6 : 1;
int twoSteps = from + step * 2;
- if (position.rank == startingRank && b->pieces[twoSteps].type == NONE) {
+ if (position.rank == startingRank &&
+ b->pieces[twoSteps].type == NONEPIECE) {
moves.push_back({position, IndexToPosition(twoSteps)});
}
}
@@ -84,7 +85,7 @@ void GeneratePawnMoves(Game *b, int from, std::vector<Move> &moves) {
moves.push_back({position, IndexToPosition(target)});
}
- if (b->pieces[target].type != NONE &&
+ if (b->pieces[target].type != NONEPIECE &&
b->pieces[target].color != pawn.color) {
if (targetRank == 0 || targetRank == 7) {
moves.push_back({position, IndexToPosition(target), QUEEN});
@@ -108,7 +109,7 @@ std::vector<Move> GetPseudoLegalMoves(Game *b) {
for (uint i = 0; i < sizeof(b->pieces) / sizeof(b->pieces[0]); i++) {
Piece piece = b->pieces[i];
- if (piece.type == NONE) {
+ if (piece.type == NONEPIECE) {
continue;
}
if (piece.color != b->turn)
@@ -237,7 +238,7 @@ void GenerateSlidingMoves(Game *b, int from,
if (i2 >= 64 || i2 < 0) {
break;
}
- if (b->pieces[i2].color == b->turn && b->pieces[i2].type != NONE) {
+ if (b->pieces[i2].color == b->turn && b->pieces[i2].type != NONEPIECE) {
break;
}
if ((direction == 1 || direction == -1) &&
@@ -245,7 +246,7 @@ void GenerateSlidingMoves(Game *b, int from,
break;
}
moves.push_back({IndexToPosition(from), IndexToPosition(i2)});
- if (b->pieces[i2].color != b->turn && b->pieces[i2].type != NONE) {
+ if (b->pieces[i2].color != b->turn && b->pieces[i2].type != NONEPIECE) {
break;
}
}
@@ -270,7 +271,7 @@ void GenerateKingMoves(Game *b, int from, std::vector<Move> &moves) {
if (std::abs((next % 8) - (from % 8)) > 1) {
continue;
};
- if (b->pieces[next].type != NONE) {
+ if (b->pieces[next].type != NONEPIECE) {
if (b->pieces[next].color == b->turn) {
continue;
};
diff --git a/src/uci.cpp b/src/uci.cpp
index 1f634fe..4e32d6f 100644
--- a/src/uci.cpp
+++ b/src/uci.cpp
@@ -57,7 +57,7 @@ static Game initBoard(string startingFEN) {
Piece EmptyPiece = {
false,
- NONE,
+ NONEPIECE,
false,
};
for (int i = 0; i < 64; i++) {
@@ -95,7 +95,7 @@ void Uci() {
cout << "bestmove ";
cout << (char)(best.From.file + 'a') << 8 - best.From.rank
<< (char)(best.To.file + 'a') << 8 - best.To.rank;
- if (best.promotion != NONE) {
+ if (best.promotion != NONEPIECE) {
switch (best.promotion) {
case QUEEN:
cout << "q";
diff --git a/src/zobrist.cpp b/src/zobrist.cpp
index b41b6c6..05d4cf2 100644
--- a/src/zobrist.cpp
+++ b/src/zobrist.cpp
@@ -36,7 +36,7 @@ uint64_t GenerateZobristKey(Game *b) {
for (int square = 0; square < 64; square++) {
Piece p = b->pieces[square];
- if (p.type == NONE)
+ if (p.type == NONEPIECE)
continue;
key ^= PieceKeys[p.color][p.type][square];