mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Fix indentation in struct FromToStats
And other little trivial stuff. No functional change.
This commit is contained in:
parent
01f2466f6e
commit
057d710fc2
10 changed files with 49 additions and 54 deletions
|
@ -419,11 +419,11 @@ namespace {
|
|||
// 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...
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
#include "uci.h"
|
||||
#include "syzygy/tbprobe.h"
|
||||
|
||||
namespace PSQT {
|
||||
void init();
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
std::cout << engine_info() << std::endl;
|
||||
|
|
|
@ -277,7 +277,7 @@ Move MovePicker::next_move() {
|
|||
case EVASIONS_INIT:
|
||||
cur = moves;
|
||||
endMoves = generate<EVASIONS>(pos, cur);
|
||||
if (endMoves - cur > 1)
|
||||
if (endMoves - cur - (ttMove != MOVE_NONE) > 1)
|
||||
score<EVASIONS>();
|
||||
++stage;
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "movegen.h"
|
||||
#include "position.h"
|
||||
#include "search.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
|
@ -45,9 +44,7 @@ struct Stats {
|
|||
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, Value v) {
|
||||
|
||||
if (abs(int(v)) >= 324)
|
||||
|
@ -68,31 +65,32 @@ typedef Stats<CounterMoveStats> CounterMoveHistoryStats;
|
|||
|
||||
struct FromToStats {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
/// 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:
|
||||
|
@ -118,7 +116,7 @@ private:
|
|||
Square recaptureSquare;
|
||||
Value threshold;
|
||||
int stage;
|
||||
ExtMove* cur, *endMoves, *endBadCaptures;
|
||||
ExtMove *cur, *endMoves, *endBadCaptures;
|
||||
ExtMove moves[MAX_MOVES];
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
|
||||
#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>
|
||||
|
||||
|
@ -34,6 +35,10 @@
|
|||
|
||||
using std::string;
|
||||
|
||||
namespace PSQT {
|
||||
extern Score psq[PIECE_NB][SQUARE_NB];
|
||||
}
|
||||
|
||||
namespace Zobrist {
|
||||
|
||||
Key psq[PIECE_NB][SQUARE_NB];
|
||||
|
|
|
@ -22,25 +22,13 @@
|
|||
#define POSITION_H_INCLUDED
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef> // For offsetof()
|
||||
#include <deque>
|
||||
#include <memory> // For std::unique_ptr
|
||||
#include <memory> // For std::unique_ptr
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#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
|
||||
|
@ -58,7 +46,7 @@ struct StateInfo {
|
|||
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;
|
||||
|
@ -76,9 +64,9 @@ typedef std::unique_ptr<std::deque<StateInfo>> StateListPtr;
|
|||
/// 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.
|
||||
class Thread;
|
||||
|
||||
class Position {
|
||||
|
||||
public:
|
||||
static void init();
|
||||
|
||||
|
@ -144,7 +132,7 @@ public:
|
|||
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;
|
||||
|
||||
|
@ -369,15 +357,13 @@ inline bool Position::is_chess960() 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 {
|
||||
|
||||
// Castling is encoded as "king captures the rook"
|
||||
assert(is_ok(m));
|
||||
// Castling is encoded as "king captures rook"
|
||||
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
|
||||
// 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;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "misc.h"
|
||||
#include "movegen.h"
|
||||
#include "movepick.h"
|
||||
#include "position.h"
|
||||
#include "search.h"
|
||||
#include "timeman.h"
|
||||
#include "thread.h"
|
||||
|
|
12
src/search.h
12
src/search.h
|
@ -25,11 +25,10 @@
|
|||
#include <vector>
|
||||
|
||||
#include "misc.h"
|
||||
#include "position.h"
|
||||
#include "movepick.h"
|
||||
#include "types.h"
|
||||
|
||||
template<typename T, bool CM> struct Stats;
|
||||
typedef Stats<Value, true> CounterMoveStats;
|
||||
class Position;
|
||||
|
||||
namespace Search {
|
||||
|
||||
|
@ -49,6 +48,7 @@ struct Stack {
|
|||
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.
|
||||
|
@ -68,6 +68,7 @@ struct RootMove {
|
|||
|
||||
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.
|
||||
|
@ -89,8 +90,9 @@ struct LimitsType {
|
|||
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 {
|
||||
std::atomic_bool stop, stopOnPonderhit;
|
||||
|
|
|
@ -66,11 +66,11 @@ public:
|
|||
Position rootPos;
|
||||
Search::RootMoves rootMoves;
|
||||
Depth rootDepth;
|
||||
FromToStats fromTo;
|
||||
Depth completedDepth;
|
||||
std::atomic_bool resetCalls;
|
||||
HistoryStats history;
|
||||
MoveStats counterMoves;
|
||||
FromToStats fromTo;
|
||||
CounterMoveHistoryStats counterMoveHistory;
|
||||
};
|
||||
|
||||
|
|
|
@ -207,6 +207,7 @@ enum Piece {
|
|||
|
||||
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 {
|
||||
|
||||
|
@ -329,8 +330,6 @@ inline Score operator/(Score s, int 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
|
||||
}
|
||||
|
@ -356,7 +355,7 @@ inline Value mated_in(int ply) {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -422,12 +421,12 @@ inline PieceType promotion_type(Move m) {
|
|||
}
|
||||
|
||||
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) {
|
||||
return Move(to | (from << 6) | T | ((pt - KNIGHT) << 12));
|
||||
return Move(T + ((pt - KNIGHT) << 12) + (from << 6) + to);
|
||||
}
|
||||
|
||||
inline bool is_ok(Move m) {
|
||||
|
|
Loading…
Add table
Reference in a new issue