1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Fix indentation in struct FromToStats

And other little trivial stuff.

No functional change.
This commit is contained in:
Marco Costalba 2016-09-17 08:19:06 +02:00
parent 01f2466f6e
commit 057d710fc2
10 changed files with 49 additions and 54 deletions

View file

@ -28,6 +28,10 @@
#include "uci.h" #include "uci.h"
#include "syzygy/tbprobe.h" #include "syzygy/tbprobe.h"
namespace PSQT {
void init();
}
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
std::cout << engine_info() << std::endl; std::cout << engine_info() << std::endl;

View file

@ -277,7 +277,7 @@ Move MovePicker::next_move() {
case EVASIONS_INIT: case EVASIONS_INIT:
cur = moves; cur = moves;
endMoves = generate<EVASIONS>(pos, cur); endMoves = generate<EVASIONS>(pos, cur);
if (endMoves - cur > 1) if (endMoves - cur - (ttMove != MOVE_NONE) > 1)
score<EVASIONS>(); score<EVASIONS>();
++stage; ++stage;

View file

@ -26,7 +26,6 @@
#include "movegen.h" #include "movegen.h"
#include "position.h" #include "position.h"
#include "search.h"
#include "types.h" #include "types.h"
@ -45,9 +44,7 @@ struct Stats {
const T* operator[](Piece pc) const { return table[pc]; } const T* operator[](Piece pc) const { return table[pc]; }
T* operator[](Piece pc) { return table[pc]; } T* operator[](Piece pc) { return table[pc]; }
void clear() { std::memset(table, 0, sizeof(table)); } 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) { void update(Piece pc, Square to, Value v) {
if (abs(int(v)) >= 324) if (abs(int(v)) >= 324)
@ -70,29 +67,30 @@ struct FromToStats {
Value get(Color c, Move m) const { return table[c][from_sq(m)][to_sq(m)]; } 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 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) if (abs(int(v)) >= 324)
return; return;
Square f = from_sq(m); Square from = from_sq(m);
Square t = to_sq(m); Square to = to_sq(m);
table[c][f][t] -= table[c][f][t] * abs(int(v)) / 324; table[c][from][to] -= table[c][from][to] * abs(int(v)) / 324;
table[c][f][t] += int(v) * 32; table[c][from][to] += int(v) * 32;
} }
private: private:
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 /// 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 /// 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, /// 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 /// 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 /// beta algorithm, MovePicker attempts to return the moves which are most likely
/// to get a cut-off first. /// to get a cut-off first.
namespace Search { struct Stack; }
class MovePicker { class MovePicker {
public: public:

View file

@ -20,6 +20,7 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cstddef> // For offsetof()
#include <cstring> // For std::memset, std::memcmp #include <cstring> // For std::memset, std::memcmp
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
@ -34,6 +35,10 @@
using std::string; using std::string;
namespace PSQT {
extern Score psq[PIECE_NB][SQUARE_NB];
}
namespace Zobrist { namespace Zobrist {
Key psq[PIECE_NB][SQUARE_NB]; Key psq[PIECE_NB][SQUARE_NB];

View file

@ -22,25 +22,13 @@
#define POSITION_H_INCLUDED #define POSITION_H_INCLUDED
#include <cassert> #include <cassert>
#include <cstddef> // For offsetof()
#include <deque> #include <deque>
#include <memory> // For std::unique_ptr #include <memory> // For std::unique_ptr
#include <string> #include <string>
#include <vector>
#include "bitboard.h" #include "bitboard.h"
#include "types.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 /// 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 /// its previous state when we retract a move. Whenever a move is made on the
@ -58,7 +46,7 @@ struct StateInfo {
Score psq; Score psq;
Square epSquare; Square epSquare;
// Not copied when making a move // Not copied when making a move (will be recomputed anyhow)
Key key; Key key;
Bitboard checkersBB; Bitboard checkersBB;
Piece capturedPiece; Piece capturedPiece;
@ -76,9 +64,9 @@ typedef std::unique_ptr<std::deque<StateInfo>> StateListPtr;
/// pieces, side to move, hash keys, castling info, etc. Important methods are /// 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 /// do_move() and undo_move(), used by the search to update node info when
/// traversing the search tree. /// traversing the search tree.
class Thread;
class Position { class Position {
public: public:
static void init(); static void init();
@ -144,7 +132,7 @@ public:
void do_null_move(StateInfo& st); void do_null_move(StateInfo& st);
void undo_null_move(); void undo_null_move();
// Static exchange evaluation // Static Exchange Evaluation
Value see(Move m) const; Value see(Move m) const;
Value see_sign(Move m) const; Value see_sign(Move m) const;
@ -369,15 +357,13 @@ inline bool Position::is_chess960() const {
} }
inline bool Position::capture_or_promotion(Move m) const { inline bool Position::capture_or_promotion(Move m) const {
assert(is_ok(m)); assert(is_ok(m));
return type_of(m) != NORMAL ? type_of(m) != CASTLING : !empty(to_sq(m)); return type_of(m) != NORMAL ? type_of(m) != CASTLING : !empty(to_sq(m));
} }
inline bool Position::capture(Move m) const { inline bool Position::capture(Move m) const {
// Castling is encoded as "king captures the rook"
assert(is_ok(m)); assert(is_ok(m));
// 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;
} }
@ -405,7 +391,7 @@ inline void Position::remove_piece(Piece pc, Square s) {
// WARNING: This is not a reversible operation. If we remove a piece in // 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 // 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[] // 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[ALL_PIECES] ^= s;
byTypeBB[type_of(pc)] ^= s; byTypeBB[type_of(pc)] ^= s;
byColorBB[color_of(pc)] ^= s; byColorBB[color_of(pc)] ^= s;

View file

@ -29,6 +29,7 @@
#include "misc.h" #include "misc.h"
#include "movegen.h" #include "movegen.h"
#include "movepick.h" #include "movepick.h"
#include "position.h"
#include "search.h" #include "search.h"
#include "timeman.h" #include "timeman.h"
#include "thread.h" #include "thread.h"

View file

@ -25,11 +25,10 @@
#include <vector> #include <vector>
#include "misc.h" #include "misc.h"
#include "position.h" #include "movepick.h"
#include "types.h" #include "types.h"
template<typename T, bool CM> struct Stats; class Position;
typedef Stats<Value, true> CounterMoveStats;
namespace Search { namespace Search {
@ -49,6 +48,7 @@ struct Stack {
CounterMoveStats* counterMoves; CounterMoveStats* counterMoves;
}; };
/// RootMove struct is used for moves at the root of the tree. For each root move /// 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 /// 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. /// fail low). Score is normally set at -VALUE_INFINITE for all non-pv moves.
@ -68,6 +68,7 @@ struct RootMove {
typedef std::vector<RootMove> RootMoves; typedef std::vector<RootMove> RootMoves;
/// LimitsType struct stores information sent by GUI about available time to /// 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 /// 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. /// if we have to ponder while it's our opponent's turn to move.
@ -89,8 +90,9 @@ struct LimitsType {
TimePoint startTime; TimePoint startTime;
}; };
/// 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 { struct SignalsType {
std::atomic_bool stop, stopOnPonderhit; std::atomic_bool stop, stopOnPonderhit;

View file

@ -66,11 +66,11 @@ public:
Position rootPos; Position rootPos;
Search::RootMoves rootMoves; Search::RootMoves rootMoves;
Depth rootDepth; Depth rootDepth;
FromToStats fromTo;
Depth completedDepth; Depth completedDepth;
std::atomic_bool resetCalls; std::atomic_bool resetCalls;
HistoryStats history; HistoryStats history;
MoveStats counterMoves; MoveStats counterMoves;
FromToStats fromTo;
CounterMoveHistoryStats counterMoveHistory; CounterMoveHistoryStats counterMoveHistory;
}; };

View file

@ -207,6 +207,7 @@ enum Piece {
const Piece Pieces[] = { W_PAWN, W_KNIGHT, W_BISHOP, W_ROOK, W_QUEEN, W_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 }; B_PAWN, B_KNIGHT, B_BISHOP, B_ROOK, B_QUEEN, B_KING };
extern Value PieceValue[PHASE_NB][PIECE_NB];
enum Depth { enum Depth {
@ -329,8 +330,6 @@ inline Score operator/(Score s, int i) {
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) { inline Color operator~(Color c) {
return Color(c ^ BLACK); // Toggle color return Color(c ^ BLACK); // Toggle color
} }
@ -356,7 +355,7 @@ inline Value mated_in(int ply) {
} }
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) {
@ -422,12 +421,12 @@ inline PieceType promotion_type(Move m) {
} }
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> template<MoveType T>
inline Move make(Square from, Square to, PieceType pt = KNIGHT) { 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) {