Skip to content

Commit

Permalink
Merge branch 'official-stockfish:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
lantonov authored Dec 9, 2024
2 parents 5fce8b2 + cf10644 commit 0214004
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 89 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Bruno de Melo Costa (BM123499)
Bruno Pellanda (pellanda)
Bryan Cross (crossbr)
candirufish
Carlos Esparza Sánchez (ces42)
Chess13234
Chris Cain (ceebo)
Ciekce
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ where the source code can be found) to generate the exact binary you are
distributing. If you make any changes to the source code, these changes must
also be made available under GPL v3.

## Acknowledgements

Stockfish uses neural networks trained on [data provided by the Leela Chess Zero
project][lc0-data-link], which is made available under the [Open Database License][odbl-link] (ODbL).


[authors-link]: https://github.com/official-stockfish/Stockfish/blob/master/AUTHORS
[build-link]: https://github.com/official-stockfish/Stockfish/actions/workflows/stockfish.yml
Expand All @@ -144,6 +149,8 @@ also be made available under GPL v3.
[wiki-uci-link]: https://github.com/official-stockfish/Stockfish/wiki/UCI-&-Commands
[wiki-usage-link]: https://github.com/official-stockfish/Stockfish/wiki/Download-and-usage
[worker-link]: https://github.com/official-stockfish/fishtest/wiki/Running-the-worker
[lc0-data-link]: https://storage.lczero.org/files/training_data
[odbl-link]: https://opendatacommons.org/licenses/odbl/odbl-10.txt

[build-badge]: https://img.shields.io/github/actions/workflow/status/official-stockfish/Stockfish/stockfish.yml?branch=master&style=for-the-badge&label=stockfish&logo=github
[commits-badge]: https://img.shields.io/github/commits-since/official-stockfish/Stockfish/latest?style=for-the-badge
Expand Down
35 changes: 13 additions & 22 deletions src/movepick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@

#include "movepick.h"

#include <algorithm>
#include <array>
#include <cassert>
#include <limits>
#include <utility>

