Skip to content

Commit

Permalink
Merge branch 'official-pikafish:master' into liground
Browse files Browse the repository at this point in the history
  • Loading branch information
williamgateszhao authored Jan 11, 2024
2 parents d0c2c75 + d462775 commit e868d48
Show file tree
Hide file tree
Showing 43 changed files with 354 additions and 316 deletions.
2 changes: 1 addition & 1 deletion src/benchmark.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2023 The Stockfish developers (see AUTHORS file)
Copyright (C) 2004-2024 The Stockfish developers (see AUTHORS file)
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/benchmark.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2023 The Stockfish developers (see AUTHORS file)
Copyright (C) 2004-2024 The Stockfish developers (see AUTHORS file)
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/bitboard.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2023 The Stockfish developers (see AUTHORS file)
Copyright (C) 2004-2024 The Stockfish developers (see AUTHORS file)
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
4 changes: 2 additions & 2 deletions src/bitboard.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2023 The Stockfish developers (see AUTHORS file)
Copyright (C) 2004-2024 The Stockfish developers (see AUTHORS file)
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -102,7 +102,7 @@ extern Magic BishopMagics[SQUARE_NB];
extern Magic KnightMagics[SQUARE_NB];
extern Magic KnightToMagics[SQUARE_NB];

constexpr Bitboard square_bb(Square s) {
inline Bitboard square_bb(Square s) {
assert(is_ok(s));
return SquareBB[s];
}
Expand Down
10 changes: 5 additions & 5 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2023 The Stockfish developers (see AUTHORS file)
Copyright (C) 2004-2024 The Stockfish developers (see AUTHORS file)
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -103,7 +103,7 @@ void NNUE::verify() {
// Returns a static, purely materialistic evaluation of the position from
// the point of view of the given color. It can be divided by PawnValue to get
// an approximation of the material advantage on the board in terms of pawns.
Value Eval::simple_eval(const Position& pos, Color c) {
int Eval::simple_eval(const Position& pos, Color c) {
return PawnValue * (pos.count<PAWN>(c) - pos.count<PAWN>(~c))
+ AdvisorValue * (pos.count<ADVISOR>(c) - pos.count<ADVISOR>(~c))
+ BishopValue * (pos.count<BISHOP>(c) - pos.count<BISHOP>(~c))
Expand All @@ -116,15 +116,15 @@ Value Eval::evaluate(const Position& pos) {

assert(!pos.checkers());

Value v;
int v;
Color stm = pos.side_to_move();
int shuffling = pos.rule60_count();
int simpleEval = simple_eval(pos, stm);

int nnueComplexity;
Value nnue = NNUE::evaluate(pos, true, &nnueComplexity);

Value optimism = pos.this_thread()->optimism[stm];
int optimism = pos.this_thread()->optimism[stm];

// Blend optimism and eval with nnue complexity and material imbalance
optimism += optimism * (nnueComplexity + std::abs(simpleEval - nnue)) / 708;
Expand All @@ -137,7 +137,7 @@ Value Eval::evaluate(const Position& pos) {
v = v * (263 - shuffling) / 192;

// Guarantee evaluation does not hit the mate range
v = std::clamp(v, VALUE_MATED_IN_MAX_PLY + 1, VALUE_MATE_IN_MAX_PLY - 1);
v = std::clamp(int(v), VALUE_MATED_IN_MAX_PLY + 1, VALUE_MATE_IN_MAX_PLY - 1);

return v;
}
Expand Down
4 changes: 2 additions & 2 deletions src/evaluate.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2023 The Stockfish developers (see AUTHORS file)
Copyright (C) 2004-2024 The Stockfish developers (see AUTHORS file)
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -31,7 +31,7 @@ namespace Eval {

std::string trace(Position& pos);

Value simple_eval(const Position& pos, Color c);
int simple_eval(const Position& pos, Color c);
Value evaluate(const Position& pos);

extern std::string currentEvalFileName;
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2023 The Stockfish developers (see AUTHORS file)
Copyright (C) 2004-2024 The Stockfish developers (see AUTHORS file)
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
Expand Down
2 changes: 1 addition & 1 deletion src/misc.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2023 The Stockfish developers (see AUTHORS file)
Copyright (C) 2004-2024 The Stockfish developers (see AUTHORS file)
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/misc.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2023 The Stockfish developers (see AUTHORS file)
Copyright (C) 2004-2024 The Stockfish developers (see AUTHORS file)
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
12 changes: 6 additions & 6 deletions src/movegen.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2023 The Stockfish developers (see AUTHORS file)
Copyright (C) 2004-2024 The Stockfish developers (see AUTHORS file)
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -72,7 +72,7 @@ ExtMove* generate_moves(const Position& pos, ExtMove* moveList, Bitboard target)
: (pos.check_squares(Pt) | HollowCannonDiscover);

while (b)
*moveList++ = make_move(from, pop_lsb(b));
*moveList++ = Move(from, pop_lsb(b));
}

return moveList;
Expand Down Expand Up @@ -106,7 +106,7 @@ ExtMove* generate_all(const Position& pos, ExtMove* moveList) {
b &= ~attacks_bb<ROOK>(OpponentKingSquare);

while (b)
*moveList++ = make_move(ksq, pop_lsb(b));
*moveList++ = Move(ksq, pop_lsb(b));
}

return moveList;
Expand Down Expand Up @@ -174,7 +174,7 @@ ExtMove* generate<EVASIONS>(const Position& pos, ExtMove* moveList) {
if (pt == ROOK || pt == CANNON)
b &= ~line_bb(checksq, ksq) | pos.pieces(~us);
while (b)
*moveList++ = make_move(ksq, pop_lsb(b));
*moveList++ = Move(ksq, pop_lsb(b));

// Generate move away hurdle piece evasions for cannon
if (pt == CANNON)
Expand All @@ -194,7 +194,7 @@ ExtMove* generate<EVASIONS>(const Position& pos, ExtMove* moveList) {
b = attacks_bb(pt, hurdleSq, pos.pieces()) & ~line_bb(checksq, hurdleSq)
& ~pos.pieces(us);
while (b)
*moveList++ = make_move(hurdleSq, pop_lsb(b));
*moveList++ = Move(hurdleSq, pop_lsb(b));
}
}

Expand All @@ -217,7 +217,7 @@ ExtMove* generate<LEGAL>(const Position& pos, ExtMove* moveList) {

while (cur != moveList)
if (!pos.legal(*cur))
*cur = (--moveList)->move;
*cur = *(--moveList);
else
++cur;

Expand Down
10 changes: 4 additions & 6 deletions src/movegen.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2023 The Stockfish developers (see AUTHORS file)
Copyright (C) 2004-2024 The Stockfish developers (see AUTHORS file)
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -37,12 +37,10 @@ enum GenType {
LEGAL
};

struct ExtMove {
Move move;
int value;
struct ExtMove: public Move {
int value;

operator Move() const { return move; }
void operator=(Move m) { move = m; }
void operator=(Move m) { data = m.raw(); }

// Inhibit unwanted implicit conversions to Move
// with an ambiguity that yields to a compile error.
Expand Down
Loading

0 comments on commit e868d48

Please sign in to comment.