1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 09:13:08 +00:00

Some coding style changes, white space

This commit is contained in:
Joost VandeVondele 2020-08-01 09:20:39 +02:00
parent 6cd70676b4
commit 61ab908db3
6 changed files with 126 additions and 121 deletions

View file

@ -904,6 +904,7 @@ make_v:
/// evaluation of the position from the point of view of the side to move. /// evaluation of the position from the point of view of the side to move.
Value Eval::evaluate(const Position& pos) { Value Eval::evaluate(const Position& pos) {
if (Eval::useNNUE) if (Eval::useNNUE)
return NNUE::evaluate(pos); return NNUE::evaluate(pos);
else else
@ -956,7 +957,6 @@ std::string Eval::trace(const Position& pos) {
<< " Winnable | " << Term(WINNABLE) << " Winnable | " << Term(WINNABLE)
<< " ------------+-------------+-------------+------------\n" << " ------------+-------------+-------------+------------\n"
<< " Total | " << Term(TOTAL); << " Total | " << Term(TOTAL);
} }
v = pos.side_to_move() == WHITE ? v : -v; v = pos.side_to_move() == WHITE ? v : -v;

View file

@ -789,9 +789,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
remove_piece(capsq); remove_piece(capsq);
if (type_of(m) == ENPASSANT) if (type_of(m) == ENPASSANT)
{
board[capsq] = NO_PIECE; board[capsq] = NO_PIECE;
}
// Update material hash key and prefetch access to materialTable // Update material hash key and prefetch access to materialTable
k ^= Zobrist::psq[captured][capsq]; k ^= Zobrist::psq[captured][capsq];
@ -1009,7 +1007,8 @@ void Position::do_castling(Color us, Square from, Square& to, Square& rfrom, Squ
auto& dp = st->dirtyPiece; auto& dp = st->dirtyPiece;
dp.dirty_num = 2; // 2 pieces moved dp.dirty_num = 2; // 2 pieces moved
if (Do) { if (Do)
{
dp0 = piece_id_on(from); dp0 = piece_id_on(from);
dp1 = piece_id_on(rfrom); dp1 = piece_id_on(rfrom);
dp.pieceId[0] = dp0; dp.pieceId[0] = dp0;
@ -1021,7 +1020,8 @@ void Position::do_castling(Color us, Square from, Square& to, Square& rfrom, Squ
evalList.put_piece(dp1, rto, make_piece(us, ROOK)); evalList.put_piece(dp1, rto, make_piece(us, ROOK));
dp.new_piece[1] = evalList.piece_with_id(dp1); dp.new_piece[1] = evalList.piece_with_id(dp1);
} }
else { else
{
dp0 = piece_id_on(to); dp0 = piece_id_on(to);
dp1 = piece_id_on(rto); dp1 = piece_id_on(rto);
evalList.put_piece(dp0, from, make_piece(us, KING)); evalList.put_piece(dp0, from, make_piece(us, KING));
@ -1395,19 +1395,3 @@ bool Position::pos_is_ok() const {
return true; return true;
} }
StateInfo* Position::state() const {
return st;
}
const EvalList* Position::eval_list() const {
return &evalList;
}
PieceId Position::piece_id_on(Square sq) const
{
assert(piece_on(sq) != NO_PIECE);
PieceId pid = evalList.piece_id_list[sq];
assert(is_ok(pid));
return pid;
}

View file

@ -443,4 +443,25 @@ inline void Position::do_move(Move m, StateInfo& newSt) {
do_move(m, newSt, gives_check(m)); do_move(m, newSt, gives_check(m));
} }
inline StateInfo* Position::state() const {
return st;
}
inline const EvalList* Position::eval_list() const {
return &evalList;
}
inline PieceId Position::piece_id_on(Square sq) const
{
assert(piece_on(sq) != NO_PIECE);
PieceId pid = evalList.piece_id_list[sq];
assert(is_ok(pid));
return pid;
}
#endif // #ifndef POSITION_H_INCLUDED #endif // #ifndef POSITION_H_INCLUDED

View file

@ -213,6 +213,7 @@ enum PieceId {
}; };
inline PieceId operator++(PieceId& d, int) { inline PieceId operator++(PieceId& d, int) {
PieceId x = d; PieceId x = d;
d = PieceId(int(d) + 1); d = PieceId(int(d) + 1);
return x; return x;
@ -272,8 +273,7 @@ enum Rank : int {
}; };
// unique number for each piece type on each square // unique number for each piece type on each square
enum PieceSquare : uint32_t enum PieceSquare : uint32_t {
{
PS_NONE = 0, PS_NONE = 0,
PS_W_PAWN = 1, PS_W_PAWN = 1,
PS_B_PAWN = 1 * SQUARE_NB + 1, PS_B_PAWN = 1 * SQUARE_NB + 1,
@ -291,8 +291,7 @@ enum PieceSquare : uint32_t
PS_END2 = 12 * SQUARE_NB + 1 PS_END2 = 12 * SQUARE_NB + 1
}; };
struct ExtPieceSquare struct ExtPieceSquare {
{
PieceSquare from[COLOR_NB]; PieceSquare from[COLOR_NB];
}; };
@ -303,8 +302,8 @@ constexpr bool is_ok(PieceId pid);
constexpr Square rotate180(Square sq); constexpr Square rotate180(Square sq);
// Structure holding which tracked piece (PieceId) is where (PieceSquare) // Structure holding which tracked piece (PieceId) is where (PieceSquare)
class EvalList class EvalList {
{
public: public:
// Max. number of pieces without kings is 30 but must be a multiple of 4 in AVX2 // Max. number of pieces without kings is 30 but must be a multiple of 4 in AVX2
static const int MAX_LENGTH = 32; static const int MAX_LENGTH = 32;
@ -349,8 +348,8 @@ private:
}; };
// For differential evaluation of pieces that changed since last turn // For differential evaluation of pieces that changed since last turn
struct DirtyPiece struct DirtyPiece {
{
// Number of changed pieces // Number of changed pieces
int dirty_num; int dirty_num;

View file

@ -55,6 +55,7 @@ void on_use_nnue(const Option& o) {
} }
void on_eval_file(const Option& o) { void on_eval_file(const Option& o) {
load_eval_finished = false; load_eval_finished = false;
init_nnue(o); init_nnue(o);
} }