#include "bitboard.h"
#include "position.h"
Expand Down Expand Up @@ -158,11 +156,11 @@ void MovePicker::score() {
Square to = m.to_sq();

// histories
m.value = (*mainHistory)[pos.side_to_move()][m.from_to()];
m.value = 2 * (*mainHistory)[pos.side_to_move()][m.from_to()];
m.value += 2 * (*pawnHistory)[pawn_structure_index(pos)][pc][to];
m.value += 2 * (*continuationHistory[0])[pc][to];
m.value += (*continuationHistory[0])[pc][to];
m.value += (*continuationHistory[1])[pc][to];
m.value += (*continuationHistory[2])[pc][to] / 3;
m.value += (*continuationHistory[2])[pc][to];
m.value += (*continuationHistory[3])[pc][to];
m.value += (*continuationHistory[5])[pc][to];

Expand Down Expand Up @@ -199,19 +197,13 @@ void MovePicker::score() {

// Returns the next move satisfying a predicate function.
// This never returns the TT move, as it was emitted before.
template<MovePicker::PickType T, typename Pred>
template<typename Pred>
Move MovePicker::select(Pred filter) {

while (cur < endMoves)
{
if constexpr (T == Best)
std::swap(*cur, *std::max_element(cur, endMoves));

for (; cur < endMoves; ++cur)
if (*cur != ttMove && filter())
return *cur++;

cur++;
}
return Move::none();
}

Expand Down Expand Up @@ -245,7 +237,7 @@ Move MovePicker::next_move() {
goto top;

case GOOD_CAPTURE :
if (select<Next>([&]() {
if (select([&]() {
// Move losing capture to endBadCaptures to be tried later
return pos.see_ge(*cur, -cur->value / 18) ? true
: (*endBadCaptures++ = *cur, false);
Expand All @@ -269,7 +261,7 @@ Move MovePicker::next_move() {
[[fallthrough]];

case GOOD_QUIET :
if (!skipQuiets && select<Next>([]() { return true; }))
if (!skipQuiets && select([]() { return true; }))
{
if ((cur - 1)->value > -7998 || (cur - 1)->value <= quiet_threshold(depth))
return *(cur - 1);
Expand All @@ -286,7 +278,7 @@ Move MovePicker::next_move() {
[[fallthrough]];

case BAD_CAPTURE :
if (select<Next>([]() { return true; }))
if (select([]() { return true; }))
return *(cur - 1);

// Prepare the pointers to loop over the bad quiets
Expand All @@ -298,7 +290,7 @@ Move MovePicker::next_move() {

case BAD_QUIET :
if (!skipQuiets)
return select<Next>([]() { return true; });
return select([]() { return true; });

return Move::none();

Expand All @@ -307,17 +299,16 @@ Move MovePicker::next_move() {
endMoves = generate<EVASIONS>(pos, cur);

score<EVASIONS>();
partial_insertion_sort(cur, endMoves, std::numeric_limits<int>::min());
++stage;
[[fallthrough]];

case EVASION :
return select<Best>([]() { return true; });
case QCAPTURE :
return select([]() { return true; });

case PROBCUT :
return select<Next>([&]() { return pos.see_ge(*cur, threshold); });

case QCAPTURE :
return select<Next>([]() { return true; });
return select([&]() { return pos.see_ge(*cur, threshold); });
}

assert(false);
Expand Down
7 changes: 1 addition & 6 deletions src/movepick.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ class Position;
// a cut-off first.
class MovePicker {

enum PickType {
Next,
Best
};

public:
MovePicker(const MovePicker&) = delete;
MovePicker& operator=(const MovePicker&) = delete;
Expand All @@ -57,7 +52,7 @@ class MovePicker {
void skip_quiet_moves();

private:
template<PickType T, typename Pred>
template<typename Pred>
Move select(Pred);
template<GenType>
void score();
Expand Down
2 changes: 1 addition & 1 deletion src/nnue/nnue_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ trace(Position& pos, const Eval::NNUE::Networks& networks, Eval::NNUE::Accumulat
board[y][x] = board[y][x + 8] = board[y + 3][x + 8] = board[y + 3][x] = '+';
if (pc != NO_PIECE)
board[y + 1][x + 4] = PieceToChar[pc];
if (value != VALUE_NONE)
if (is_valid(value))
format_cp_compact(value, &board[y + 2][x + 2], pos);
};

Expand Down
8 changes: 4 additions & 4 deletions src/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ void Position::set_state() const {
{
st->nonPawnMaterial[color_of(pc)] += PieceValue[pc];

if (type_of(pc) == QUEEN || type_of(pc) == ROOK)
if (type_of(pc) >= ROOK)
st->majorPieceKey ^= Zobrist::psq[pc][s];

else
Expand Down Expand Up @@ -759,7 +759,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
st->nonPawnMaterial[them] -= PieceValue[captured];
st->nonPawnKey[them] ^= Zobrist::psq[captured][capsq];

if (type_of(captured) == QUEEN || type_of(captured) == ROOK)
if (type_of(captured) >= ROOK)
st->majorPieceKey ^= Zobrist::psq[captured][capsq];

else
Expand Down Expand Up @@ -844,7 +844,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
st->materialKey ^=
Zobrist::psq[promotion][pieceCount[promotion] - 1] ^ Zobrist::psq[pc][pieceCount[pc]];

if (promotionType == QUEEN || promotionType == ROOK)
if (promotionType >= ROOK)
st->majorPieceKey ^= Zobrist::psq[promotion][to];

else
Expand All @@ -871,7 +871,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
st->minorPieceKey ^= Zobrist::psq[pc][from] ^ Zobrist::psq[pc][to];
}

else if (type_of(pc) == QUEEN || type_of(pc) == ROOK)
else if (type_of(pc) >= ROOK)
st->majorPieceKey ^= Zobrist::psq[pc][from] ^ Zobrist::psq[pc][to];

else
Expand Down
2 changes: 1 addition & 1 deletion src/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Stockfish {
Score::Score(Value v, const Position& pos) {
assert(-VALUE_INFINITE < v && v < VALUE_INFINITE);

if (std::abs(v) < VALUE_TB_WIN_IN_MAX_PLY)
if (!is_decisive(v))
{
score = InternalUnits{UCIEngine::to_cp(v, pos)};
}
Expand Down
Loading

0 comments on commit 0214004

Please sign in to comment.