Skip to content

Commit 9ee4b8b

Browse files
authored
Merge pull request official-stockfish#1685 from IIvec/master-1
New master
2 parents 406d6f0 + c53dc28 commit 9ee4b8b

File tree

10 files changed

+103
-89
lines changed

10 files changed

+103
-89
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Bruno de Melo Costa (BM123499)
4545
Bruno Pellanda (pellanda)
4646
Bryan Cross (crossbr)
4747
candirufish
48+
Carlos Esparza Sánchez (ces42)
4849
Chess13234
4950
Chris Cain (ceebo)
5051
Ciekce

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ where the source code can be found) to generate the exact binary you are
120120
distributing. If you make any changes to the source code, these changes must
121121
also be made available under GPL v3.
122122

123+
## Acknowledgements
124+
125+
Stockfish uses neural networks trained on [data provided by the Leela Chess Zero
126+
project][lc0-data-link], which is made available under the [Open Database License][odbl-link] (ODbL).
127+
123128

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

148155
[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
149156
[commits-badge]: https://img.shields.io/github/commits-since/official-stockfish/Stockfish/latest?style=for-the-badge

src/movepick.cpp

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818

1919
#include "movepick.h"
2020

21-
#include <algorithm>
2221
#include <array>
2322
#include <cassert>
2423
#include <limits>
25-
#include <utility>
2624

2725
#include "bitboard.h"
2826
#include "position.h"
@@ -158,11 +156,11 @@ void MovePicker::score() {
158156
Square to = m.to_sq();
159157

160158
// histories
161-
m.value = (*mainHistory)[pos.side_to_move()][m.from_to()];
159+
m.value = 2 * (*mainHistory)[pos.side_to_move()][m.from_to()];
162160
m.value += 2 * (*pawnHistory)[pawn_structure_index(pos)][pc][to];
163-
m.value += 2 * (*continuationHistory[0])[pc][to];
161+
m.value += (*continuationHistory[0])[pc][to];
164162
m.value += (*continuationHistory[1])[pc][to];
165-
m.value += (*continuationHistory[2])[pc][to] / 3;
163+
m.value += (*continuationHistory[2])[pc][to];
166164
m.value += (*continuationHistory[3])[pc][to];
167165
m.value += (*continuationHistory[5])[pc][to];
168166

@@ -199,19 +197,13 @@ void MovePicker::score() {
199197

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

205-
while (cur < endMoves)
206-
{
207-
if constexpr (T == Best)
208-
std::swap(*cur, *std::max_element(cur, endMoves));
209-
203+
for (; cur < endMoves; ++cur)
210204
if (*cur != ttMove && filter())
211205
return *cur++;
212206

213-
cur++;
214-
}
215207
return Move::none();
216208
}
217209

@@ -245,7 +237,7 @@ Move MovePicker::next_move() {
245237
goto top;
246238

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

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

288280
case BAD_CAPTURE :
289-
if (select<Next>([]() { return true; }))
281+
if (select([]() { return true; }))
290282
return *(cur - 1);
291283

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

299291
case BAD_QUIET :
300292
if (!skipQuiets)
301-
return select<Next>([]() { return true; });
293+
return select([]() { return true; });
302294

303295
return Move::none();
304296

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

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

313306
case EVASION :
314-
return select<Best>([]() { return true; });
307+
case QCAPTURE :
308+
return select([]() { return true; });
315309

316310
case PROBCUT :
317-
return select<Next>([&]() { return pos.see_ge(*cur, threshold); });
318-
319-
case QCAPTURE :
320-
return select<Next>([]() { return true; });
311+
return select([&]() { return pos.see_ge(*cur, threshold); });
321312
}
322313

323314
assert(false);

src/movepick.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ class Position;
3535
// a cut-off first.
3636
class MovePicker {
3737

38-
enum PickType {
39-
Next,
40-
Best
41-
};
42-
4338
public:
4439
MovePicker(const MovePicker&) = delete;
4540
MovePicker& operator=(const MovePicker&) = delete;
@@ -57,7 +52,7 @@ class MovePicker {
5752
void skip_quiet_moves();
5853

5954
private:
60-
template<PickType T, typename Pred>
55+
template<typename Pred>
6156
Move select(Pred);
6257
template<GenType>
6358
void score();

src/nnue/nnue_misc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ trace(Position& pos, const Eval::NNUE::Networks& networks, Eval::NNUE::Accumulat
126126
board[y][x] = board[y][x + 8] = board[y + 3][x + 8] = board[y + 3][x] = '+';
127127
if (pc != NO_PIECE)
128128
board[y + 1][x + 4] = PieceToChar[pc];
129-
if (value != VALUE_NONE)
129+
if (is_valid(value))
130130
format_cp_compact(value, &board[y + 2][x + 2], pos);
131131
};
132132

src/position.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void Position::set_state() const {
360360
{
361361
st->nonPawnMaterial[color_of(pc)] += PieceValue[pc];
362362

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

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

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

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

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

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

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

877877
else

src/score.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace Stockfish {
2929
Score::Score(Value v, const Position& pos) {
3030
assert(-VALUE_INFINITE < v && v < VALUE_INFINITE);
3131

32-
if (std::abs(v) < VALUE_TB_WIN_IN_MAX_PLY)
32+
if (!is_decisive(v))
3333
{
3434
score = InternalUnits{UCIEngine::to_cp(v, pos)};
3535
}

0 commit comments

Comments
 (0)