From 25296547d0258f8519b7614e4474bbc947eaea04 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 7 May 2017 10:26:09 +0200 Subject: [PATCH] Move Pieces[] out of global visibility It is an helper array used only in position.cpp Also small code tidy up while there. No functional change. Closes #1106 --- src/position.cpp | 3 +++ src/search.h | 9 +++++---- src/types.h | 9 ++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 69a756d9..03d8bf8c 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -52,6 +52,9 @@ namespace { const string PieceToChar(" PNBRQK pnbrqk"); +const Piece Pieces[] = { W_PAWN, W_KNIGHT, W_BISHOP, W_ROOK, W_QUEEN, W_KING, + B_PAWN, B_KNIGHT, B_BISHOP, B_ROOK, B_QUEEN, B_KING }; + // min_attacker() is a helper function used by see_ge() to locate the least // valuable attacker for the side to move, remove the attacker we just found // from the bitboards and scan for new X-ray attacks behind it. diff --git a/src/search.h b/src/search.h index 1218ef3b..94b59d2b 100644 --- a/src/search.h +++ b/src/search.h @@ -56,11 +56,12 @@ struct Stack { struct RootMove { explicit RootMove(Move m) : pv(1, m) {} - - bool operator<(const RootMove& m) const { - return m.score != score ? m.score < score : m.previousScore < previousScore; } // Descending sort - bool operator==(const Move& m) const { return pv[0] == m; } bool extract_ponder_from_tt(Position& pos); + bool operator==(const Move& m) const { return pv[0] == m; } + bool operator<(const RootMove& m) const { // Sort in descending order + return m.score != score ? m.score < score + : m.previousScore < previousScore; + } Value score = -VALUE_INFINITE; Value previousScore = -VALUE_INFINITE; diff --git a/src/types.h b/src/types.h index 1514c8c1..417f4815 100644 --- a/src/types.h +++ b/src/types.h @@ -76,7 +76,7 @@ # include // Header for _pext_u64() intrinsic # define pext(b, m) _pext_u64(b, m) #else -# define pext(b, m) (0) +# define pext(b, m) 0 #endif #ifdef USE_POPCNT @@ -205,8 +205,6 @@ enum Piece { PIECE_NB = 16 }; -const Piece Pieces[] = { W_PAWN, W_KNIGHT, W_BISHOP, W_ROOK, W_QUEEN, W_KING, - B_PAWN, B_KNIGHT, B_BISHOP, B_ROOK, B_QUEEN, B_KING }; extern Value PieceValue[PHASE_NB][PIECE_NB]; enum Depth : int { @@ -239,8 +237,8 @@ enum Square { NORTH = 8, EAST = 1, - SOUTH = -8, - WEST = -1, + SOUTH = -NORTH, + WEST = -EAST, NORTH_EAST = NORTH + EAST, SOUTH_EAST = SOUTH + EAST, @@ -331,6 +329,7 @@ inline Score operator/(Score s, int i) { /// Multiplication of a Score by an integer. We check for overflow in debug mode. inline Score operator*(Score s, int i) { + Score result = Score(int(s) * i); assert(eg_value(result) == (i * eg_value(s))); -- 2.39.2