Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use self-describing constants instead of numbers

And remove now useless comments.

No functional change.
  • Loading branch information...
commit e304db9d1ecf6a2318708483c90fadecf4fac4ee 1 parent 6b909b2
@mcostalba authored
View
52 src/bitboard.cpp
@@ -28,31 +28,31 @@
CACHE_LINE_ALIGNMENT
-Bitboard RMasks[64];
-Bitboard RMagics[64];
-Bitboard* RAttacks[64];
-unsigned RShifts[64];
-
-Bitboard BMasks[64];
-Bitboard BMagics[64];
-Bitboard* BAttacks[64];
-unsigned BShifts[64];
-
-Bitboard SquareBB[64];
-Bitboard FileBB[8];
-Bitboard RankBB[8];
-Bitboard AdjacentFilesBB[8];
-Bitboard ThisAndAdjacentFilesBB[8];
-Bitboard InFrontBB[2][8];
-Bitboard StepAttacksBB[16][64];
-Bitboard BetweenBB[64][64];
-Bitboard DistanceRingsBB[64][8];
-Bitboard ForwardBB[2][64];
-Bitboard PassedPawnMask[2][64];
-Bitboard AttackSpanMask[2][64];
-Bitboard PseudoAttacks[6][64];
-
-int SquareDistance[64][64];
+Bitboard RMasks[SQUARE_NB];
+Bitboard RMagics[SQUARE_NB];
+Bitboard* RAttacks[SQUARE_NB];
+unsigned RShifts[SQUARE_NB];
+
+Bitboard BMasks[SQUARE_NB];
+Bitboard BMagics[SQUARE_NB];
+Bitboard* BAttacks[SQUARE_NB];
+unsigned BShifts[SQUARE_NB];
+
+Bitboard SquareBB[SQUARE_NB];
+Bitboard FileBB[FILE_NB];
+Bitboard RankBB[RANK_NB];
+Bitboard AdjacentFilesBB[FILE_NB];
+Bitboard ThisAndAdjacentFilesBB[FILE_NB];
+Bitboard InFrontBB[COLOR_NB][RANK_NB];
+Bitboard StepAttacksBB[PIECE_NB][SQUARE_NB];
+Bitboard BetweenBB[SQUARE_NB][SQUARE_NB];
+Bitboard DistanceRingsBB[SQUARE_NB][8];
+Bitboard ForwardBB[COLOR_NB][SQUARE_NB];
+Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB];
+Bitboard AttackSpanMask[COLOR_NB][SQUARE_NB];
+Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB];
+
+int SquareDistance[SQUARE_NB][SQUARE_NB];
namespace {
@@ -63,7 +63,7 @@ namespace {
CACHE_LINE_ALIGNMENT
int MS1BTable[256];
- Square BSFTable[64];
+ Square BSFTable[SQUARE_NB];
Bitboard RTable[0x19000]; // Storage space for rook attacks
Bitboard BTable[0x1480]; // Storage space for bishop attacks
View
46 src/bitboard.h
@@ -39,29 +39,29 @@ uint32_t probe_kpk(Square wksq, Square wpsq, Square bksq, Color stm);
CACHE_LINE_ALIGNMENT
-extern Bitboard RMasks[64];
-extern Bitboard RMagics[64];
-extern Bitboard* RAttacks[64];
-extern unsigned RShifts[64];
-
-extern Bitboard BMasks[64];
-extern Bitboard BMagics[64];
-extern Bitboard* BAttacks[64];
-extern unsigned BShifts[64];
-
-extern Bitboard SquareBB[64];
-extern Bitboard FileBB[8];
-extern Bitboard RankBB[8];
-extern Bitboard AdjacentFilesBB[8];
-extern Bitboard ThisAndAdjacentFilesBB[8];
-extern Bitboard InFrontBB[2][8];
-extern Bitboard StepAttacksBB[16][64];
-extern Bitboard BetweenBB[64][64];
-extern Bitboard DistanceRingsBB[64][8];
-extern Bitboard ForwardBB[2][64];
-extern Bitboard PassedPawnMask[2][64];
-extern Bitboard AttackSpanMask[2][64];
-extern Bitboard PseudoAttacks[6][64];
+extern Bitboard RMasks[SQUARE_NB];
+extern Bitboard RMagics[SQUARE_NB];
+extern Bitboard* RAttacks[SQUARE_NB];
+extern unsigned RShifts[SQUARE_NB];
+
+extern Bitboard BMasks[SQUARE_NB];
+extern Bitboard BMagics[SQUARE_NB];
+extern Bitboard* BAttacks[SQUARE_NB];
+extern unsigned BShifts[SQUARE_NB];
+
+extern Bitboard SquareBB[SQUARE_NB];
+extern Bitboard FileBB[FILE_NB];
+extern Bitboard RankBB[RANK_NB];
+extern Bitboard AdjacentFilesBB[FILE_NB];
+extern Bitboard ThisAndAdjacentFilesBB[FILE_NB];
+extern Bitboard InFrontBB[COLOR_NB][RANK_NB];
+extern Bitboard StepAttacksBB[PIECE_NB][SQUARE_NB];
+extern Bitboard BetweenBB[SQUARE_NB][SQUARE_NB];
+extern Bitboard DistanceRingsBB[SQUARE_NB][8];
+extern Bitboard ForwardBB[COLOR_NB][SQUARE_NB];
+extern Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB];
+extern Bitboard AttackSpanMask[COLOR_NB][SQUARE_NB];
+extern Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB];
/// Overloads of bitwise operators between a Bitboard and a Square for testing
View
4 src/endgame.cpp
@@ -31,7 +31,7 @@ namespace {
// Table used to drive the defending king towards the edge of the board
// in KX vs K and KQ vs KR endgames.
- const int MateTable[64] = {
+ const int MateTable[SQUARE_NB] = {
100, 90, 80, 70, 70, 80, 90, 100,
90, 70, 60, 50, 50, 60, 70, 90,
80, 60, 40, 30, 30, 40, 60, 80,
@@ -44,7 +44,7 @@ namespace {
// Table used to drive the defending king towards a corner square of the
// right color in KBN vs K endgames.
- const int KBNKMateTable[64] = {
+ const int KBNKMateTable[SQUARE_NB] = {
200, 190, 180, 170, 160, 150, 140, 130,
190, 180, 170, 160, 150, 140, 130, 140,
180, 170, 155, 140, 140, 125, 140, 150,
View
20 src/evaluate.cpp
@@ -42,7 +42,7 @@ namespace {
// attackedBy[color][piece type] is a bitboard representing all squares
// attacked by a given color and piece type, attackedBy[color][0] contains
// all squares attacked by the given color.
- Bitboard attackedBy[2][8];
+ Bitboard attackedBy[COLOR_NB][PIECE_TYPE_NB];
// kingRing[color] is the zone around the king which is considered
// by the king safety evaluation. This consists of the squares directly
@@ -50,25 +50,25 @@ namespace {
// squares two ranks in front of the king. For instance, if black's king
// is on g8, kingRing[BLACK] is a bitboard containing the squares f8, h8,
// f7, g7, h7, f6, g6 and h6.
- Bitboard kingRing[2];
+ Bitboard kingRing[COLOR_NB];
// kingAttackersCount[color] is the number of pieces of the given color
// which attack a square in the kingRing of the enemy king.
- int kingAttackersCount[2];
+ int kingAttackersCount[COLOR_NB];
// kingAttackersWeight[color] is the sum of the "weight" of the pieces of the
// given color which attack a square in the kingRing of the enemy king. The
// weights of the individual piece types are given by the variables
// QueenAttackWeight, RookAttackWeight, BishopAttackWeight and
// KnightAttackWeight in evaluate.cpp
- int kingAttackersWeight[2];
+ int kingAttackersWeight[COLOR_NB];
// kingAdjacentZoneAttacksCount[color] is the number of attacks to squares
// directly adjacent to the king of the given color. Pieces which attack
// more than one square are counted multiple times. For instance, if black's
// king is on g8 and there's a white knight on g5, this knight adds
// 2 to kingAdjacentZoneAttacksCount[BLACK].
- int kingAdjacentZoneAttacksCount[2];
+ int kingAdjacentZoneAttacksCount[COLOR_NB];
};
// Evaluation grain size, must be a power of 2
@@ -114,7 +114,7 @@ namespace {
// OutpostBonus[PieceType][Square] contains outpost bonuses of knights and
// bishops, indexed by piece type and square (from white's point of view).
- const Value OutpostBonus[][64] = {
+ const Value OutpostBonus[][SQUARE_NB] = {
{
// A B C D E F G H
V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0), // Knights
@@ -134,7 +134,7 @@ namespace {
// ThreatBonus[attacking][attacked] contains threat bonuses according to
// which piece type attacks which one.
- const Score ThreatBonus[][8] = {
+ const Score ThreatBonus[][PIECE_TYPE_NB] = {
{}, {},
{ S(0, 0), S( 7, 39), S( 0, 0), S(24, 49), S(41,100), S(41,100) }, // KNIGHT
{ S(0, 0), S( 7, 39), S(24, 49), S( 0, 0), S(41,100), S(41,100) }, // BISHOP
@@ -221,11 +221,11 @@ namespace {
// KingDangerTable[Color][attackUnits] contains the actual king danger
// weighted scores, indexed by color and by a calculated integer number.
- Score KingDangerTable[2][128];
+ Score KingDangerTable[COLOR_NB][128];
// TracedTerms[Color][PieceType || TracedType] contains a breakdown of the
// evaluation terms, used when tracing.
- Score TracedScores[2][16];
+ Score TracedScores[COLOR_NB][16];
std::stringstream TraceStream;
enum TracedType {
@@ -364,7 +364,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
assert(!pos.in_check());
EvalInfo ei;
- Value margins[2];
+ Value margins[COLOR_NB];
Score score, mobilityWhite, mobilityBlack;
// margins[] store the uncertainty estimation of position's evaluation
View
4 src/history.h
@@ -44,8 +44,8 @@ class History {
static const Value MaxValue = Value(2000);
private:
- Value history[16][64]; // [piece][to_square]
- Value maxGains[16][64]; // [piece][to_square]
+ Value history[PIECE_NB][SQUARE_NB];
+ Value maxGains[PIECE_NB][SQUARE_NB];
};
inline void History::clear() {
View
8 src/material.cpp
@@ -40,11 +40,11 @@ namespace {
const int LinearCoefficients[6] = { 1617, -162, -1172, -190, 105, 26 };
- const int QuadraticCoefficientsSameColor[][8] = {
+ const int QuadraticCoefficientsSameColor[][PIECE_TYPE_NB] = {
{ 7, 7, 7, 7, 7, 7 }, { 39, 2, 7, 7, 7, 7 }, { 35, 271, -4, 7, 7, 7 },
{ 7, 25, 4, 7, 7, 7 }, { -27, -2, 46, 100, 56, 7 }, { 58, 29, 83, 148, -3, -25 } };
- const int QuadraticCoefficientsOppositeColor[][8] = {
+ const int QuadraticCoefficientsOppositeColor[][PIECE_TYPE_NB] = {
{ 41, 41, 41, 41, 41, 41 }, { 37, 41, 41, 41, 41, 41 }, { 10, 62, 41, 41, 41, 41 },
{ 57, 64, 39, 41, 41, 41 }, { 50, 40, 23, -22, 41, 41 }, { 106, 101, 3, 151, 171, 41 } };
@@ -215,7 +215,7 @@ MaterialEntry* MaterialTable::probe(const Position& pos) {
// Evaluate the material imbalance. We use PIECE_TYPE_NONE as a place holder
// for the bishop pair "extended piece", this allow us to be more flexible
// in defining bishop pair bonuses.
- const int pieceCount[2][8] = {
+ const int pieceCount[COLOR_NB][PIECE_TYPE_NB] = {
{ pos.piece_count(WHITE, BISHOP) > 1, pos.piece_count(WHITE, PAWN), pos.piece_count(WHITE, KNIGHT),
pos.piece_count(WHITE, BISHOP) , pos.piece_count(WHITE, ROOK), pos.piece_count(WHITE, QUEEN) },
{ pos.piece_count(BLACK, BISHOP) > 1, pos.piece_count(BLACK, PAWN), pos.piece_count(BLACK, KNIGHT),
@@ -230,7 +230,7 @@ MaterialEntry* MaterialTable::probe(const Position& pos) {
/// piece type for both colors.
template<Color Us>
-int MaterialTable::imbalance(const int pieceCount[][8]) {
+int MaterialTable::imbalance(const int pieceCount[][PIECE_TYPE_NB]) {
const Color Them = (Us == WHITE ? BLACK : WHITE);
View
6 src/material.h
@@ -52,9 +52,9 @@ class MaterialEntry {
private:
Key key;
int16_t value;
- uint8_t factor[2];
+ uint8_t factor[COLOR_NB];
EndgameBase<Value>* evaluationFunction;
- EndgameBase<ScaleFactor>* scalingFunction[2];
+ EndgameBase<ScaleFactor>* scalingFunction[COLOR_NB];
int spaceWeight;
Phase gamePhase;
};
@@ -67,7 +67,7 @@ struct MaterialTable {
MaterialEntry* probe(const Position& pos);
static Phase game_phase(const Position& pos);
- template<Color Us> static int imbalance(const int pieceCount[][8]);
+ template<Color Us> static int imbalance(const int pieceCount[][PIECE_TYPE_NB]);
HashTable<MaterialEntry, MaterialTableSize> entries;
Endgames endgames;
View
8 src/notation.cpp
@@ -28,7 +28,7 @@
using namespace std;
-static const char* PieceToChar = " PNBRQK pnbrqk";
+static const char* PieceToChar[COLOR_NB] = { "PNBRQK", "pnbrqk" };
/// score_to_uci() converts a value to a string suitable for use with the UCI
@@ -75,7 +75,7 @@ const string move_to_uci(Move m, bool chess960) {
string move = square_to_string(from) + square_to_string(to);
if (type_of(m) == PROMOTION)
- move += PieceToChar[make_piece(BLACK, promotion_type(m))]; // Lower case
+ move += PieceToChar[BLACK][promotion_type(m)]; // Lower case
return move;
}
@@ -125,7 +125,7 @@ const string move_to_san(Position& pos, Move m) {
{
if (pt != PAWN)
{
- san = PieceToChar[pt]; // Upper case
+ san = PieceToChar[WHITE][pt]; // Upper case
// Disambiguation if we have more then one piece with destination 'to'
// note that for pawns is not needed because starting file is explicit.
@@ -167,7 +167,7 @@ const string move_to_san(Position& pos, Move m) {
san += square_to_string(to);
if (type_of(m) == PROMOTION)
- san += string("=") + PieceToChar[promotion_type(m)];
+ san += string("=") + PieceToChar[WHITE][promotion_type(m)];
}
if (pos.move_gives_check(m, CheckInfo(pos)))
View
14 src/pawns.cpp
@@ -30,34 +30,34 @@ namespace {
#define S(mg, eg) make_score(mg, eg)
// Doubled pawn penalty by opposed flag and file
- const Score DoubledPawnPenalty[2][8] = {
+ const Score DoubledPawnPenalty[2][FILE_NB] = {
{ S(13, 43), S(20, 48), S(23, 48), S(23, 48),
S(23, 48), S(23, 48), S(20, 48), S(13, 43) },
{ S(13, 43), S(20, 48), S(23, 48), S(23, 48),
S(23, 48), S(23, 48), S(20, 48), S(13, 43) }};
// Isolated pawn penalty by opposed flag and file
- const Score IsolatedPawnPenalty[2][8] = {
+ const Score IsolatedPawnPenalty[2][FILE_NB] = {
{ S(37, 45), S(54, 52), S(60, 52), S(60, 52),
S(60, 52), S(60, 52), S(54, 52), S(37, 45) },
{ S(25, 30), S(36, 35), S(40, 35), S(40, 35),
S(40, 35), S(40, 35), S(36, 35), S(25, 30) }};
// Backward pawn penalty by opposed flag and file
- const Score BackwardPawnPenalty[2][8] = {
+ const Score BackwardPawnPenalty[2][FILE_NB] = {
{ S(30, 42), S(43, 46), S(49, 46), S(49, 46),
S(49, 46), S(49, 46), S(43, 46), S(30, 42) },
{ S(20, 28), S(29, 31), S(33, 31), S(33, 31),
S(33, 31), S(33, 31), S(29, 31), S(20, 28) }};
// Pawn chain membership bonus by file
- const Score ChainBonus[8] = {
+ const Score ChainBonus[FILE_NB] = {
S(11,-1), S(13,-1), S(13,-1), S(14,-1),
S(14,-1), S(13,-1), S(13,-1), S(11,-1)
};
// Candidate passed pawn bonus by rank
- const Score CandidateBonus[8] = {
+ const Score CandidateBonus[RANK_NB] = {
S( 0, 0), S( 6, 13), S(6,13), S(14,29),
S(34,68), S(83,166), S(0, 0), S( 0, 0)
};
@@ -65,12 +65,12 @@ namespace {
const Score PawnStructureWeight = S(233, 201);
// Weakness of our pawn shelter in front of the king indexed by [king pawn][rank]
- const Value ShelterWeakness[2][8] =
+ const Value ShelterWeakness[2][RANK_NB] =
{ { V(141), V(0), V(38), V(102), V(128), V(141), V(141) },
{ V( 61), V(0), V(16), V( 44), V( 56), V( 61), V( 61) } };
// Danger of enemy pawns moving toward our king indexed by [pawn blocked][rank]
- const Value StormDanger[2][8] =
+ const Value StormDanger[2][RANK_NB] =
{ { V(26), V(0), V(128), V(51), V(26) },
{ V(13), V(0), V( 64), V(25), V(13) } };
View
14 src/pawns.h
@@ -56,14 +56,14 @@ class PawnEntry {
Value shelter_storm(const Position& pos, Square ksq);
Key key;
- Bitboard passedPawns[2];
- Bitboard pawnAttacks[2];
- Square kingSquares[2];
- int minKPdistance[2];
- int castleRights[2];
+ Bitboard passedPawns[COLOR_NB];
+ Bitboard pawnAttacks[COLOR_NB];
+ Square kingSquares[COLOR_NB];
+ int minKPdistance[COLOR_NB];
+ int castleRights[COLOR_NB];
Score value;
- int halfOpenFiles[2];
- Score kingSafety[2];
+ int halfOpenFiles[COLOR_NB];
+ Score kingSafety[COLOR_NB];
};
View
12 src/position.cpp
@@ -40,16 +40,16 @@ static const string PieceToChar(" PNBRQK pnbrqk");
CACHE_LINE_ALIGNMENT
-Score pieceSquareTable[16][64]; // [piece][square]
-Value PieceValue[2][18] = { // [Mg / Eg][piece / pieceType]
+Score pieceSquareTable[PIECE_NB][SQUARE_NB];
+Value PieceValue[2][18] = { // [Mg / Eg][piece / pieceType]
{ VALUE_ZERO, PawnValueMg, KnightValueMg, BishopValueMg, RookValueMg, QueenValueMg },
{ VALUE_ZERO, PawnValueEg, KnightValueEg, BishopValueEg, RookValueEg, QueenValueEg } };
namespace Zobrist {
-Key psq[2][8][64]; // [color][pieceType][square / piece count]
-Key enpassant[8]; // [file]
-Key castle[16]; // [castleRight]
+Key psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB];
+Key enpassant[FILE_NB];
+Key castle[CASTLE_RIGHT_NB];
Key side;
Key exclusion;
@@ -1593,7 +1593,7 @@ bool Position::pos_is_ok(int* failedStep) const {
if ((*step)++, debugKingCount)
{
- int kingCount[2] = {};
+ int kingCount[COLOR_NB] = {};
for (Square s = SQ_A1; s <= SQ_H8; s++)
if (type_of(piece_on(s)) == KING)
View
24 src/position.h
@@ -37,7 +37,7 @@ struct CheckInfo {
Bitboard dcCandidates;
Bitboard pinned;
- Bitboard checkSq[8];
+ Bitboard checkSq[PIECE_TYPE_NB];
Square ksq;
};
@@ -49,7 +49,7 @@ struct CheckInfo {
struct StateInfo {
Key pawnKey, materialKey;
- Value npMaterial[2];
+ Value npMaterial[COLOR_NB];
int castleRights, rule50, pliesFromNull;
Score psqScore;
Square epSquare;
@@ -62,7 +62,7 @@ struct StateInfo {
struct ReducedStateInfo {
Key pawnKey, materialKey;
- Value npMaterial[2];
+ Value npMaterial[COLOR_NB];
int castleRights, rule50, pliesFromNull;
Score psqScore;
Square epSquare;
@@ -209,17 +209,17 @@ class Position {
Value compute_non_pawn_material(Color c) const;
// Board and pieces
- Piece board[64]; // [square]
- Bitboard byTypeBB[8]; // [pieceType]
- Bitboard byColorBB[2]; // [color]
- int pieceCount[2][8]; // [color][pieceType]
- Square pieceList[2][8][16]; // [color][pieceType][index]
- int index[64]; // [square]
+ Piece board[SQUARE_NB];
+ Bitboard byTypeBB[PIECE_TYPE_NB];
+ Bitboard byColorBB[COLOR_NB];
+ int pieceCount[COLOR_NB][PIECE_TYPE_NB];
+ Square pieceList[COLOR_NB][PIECE_TYPE_NB][16];
+ int index[SQUARE_NB];
// Other info
- int castleRightsMask[64]; // [square]
- Square castleRookSquare[2][2]; // [color][side]
- Bitboard castlePath[2][2]; // [color][side]
+ int castleRightsMask[SQUARE_NB];
+ Square castleRookSquare[COLOR_NB][CASTLING_SIDE_NB];
+ Bitboard castlePath[COLOR_NB][CASTLING_SIDE_NB];
StateInfo startState;
int64_t nodes;
int startPosPly;
View
2  src/psqtab.h
@@ -29,7 +29,7 @@
/// a given square a (midgame, endgame) score pair is assigned. PSQT is defined
/// for white side, for black side the tables are symmetric.
-static const Score PSQT[][64] = {
+static const Score PSQT[][SQUARE_NB] = {
{ },
{ // Pawn
S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0), S(0, 0), S( 0, 0), S( 0, 0), S( 0, 0),
View
2  src/search.cpp
@@ -92,7 +92,7 @@ namespace {
int BestMoveChanges;
int SkillLevel;
bool SkillLevelEnabled, Chess960;
- Value DrawValue[2];
+ Value DrawValue[COLOR_NB];
History H;
template <NodeType NT>
View
2  src/search.h
@@ -82,7 +82,7 @@ struct LimitsType {
LimitsType() { memset(this, 0, sizeof(LimitsType)); }
bool use_time_management() const { return !(movetime | depth | nodes | infinite); }
- int time[2], inc[2], movestogo, depth, nodes, movetime, infinite, ponder;
+ int time[COLOR_NB], inc[COLOR_NB], movestogo, depth, nodes, movetime, infinite, ponder;
};
View
32 src/types.h
@@ -136,12 +136,14 @@ enum CastleRight { // Defined as in PolyGlot book hash key
WHITE_OOO = 2,
BLACK_OO = 4,
BLACK_OOO = 8,
- ALL_CASTLES = 15
+ ALL_CASTLES = 15,
+ CASTLE_RIGHT_NB = 16
};
enum CastlingSide {
KING_SIDE,
- QUEEN_SIDE
+ QUEEN_SIDE,
+ CASTLING_SIDE_NB = 2
};
enum Phase {
@@ -188,17 +190,19 @@ enum Value {
enum PieceType {
NO_PIECE_TYPE = 0, ALL_PIECES = 0,
- PAWN = 1, KNIGHT = 2, BISHOP = 3, ROOK = 4, QUEEN = 5, KING = 6
+ PAWN = 1, KNIGHT = 2, BISHOP = 3, ROOK = 4, QUEEN = 5, KING = 6,
+ PIECE_TYPE_NB = 8
};
enum Piece {
NO_PIECE = 16, // color_of(NO_PIECE) == NO_COLOR
W_PAWN = 1, W_KNIGHT = 2, W_BISHOP = 3, W_ROOK = 4, W_QUEEN = 5, W_KING = 6,
- B_PAWN = 9, B_KNIGHT = 10, B_BISHOP = 11, B_ROOK = 12, B_QUEEN = 13, B_KING = 14
+ B_PAWN = 9, B_KNIGHT = 10, B_BISHOP = 11, B_ROOK = 12, B_QUEEN = 13, B_KING = 14,
+ PIECE_NB = 16
};
enum Color {
- WHITE, BLACK, NO_COLOR
+ WHITE, BLACK, NO_COLOR, COLOR_NB = 2
};
enum Depth {
@@ -224,6 +228,8 @@ enum Square {
SQ_A8, SQ_B8, SQ_C8, SQ_D8, SQ_E8, SQ_F8, SQ_G8, SQ_H8,
SQ_NONE,
+ SQUARE_NB = 64,
+
DELTA_N = 8,
DELTA_E = 1,
DELTA_S = -8,
@@ -238,11 +244,11 @@ enum Square {
};
enum File {
- FILE_A, FILE_B, FILE_C, FILE_D, FILE_E, FILE_F, FILE_G, FILE_H
+ FILE_A, FILE_B, FILE_C, FILE_D, FILE_E, FILE_F, FILE_G, FILE_H, FILE_NB = 8
};
enum Rank {
- RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8
+ RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8, RANK_NB = 8
};
@@ -329,9 +335,9 @@ inline Score apply_weight(Score v, Score w) {
namespace Zobrist {
- extern Key psq[2][8][64]; // [color][pieceType][square / piece count]
- extern Key enpassant[8]; // [file]
- extern Key castle[16]; // [castleRight]
+ extern Key psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB];
+ extern Key enpassant[FILE_NB];
+ extern Key castle[CASTLE_RIGHT_NB];
extern Key side;
extern Key exclusion;
@@ -340,9 +346,9 @@ namespace Zobrist {
CACHE_LINE_ALIGNMENT
-extern Score pieceSquareTable[16][64]; // [piece][square]
-extern Value PieceValue[2][18]; // [Mg / Eg][piece / pieceType]
-extern int SquareDistance[64][64]; // [square][square]
+extern Score pieceSquareTable[PIECE_NB][SQUARE_NB];
+extern Value PieceValue[2][18]; // [Mg / Eg][piece / pieceType]
+extern int SquareDistance[SQUARE_NB][SQUARE_NB];
struct MoveStack {
Move move;
Please sign in to comment.
Something went wrong with that request. Please try again.