And other little trivial stuff.
No functional change.
// attacked and undefended squares around our king and the quality of
// the pawn shelter (current 'score' value).
kingDanger = std::min(807, ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them])
// attacked and undefended squares around our king and the quality of
// the pawn shelter (current 'score' value).
kingDanger = std::min(807, ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them])
- + 101 * ei.kingAdjacentZoneAttacksCount[Them]
- + 235 * popcount(undefended)
- + 134 * (popcount(b) + !!ei.pinnedPieces[Us])
- - 717 * !pos.count<QUEEN>(Them)
- - 7 * mg_value(score) / 5 - 5;
+ + 101 * ei.kingAdjacentZoneAttacksCount[Them]
+ + 235 * popcount(undefended)
+ + 134 * (popcount(b) + !!ei.pinnedPieces[Us])
+ - 717 * !pos.count<QUEEN>(Them)
+ - 7 * mg_value(score) / 5 - 5;
// Analyse the enemy's safe queen contact checks. Firstly, find the
// undefended squares around the king reachable by the enemy queen...
// Analyse the enemy's safe queen contact checks. Firstly, find the
// undefended squares around the king reachable by the enemy queen...
#include "uci.h"
#include "syzygy/tbprobe.h"
#include "uci.h"
#include "syzygy/tbprobe.h"
+namespace PSQT {
+ void init();
+}
+
int main(int argc, char* argv[]) {
std::cout << engine_info() << std::endl;
int main(int argc, char* argv[]) {
std::cout << engine_info() << std::endl;
case EVASIONS_INIT:
cur = moves;
endMoves = generate<EVASIONS>(pos, cur);
case EVASIONS_INIT:
cur = moves;
endMoves = generate<EVASIONS>(pos, cur);
- if (endMoves - cur > 1)
+ if (endMoves - cur - (ttMove != MOVE_NONE) > 1)
score<EVASIONS>();
++stage;
score<EVASIONS>();
++stage;
#include "movegen.h"
#include "position.h"
#include "movegen.h"
#include "position.h"
const T* operator[](Piece pc) const { return table[pc]; }
T* operator[](Piece pc) { return table[pc]; }
void clear() { std::memset(table, 0, sizeof(table)); }
const T* operator[](Piece pc) const { return table[pc]; }
T* operator[](Piece pc) { return table[pc]; }
void clear() { std::memset(table, 0, sizeof(table)); }
void update(Piece pc, Square to, Move m) { table[pc][to] = m; }
void update(Piece pc, Square to, Move m) { table[pc][to] = m; }
void update(Piece pc, Square to, Value v) {
if (abs(int(v)) >= 324)
void update(Piece pc, Square to, Value v) {
if (abs(int(v)) >= 324)
- Value get(Color c, Move m) const { return table[c][from_sq(m)][to_sq(m)]; }
- void clear() { std::memset(table, 0, sizeof(table)); }
+ Value get(Color c, Move m) const { return table[c][from_sq(m)][to_sq(m)]; }
+ void clear() { std::memset(table, 0, sizeof(table)); }
+ void update(Color c, Move m, Value v) {
- void update(Color c, Move m, Value v)
- {
- if (abs(int(v)) >= 324)
- return;
+ if (abs(int(v)) >= 324)
+ return;
- Square f = from_sq(m);
- Square t = to_sq(m);
+ Square from = from_sq(m);
+ Square to = to_sq(m);
- table[c][f][t] -= table[c][f][t] * abs(int(v)) / 324;
- table[c][f][t] += int(v) * 32;
- }
+ table[c][from][to] -= table[c][from][to] * abs(int(v)) / 324;
+ table[c][from][to] += int(v) * 32;
+ }
- Value table[COLOR_NB][SQUARE_NB][SQUARE_NB];
+ Value table[COLOR_NB][SQUARE_NB][SQUARE_NB];
/// MovePicker class is used to pick one pseudo legal move at a time from the
/// current position. The most important method is next_move(), which returns a
/// new pseudo legal move each time it is called, until there are no moves left,
/// when MOVE_NONE is returned. In order to improve the efficiency of the alpha
/// beta algorithm, MovePicker attempts to return the moves which are most likely
/// to get a cut-off first.
/// MovePicker class is used to pick one pseudo legal move at a time from the
/// current position. The most important method is next_move(), which returns a
/// new pseudo legal move each time it is called, until there are no moves left,
/// when MOVE_NONE is returned. In order to improve the efficiency of the alpha
/// beta algorithm, MovePicker attempts to return the moves which are most likely
/// to get a cut-off first.
+namespace Search { struct Stack; }
class MovePicker {
public:
class MovePicker {
public:
Square recaptureSquare;
Value threshold;
int stage;
Square recaptureSquare;
Value threshold;
int stage;
- ExtMove* cur, *endMoves, *endBadCaptures;
+ ExtMove *cur, *endMoves, *endBadCaptures;
ExtMove moves[MAX_MOVES];
};
ExtMove moves[MAX_MOVES];
};
#include <algorithm>
#include <cassert>
#include <algorithm>
#include <cassert>
-#include <cstring> // For std::memset, std::memcmp
+#include <cstddef> // For offsetof()
+#include <cstring> // For std::memset, std::memcmp
#include <iomanip>
#include <sstream>
#include <iomanip>
#include <sstream>
+namespace PSQT {
+ extern Score psq[PIECE_NB][SQUARE_NB];
+}
+
namespace Zobrist {
Key psq[PIECE_NB][SQUARE_NB];
namespace Zobrist {
Key psq[PIECE_NB][SQUARE_NB];
#define POSITION_H_INCLUDED
#include <cassert>
#define POSITION_H_INCLUDED
#include <cassert>
-#include <cstddef> // For offsetof()
-#include <memory> // For std::unique_ptr
+#include <memory> // For std::unique_ptr
#include "bitboard.h"
#include "types.h"
#include "bitboard.h"
#include "types.h"
-class Position;
-class Thread;
-
-namespace PSQT {
-
- extern Score psq[PIECE_NB][SQUARE_NB];
-
- void init();
-}
-
/// StateInfo struct stores information needed to restore a Position object to
/// its previous state when we retract a move. Whenever a move is made on the
/// StateInfo struct stores information needed to restore a Position object to
/// its previous state when we retract a move. Whenever a move is made on the
Score psq;
Square epSquare;
Score psq;
Square epSquare;
- // Not copied when making a move
+ // Not copied when making a move (will be recomputed anyhow)
Key key;
Bitboard checkersBB;
Piece capturedPiece;
Key key;
Bitboard checkersBB;
Piece capturedPiece;
/// pieces, side to move, hash keys, castling info, etc. Important methods are
/// do_move() and undo_move(), used by the search to update node info when
/// traversing the search tree.
/// pieces, side to move, hash keys, castling info, etc. Important methods are
/// do_move() and undo_move(), used by the search to update node info when
/// traversing the search tree.
public:
static void init();
public:
static void init();
void do_null_move(StateInfo& st);
void undo_null_move();
void do_null_move(StateInfo& st);
void undo_null_move();
- // Static exchange evaluation
+ // Static Exchange Evaluation
Value see(Move m) const;
Value see_sign(Move m) const;
Value see(Move m) const;
Value see_sign(Move m) const;
}
inline bool Position::capture_or_promotion(Move m) const {
}
inline bool Position::capture_or_promotion(Move m) const {
assert(is_ok(m));
return type_of(m) != NORMAL ? type_of(m) != CASTLING : !empty(to_sq(m));
}
inline bool Position::capture(Move m) const {
assert(is_ok(m));
return type_of(m) != NORMAL ? type_of(m) != CASTLING : !empty(to_sq(m));
}
inline bool Position::capture(Move m) const {
-
- // Castling is encoded as "king captures the rook"
+ // Castling is encoded as "king captures rook"
return (!empty(to_sq(m)) && type_of(m) != CASTLING) || type_of(m) == ENPASSANT;
}
return (!empty(to_sq(m)) && type_of(m) != CASTLING) || type_of(m) == ENPASSANT;
}
// WARNING: This is not a reversible operation. If we remove a piece in
// do_move() and then replace it in undo_move() we will put it at the end of
// the list and not in its original place, it means index[] and pieceList[]
// WARNING: This is not a reversible operation. If we remove a piece in
// do_move() and then replace it in undo_move() we will put it at the end of
// the list and not in its original place, it means index[] and pieceList[]
- // are not guaranteed to be invariant to a do_move() + undo_move() sequence.
+ // are not invariant to a do_move() + undo_move() sequence.
byTypeBB[ALL_PIECES] ^= s;
byTypeBB[type_of(pc)] ^= s;
byColorBB[color_of(pc)] ^= s;
byTypeBB[ALL_PIECES] ^= s;
byTypeBB[type_of(pc)] ^= s;
byColorBB[color_of(pc)] ^= s;
#include "misc.h"
#include "movegen.h"
#include "movepick.h"
#include "misc.h"
#include "movegen.h"
#include "movepick.h"
#include "search.h"
#include "timeman.h"
#include "thread.h"
#include "search.h"
#include "timeman.h"
#include "thread.h"
#include <vector>
#include "misc.h"
#include <vector>
#include "misc.h"
-template<typename T, bool CM> struct Stats;
-typedef Stats<Value, true> CounterMoveStats;
CounterMoveStats* counterMoves;
};
CounterMoveStats* counterMoves;
};
/// RootMove struct is used for moves at the root of the tree. For each root move
/// we store a score and a PV (really a refutation in the case of moves which
/// fail low). Score is normally set at -VALUE_INFINITE for all non-pv moves.
/// RootMove struct is used for moves at the root of the tree. For each root move
/// we store a score and a PV (really a refutation in the case of moves which
/// fail low). Score is normally set at -VALUE_INFINITE for all non-pv moves.
typedef std::vector<RootMove> RootMoves;
typedef std::vector<RootMove> RootMoves;
/// LimitsType struct stores information sent by GUI about available time to
/// search the current move, maximum depth/time, if we are in analysis mode or
/// if we have to ponder while it's our opponent's turn to move.
/// LimitsType struct stores information sent by GUI about available time to
/// search the current move, maximum depth/time, if we are in analysis mode or
/// if we have to ponder while it's our opponent's turn to move.
-/// The SignalsType struct stores atomic flags updated during the search
-/// typically in an async fashion e.g. to stop the search by the GUI.
+
+/// SignalsType struct stores atomic flags updated during the search, typically
+/// in an async fashion e.g. to stop the search by the GUI.
struct SignalsType {
std::atomic_bool stop, stopOnPonderhit;
struct SignalsType {
std::atomic_bool stop, stopOnPonderhit;
Position rootPos;
Search::RootMoves rootMoves;
Depth rootDepth;
Position rootPos;
Search::RootMoves rootMoves;
Depth rootDepth;
Depth completedDepth;
std::atomic_bool resetCalls;
HistoryStats history;
MoveStats counterMoves;
Depth completedDepth;
std::atomic_bool resetCalls;
HistoryStats history;
MoveStats counterMoves;
CounterMoveHistoryStats counterMoveHistory;
};
CounterMoveHistoryStats counterMoveHistory;
};
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 };
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];
return make_score(mg_value(s) / i, eg_value(s) / i);
}
return make_score(mg_value(s) / i, eg_value(s) / i);
}
-extern Value PieceValue[PHASE_NB][PIECE_NB];
-
inline Color operator~(Color c) {
return Color(c ^ BLACK); // Toggle color
}
inline Color operator~(Color c) {
return Color(c ^ BLACK); // Toggle color
}
}
inline Square make_square(File f, Rank r) {
}
inline Square make_square(File f, Rank r) {
- return Square((r << 3) | f);
+ return Square((r << 3) + f);
}
inline Piece make_piece(Color c, PieceType pt) {
}
inline Piece make_piece(Color c, PieceType pt) {
}
inline Move make_move(Square from, Square to) {
}
inline Move make_move(Square from, Square to) {
- return Move(to | (from << 6));
+ return Move((from << 6) + to);
}
template<MoveType T>
inline Move make(Square from, Square to, PieceType pt = KNIGHT) {
}
template<MoveType T>
inline Move make(Square from, Square to, PieceType pt = KNIGHT) {
- return Move(to | (from << 6) | T | ((pt - KNIGHT) << 12));
+ return Move(T + ((pt - KNIGHT) << 12) + (from << 6) + to);
}
inline bool is_ok(Move m) {
}
inline bool is_ok(Move m) {