1
0
Fork 0
Commit Graph

274 Commits (riscv64-cartesi)

Author SHA1 Message Date
bmc4 c4a1390f4e Simplify away the Reverse Move penalty
This simplifies the penalty for reverse move introduced in
https://github.com/official-stockfish/Stockfish/pull/2294 .

STC:
LLR: 2.94 (-2.94,2.94) <-2.25,0.25>
Total: 81696 W: 20627 L: 20540 D: 40529
Ptnml(0-2): 221, 9390, 21559, 9437, 241
https://tests.stockfishchess.org/tests/view/618810acd7a085ad008ef1cc

LTC:
LLR: 2.95 (-2.94,2.94) <-2.25,0.25>
Total: 44136 W: 11021 L: 10890 D: 22225
Ptnml(0-2): 28, 4570, 12746, 4691, 33
https://tests.stockfishchess.org/tests/view/61885686d7a085ad008ef20b

closes https://github.com/official-stockfish/Stockfish/pull/3781

bench: 6547978
2021-11-08 13:14:18 +01:00
Stéphane Nicolet 73018a0337 Detect search explosions
This patch detects some search explosions (due to double extensions in
search.cpp) which can happen in some pathological positions, and takes
measures to ensure progress in search even for these pathological situations.

While a small number of double extensions can be useful during search
(for example to resolve a tactical sequence), a sustained regime of
double extensions leads to search explosion and a non-finishing search.
See the discussion in https://github.com/official-stockfish/Stockfish/pull/3544
and the issue https://github.com/official-stockfish/Stockfish/issues/3532 .

The implemented algorithm is the following:

a) at each node during search, store the current depth in the stack.
   Double extensions are by definition levels of the stack where the
   depth at ply N is strictly higher than depth at ply N-1.

b) during search, calculate for each thread a running average of the
   number of double extensions in the last 4096 visited nodes.

c) if one thread has more than 2% of double extensions for a sustained
   period of time (6 millions consecutive nodes, or about 4 seconds on
   my iMac), we decide that this thread is in an explosion state and
   we calm down this thread by preventing it to do any double extension
   for the next 6 millions nodes.

To calculate the running averages, we also introduced a auxiliary class
generalizing the computations of ttHitAverage variable we already had in
code. The implementation uses an exponential moving average of period 4096
and resolution 1/1024, and all computations are done with integers for
efficiency.

-----------

Example where the patch solves a search explosion:

```
   ./stockfish
   ucinewgame
   position fen 8/Pk6/8/1p6/8/P1K5/8/6B1 w - - 37 130
   go infinite
```

This algorithm does not affect search in normal, non-pathological positions.
We verified, for instance, that the usual bench is unchanged up to depth 20
at least, and that the node numbers are unchanged for a search of the starting
position at depth 32.

-------------

See https://github.com/official-stockfish/Stockfish/pull/3714

Bench: 5575265
2021-09-23 23:19:06 +02:00
Stéphane Nicolet 754fc8a8b5 Remove Tempo
The Tempo variable was introduced 10 years ago in our search because the
classical evaluation function was antisymmetrical in White and Black by design
to gain speed:

    Eval(White to play) = -Eval(Black to play)

Nowadays our neural networks know which side is to play in a position when
they evaluate a position and are trained on real games, so the neural network
encodes the advantage of moving as an output of search. This patch shows that
the Tempo variable is not necessary anymore.

STC:
LLR: 2.94 (-2.94,2.94) <-2.50,0.50>
Total: 33512 W: 2805 L: 2709 D: 27998
Ptnml(0-2): 80, 2209, 12095, 2279, 93
https://tests.stockfishchess.org/tests/view/60a44ceace8ea25a3ef03d30

LTC:
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 53920 W: 1807 L: 1760 D: 50353
Ptnml(0-2): 16, 1617, 23650, 1658, 19
https://tests.stockfishchess.org/tests/view/60a477f0ce8ea25a3ef03d49

We also tried a match (20000 games) at STC using purely classical, result was neutral:
https://tests.stockfishchess.org/tests/view/60a4eebcce8ea25a3ef03db5

Note: there are two locations left in search.cpp where we assume antisymmetry
of evaluation (in relation with a speed optimization for null moves in lines
770 and 1439), but as the values are just used for heuristic pruning this
approximation should not hurt too much because the order of magnitude is still
true most of the time.

closes https://github.com/official-stockfish/Stockfish/pull/3481

Bench: 4015864
2021-05-19 20:34:37 +02:00
Dieter Dobbelaere 7ffae17f85 Add Stockfish namespace.
fixes #3350 and is a small cleanup that might make it easier to use SF
in separate projects, like a NNUE trainer or similar.

closes https://github.com/official-stockfish/Stockfish/pull/3370

No functional change.
2021-03-07 14:26:54 +01:00
Dieter Dobbelaere 87586b3d0c Use correct chess terms + fix spelling.
- "discovered check" (instead of "discovery check")
  - "en passant" (instead of "en-passant")
  - "pseudo-legal" before a noun (instead of "pseudo legal")
  - "3-fold" (instead of "3fold")

closes https://github.com/official-stockfish/Stockfish/pull/3294

No functional change.
2021-01-11 19:19:39 +01:00
Joost VandeVondele c4d67d77c9 Update copyright years
No functional change
2021-01-08 17:04:23 +01:00
Stéphane Nicolet 027626db1e Small cleanups 13
No functional change
2020-11-23 22:20:32 +01:00
Tomasz Sobczyk 3f6451eff7 Manually align arrays on the stack
as a workaround to issues with overaligned alignas() on stack variables in gcc < 9.3 on windows.

closes https://github.com/official-stockfish/Stockfish/pull/3217

fixes #3216

No functional change
2020-11-04 19:52:42 +01:00
syzygy1 9b4967071e Remove EvalList
This patch removes the EvalList structure from the Position object and generally simplifies the interface between do_move() and the NNUE code.

The NNUE evaluation function first calculates the "accumulator". The accumulator consists of two halves: one for white's perspective, one for black's perspective.

If the "friendly king" has moved or the accumulator for the parent position is not available, the accumulator for this half has to be calculated from scratch. To do this, the NNUE node needs to know the positions and types of all non-king pieces and the position of the friendly king. This information can easily be obtained from the Position object.

If the "friendly king" has not moved, its half of the accumulator can be calculated by incrementally updating the accumulator for the previous position. For this, the NNUE code needs to know which pieces have been added to which squares and which pieces have been removed from which squares. In principle this information can be derived from the Position object and StateInfo struct (in the same way as undo_move() does this). However, it is probably a bit faster to prepare this information in do_move(), so I have kept the DirtyPiece struct. Since the DirtyPiece struct now stores the squares rather than "PieceSquare" indices, there are now at most three "dirty pieces" (previously two). A promotion move that captures a piece removes the capturing pawn and the captured piece from the board (to SQ_NONE) and moves the promoted piece to the promotion square (from SQ_NONE).

An STC test has confirmed a small speedup:

https://tests.stockfishchess.org/tests/view/5f43f06b5089a564a10d850a
LLR: 2.94 (-2.94,2.94) {-0.25,1.25}
Total: 87704 W: 9763 L: 9500 D: 68441
Ptnml(0-2): 426, 6950, 28845, 7197, 434

closes https://github.com/official-stockfish/Stockfish/pull/3068

No functional change
2020-08-26 07:11:26 +02:00
Sami Kiminki f7b3f0e842 Allow TT entries with key16==0 to be fetched
Fix the issue where a TT entry with key16==0 would always be reported
as a miss. Instead, we'll use depth8 to detect whether the TT entry is
occupied. In order to do that, we'll change DEPTH_OFFSET to -7
(depth8==0) to distinguish between an unoccupied entry and the
otherwise lowest possible depth, i.e., DEPTH_NONE (depth8==1).

To prevent a performance regression, we'll reorder the TT entry fields
by the access order of TranspositionTable::probe(). Memory in general
works fastest when accessed in sequential order. We'll also match the
store order in TTEntry::save() with the entry field order, and
re-order the 'if-or' expressions in TTEntry::save() from the cheapest
to the most expensive.

Finally, as we now have a proper TT entry occupancy test, we'll fix a
minor corner case with hashfull reporting. To reproduce:
- Use a big hash
- Either:
  a. Start 31 very quick searches (this wraparounds generation to 0); or
  b. Force generation of the first search to 0.
- go depth infinite

Before the fix, hashfull would incorrectly report nearly full hash
immediately after the search start, since
TranspositionTable::hashfull() used to consider only the entry
generation and not whether the entry was actually occupied.

STC:
LLR: 2.95 (-2.94,2.94) {-0.25,1.25}
Total: 36848 W: 4091 L: 3898 D: 28859
Ptnml(0-2): 158, 2996, 11972, 3091, 207
https://tests.stockfishchess.org/tests/view/5f3f98d5dc02a01a0c2881f7

LTC:
LLR: 2.95 (-2.94,2.94) {0.25,1.25}
Total: 32280 W: 1828 L: 1653 D: 28799
Ptnml(0-2): 34, 1428, 13051, 1583, 44
https://tests.stockfishchess.org/tests/view/5f3fe77a87a5c3c63d8f5332

closes https://github.com/official-stockfish/Stockfish/pull/3048

Bench: 3760677
2020-08-24 12:03:28 +02:00
FauziAkram af935365e3 Tuned pawn values
Passed STC:
https://tests.stockfishchess.org/tests/view/5f2aa49fa5abc164f05e4d1b
LLR: 2.95 (-2.94,2.94) {-0.50,1.50}
Total: 40888 W: 7977 L: 7726 D: 25185
Ptnml(0-2): 665, 4806, 9333, 4893, 747

Passed LTC:
https://tests.stockfishchess.org/tests/view/5f2b1059b3ebe5cbfee85ae7
LLR: 2.98 (-2.94,2.94) {0.25,1.75}
Total: 51264 W: 6445 L: 6134 D: 38685
Ptnml(0-2): 328, 4564, 15580, 4789, 371

closes https://github.com/official-stockfish/Stockfish/pull/2920

bench: 4314943
2020-08-07 08:57:37 +02:00
nodchip 84f3e86790 Add NNUE evaluation
This patch ports the efficiently updatable neural network (NNUE) evaluation to Stockfish.

Both the NNUE and the classical evaluations are available, and can be used to
assign a value to a position that is later used in alpha-beta (PVS) search to find the
best move. The classical evaluation computes this value as a function of various chess
concepts, handcrafted by experts, tested and tuned using fishtest. The NNUE evaluation
computes this value with a neural network based on basic inputs. The network is optimized
and trained on the evalutions of millions of positions at moderate search depth.

The NNUE evaluation was first introduced in shogi, and ported to Stockfish afterward.
It can be evaluated efficiently on CPUs, and exploits the fact that only parts
of the neural network need to be updated after a typical chess move.
[The nodchip repository](https://github.com/nodchip/Stockfish) provides additional
tools to train and develop the NNUE networks.

This patch is the result of contributions of various authors, from various communities,
including: nodchip, ynasu87, yaneurao (initial port and NNUE authors), domschl, FireFather,
rqs, xXH4CKST3RXx, tttak, zz4032, joergoster, mstembera, nguyenpham, erbsenzaehler,
dorzechowski, and vondele.

This new evaluation needed various changes to fishtest and the corresponding infrastructure,
for which tomtor, ppigazzini, noobpwnftw, daylen, and vondele are gratefully acknowledged.

The first networks have been provided by gekkehenker and sergiovieri, with the latter
net (nn-97f742aaefcd.nnue) being the current default.

The evaluation function can be selected at run time with the `Use NNUE` (true/false) UCI option,
provided the `EvalFile` option points the the network file (depending on the GUI, with full path).

The performance of the NNUE evaluation relative to the classical evaluation depends somewhat on
the hardware, and is expected to improve quickly, but is currently on > 80 Elo on fishtest:

60000 @ 10+0.1 th 1
https://tests.stockfishchess.org/tests/view/5f28fe6ea5abc164f05e4c4c
ELO: 92.77 +-2.1 (95%) LOS: 100.0%
Total: 60000 W: 24193 L: 8543 D: 27264
Ptnml(0-2): 609, 3850, 9708, 10948, 4885

40000 @ 20+0.2 th 8
https://tests.stockfishchess.org/tests/view/5f290229a5abc164f05e4c58
ELO: 89.47 +-2.0 (95%) LOS: 100.0%
Total: 40000 W: 12756 L: 2677 D: 24567
Ptnml(0-2): 74, 1583, 8550, 7776, 2017

At the same time, the impact on the classical evaluation remains minimal, causing no significant
regression:

sprt @ 10+0.1 th 1
https://tests.stockfishchess.org/tests/view/5f2906a2a5abc164f05e4c5b
LLR: 2.94 (-2.94,2.94) {-6.00,-4.00}
Total: 34936 W: 6502 L: 6825 D: 21609
Ptnml(0-2): 571, 4082, 8434, 3861, 520

sprt @ 60+0.6 th 1
https://tests.stockfishchess.org/tests/view/5f2906cfa5abc164f05e4c5d
LLR: 2.93 (-2.94,2.94) {-6.00,-4.00}
Total: 10088 W: 1232 L: 1265 D: 7591
Ptnml(0-2): 49, 914, 3170, 843, 68

The needed networks can be found at https://tests.stockfishchess.org/nns
It is recommended to use the default one as indicated by the `EvalFile` UCI option.

Guidelines for testing new nets can be found at
https://github.com/glinscott/fishtest/wiki/Creating-my-first-test#nnue-net-tests

Integration has been discussed in various issues:
https://github.com/official-stockfish/Stockfish/issues/2823
https://github.com/official-stockfish/Stockfish/issues/2728

The integration branch will be closed after the merge:
https://github.com/official-stockfish/Stockfish/pull/2825
https://github.com/official-stockfish/Stockfish/tree/nnue-player-wip

closes https://github.com/official-stockfish/Stockfish/pull/2912

This will be an exciting time for computer chess, looking forward to seeing the evolution of
this approach.

Bench: 4746616
2020-08-06 16:37:45 +02:00
mstembera de24fcebc8 Fix fragile code to use proper random 64 bit keys.
This fixes an old issue where we want to make a position unique but only
change a small number of bits in the key instead of all 64 of them randomly.
This is fragile and can lead to non uniqueness issues in the TT.

Key make_key(uint64_t seed) takes any integer and produces a unique random 64 bit key.
It is computationally efficient and is based on a congruential pseudo random number
generator using well tested constants by Donald Knuth
(see https://en.wikipedia.org/wiki/Linear_congruential_generator)

STC https://tests.stockfishchess.org/tests/view/5ef6c78f761b685b4c724bb6
LLR: 2.95 (-2.94,2.94) {-1.50,0.50}
Total: 154320 W: 29343 L: 29376 D: 95601
Ptnml(0-2): 2543, 18170, 35891, 17889, 2667

LTC https://tests.stockfishchess.org/tests/view/5ef7d1a9020eec13834a940e
LLR: 2.95 (-2.94,2.94) {-1.50,0.50}
Total: 53488 W: 6629 L: 6584 D: 40275
Ptnml(0-2): 372, 4878, 16183, 4955, 356

closes https://github.com/official-stockfish/Stockfish/pull/2773

bench: 4626776
2020-06-28 21:57:37 +02:00
Joost VandeVondele ab5cd8340f Small cleanups
closes https://github.com/official-stockfish/Stockfish/pull/2756

No functional change
2020-06-24 22:20:04 +02:00
Joost VandeVondele 6f15e7fab2 small cleanups
closes https://github.com/official-stockfish/Stockfish/pull/2695

No functional change
2020-06-21 15:22:20 +02:00
Moez Jellouli 66ed8b6c47 Tune pawn value
Small tune of PawnValue parameters -4 / -7 with "closedpos.epd" opening book.

STC:
LLR: 2.96 (-2.94,2.94) {-0.50,1.50}
Total: 58776 W: 11787 L: 11511 D: 35478
Ptnml(0-2): 975, 6876, 13443, 7086, 1008
https://tests.stockfishchess.org/tests/view/5eb5aa712326444a3b6d3e33

LTC:
LLR: 2.98 (-2.94,2.94) {0.25,1.75}
Total: 137544 W: 19687 L: 19115 D: 98742
Ptnml(0-2): 988, 13219, 39901, 13561, 1103
https://tests.stockfishchess.org/tests/view/5eb67a392326444a3b6d3e9a

Non regression STC with "noob_3moves.epd" opening book
LLR: 2.94 (-2.94,2.94) {-1.50,0.50}
Total: 98168 W: 18545 L: 18499 D: 61124
Ptnml(0-2): 1647, 11396, 22951, 11444, 1646
https://tests.stockfishchess.org/tests/view/5eb7e489e0300e8e8c896203

closes https://github.com/official-stockfish/Stockfish/pull/2670

Bench 4696646
2020-05-11 20:46:39 +02:00
Marco Costalba c527c3ad44 Fishtest Tuning Framework
The purpose of the code is to allow developers to easily and flexibly
setup SF for a tuning session. Mainly you have just to remove 'const'
qualifiers from the variables you want to tune and flag them for
tuning, so if you have:

int myKing = 10;
Score myBonus = S(5, 15);
Value myValue[][2] = { { V(100), V(20) }, { V(7), V(78) } };

and at the end of the update you may want to call
a post update function:

void my_post_update();

If instead of default Option's min-max values,
you prefer your custom ones, returned by:

std::pair<int, int> my_range(int value)

Or you jus want to set the range directly, you can
simply add below:

TUNE(SetRange(my_range), myKing, SetRange(-200, 200), myBonus, myValue, my_post_update);

And all the magic happens :-)

At startup all the parameters are printed in a
format suitable to be copy-pasted in fishtest.

In case the post update function is slow and you have many
parameters to tune, you can add:

UPDATE_ON_LAST();

And the values update, including post update function call, will
be done only once, after the engine receives the last UCI option.
The last option is the one defined and created as the last one, so
this assumes that the GUI sends the options in the same order in
which have been defined.

closes https://github.com/official-stockfish/Stockfish/pull/2654

No functional change.
2020-05-02 17:32:11 +02:00
Joost VandeVondele f83cb95740 Small cleanups
closes https://github.com/official-stockfish/Stockfish/pull/2606

No functional change
2020-04-12 20:30:08 +02:00
Joost VandeVondele ddcbacd04d Small cleanups
closes https://github.com/official-stockfish/Stockfish/pull/2567

No functional change.
2020-03-14 17:04:50 +01:00
protonspring 47be966d30 Equations for edges and corners.
This is a functional simplification that removes the large arrays in endgames.cpp.
It also fixes a recently introduced bug (960d59d541) in KNBvK,
now using flip_file() instead of ~.

One fen added to bench to increase endgame coverage.

STC
LLR: 2.94 (-2.94,2.94) {-1.50,0.50}
Total: 174724 W: 33325 L: 33404 D: 107995
Ptnml(0-2): 2503, 19607, 43181, 19608, 2463
http://tests.stockfishchess.org/tests/view/5e6448ffe42a5c3b3ca2e287

LTC
LLR: 2.95 (-2.94,2.94) {-1.50,0.50}
Total: 35640 W: 4679 L: 4621 D: 26340
Ptnml(0-2): 189, 2991, 11424, 3005, 211
http://tests.stockfishchess.org/tests/view/5e650b24e42a5c3b3ca2e2d8

closes https://github.com/official-stockfish/Stockfish/pull/2577

Bench: 5527957
2020-03-09 22:16:26 +01:00
protonspring 960d59d541 Consolidate Square Flipping
Add a flip_rank() and flip_file() so that all of the square flipping can be consolidated.

STC
LLR: 2.94 (-2.94,2.94) {-1.50,0.50}
Total: 57234 W: 11064 L: 10969 D: 35201
Ptnml(0-2): 822, 6562, 13801, 6563, 869
http://tests.stockfishchess.org/tests/view/5e5d2f2aafe6254521f2ffaa

closes https://github.com/official-stockfish/Stockfish/pull/2568

No functional change.
2020-03-04 07:11:48 +01:00
Joost VandeVondele c6839a2615 Small cleanups
closes https://github.com/official-stockfish/Stockfish/pull/2546

No functional change.
2020-03-01 09:31:58 +01:00
Joost VandeVondele be5a2f015e Fix for incorrect VALUE_MATE_IN_MAX_PLY usage.
Fixes #2533, fixes #2543, fixes #2423.

the code that prevents false mate announcements depending on the TT
state (GHI), incorrectly used VALUE_MATE_IN_MAX_PLY. The latter
constant, however, also includes, counterintuitively, the TB win range.

This patch fixes that, by restoring the behavior for TB win scores,
while retaining the false mate correctness, and improving the mate
finding ability. In particular

no alse mates are announced with the poisened hash testcase
```
position fen 8/8/8/3k4/8/8/6K1/7R w - - 0 1
go depth 40
position fen 8/8/8/3k4/8/8/6K1/7R w - - 76 1
go depth 20
ucinewgame
```

mates are found with the testcases reported in #2543
```
position fen 4k3/3pp3/8/8/8/8/2PPP3/4K3 w - - 0 1
setoption name Hash value 1024
go depth 55
ucinewgame
```
and
```
position fen 4k3/4p3/8/8/8/8/3PP3/4K3 w - - 0 1
setoption name Hash value 1024
go depth 45
ucinewgame
```

furthermore, on the mate finding benchmark (ChestUCI_23102018.epd),
performance improves over master, roughly reaching performance with the
false mate protection reverted
```
Analyzing 6566 mate positions for best and found mates:

                 ----------------best ---------------found
           nodes master revert  fixed master revert  fixed
        16000000   4233   4236   4235   5200   5201   5199
        32000000   4583   4585   4585   5417   5424   5418
        64000000   4852   4853   4855   5575   5584   5579
       128000000   5071   5068   5066   5710   5720   5716
       256000000   5280   5282   5279   5819   5827   5826
       512000000   5471   5468   5468   5919   5935   5932
```

On a testcase with TB enabled, progress is made consistently, contrary
to master
```
setoption name SyzygyPath value ../../../syzygy/3-4-5/
setoption name Hash value 2048
position fen 1R6/3k4/8/K2p4/4n3/2P5/8/8 w - - 0 1
go depth 58
ucinewgame
```

The PR (prior to a rewrite for clarity)

passed STC:
LLR: 2.94 (-2.94,2.94) {-1.50,0.50}
Total: 65405 W: 12454 L: 12384 D: 40567
Ptnml(0-2): 920, 7256, 16285, 7286, 944
http://tests.stockfishchess.org/tests/view/5e441a3be70d848499f63d15

passed LTC:
LLR: 2.94 (-2.94,2.94) {-1.50,0.50}
Total: 27096 W: 3477 L: 3413 D: 20206
Ptnml(0-2): 128, 2215, 8776, 2292, 122
http://tests.stockfishchess.org/tests/view/5e44e277e70d848499f63d63

The incorrectly named VALUE_MATE_IN_MAX_PLY and VALUE_MATED_IN_MAX_PLY
were renamed into VALUE_TB_WIN_IN_MAX_PLY and VALUE_TB_LOSS_IN_MAX_PLY,
and correclty defined VALUE_MATE_IN_MAX_PLY and VALUE_MATED_IN_MAX_PLY
were introduced.

One further (corner case) mistake using these constants was fixed (go
mate X), which could lead to a premature return if X > MAX_PLY / 2,
but TB were present.

Thanks to @svivanov72 for one of the reports and help fixing the issue.

closes https://github.com/official-stockfish/Stockfish/pull/2552

Bench: 4932981
2020-02-15 15:10:07 +01:00
Alain SAVARD 09bef14c76 Update lists of authors and contributors
Preparing for version 11 of Stockfish: update lists of authors,
contributors giving CPU time to the fishtest framework, etc.

No functional change
2020-01-09 01:43:47 +01:00
SFisGOD 474d133565 Combo of Parameter Tweaks
This patch is a combo of the following tweaks:

Complexity parameters
Knight PSQT
Bishop PSQT
King PSQT
Piece Values

Passed STC:
LLR: 2.95 (-2.94,2.94) [-1.50,4.50]
Total: 56527 W: 12326 L: 12052 D: 32149
http://tests.stockfishchess.org/tests/view/5dbbca3f0ebc5925b64ee6d6

Passed LTC:
LLR: 2.95 (-2.94,2.94) [0.00,3.50]
Total: 64010 W: 10549 L: 10199 D: 43262
http://tests.stockfishchess.org/tests/view/5dbc30dc0ebc5925b64eee0c

Closes https://github.com/official-stockfish/Stockfish/pull/2390

Bench: 4312945
2019-11-02 21:19:35 +01:00
Stéphane Nicolet 90c0385724 Assorted trivial cleanups
- Cleanups by Alain
- Group king attacks and king defenses
- Signature of futility_move_count()
- Use is_discovery_check_on_king()
- Simplify backward definition
- Use static asserts in move generator
- Factor a statement in move generator

No functional change
2019-10-26 00:29:12 +02:00
Brian Sheppard ca7d4e9ac7 Eliminate ONE_PLY
Simplification that eliminates ONE_PLY, based on a suggestion in the forum that
support for fractional plies has never been used, and @mcostalba's openness to
the idea of eliminating it. We lose a little bit of type safety by making Depth
an integer, but in return we simplify the code in search.cpp quite significantly.

No functional change

------------------------------------------

The argument favoring eliminating ONE_PLY:

* The term “ONE_PLY” comes up in a lot of forum posts (474 to date)
https://groups.google.com/forum/?fromgroups=#!searchin/fishcooking/ONE_PLY%7Csort:relevance

* There is occasionally a commit that breaks invariance of the code
with respect to ONE_PLY
https://groups.google.com/forum/?fromgroups=#!searchin/fishcooking/ONE_PLY%7Csort:date/fishcooking/ZIPdYj6k0fk/KdNGcPWeBgAJ

* To prevent such commits, there is a Travis CI hack that doubles ONE_PLY
and rechecks bench

* Sustaining ONE_PLY has, alas, not resulted in any improvements to the
  engine, despite many individuals testing many experiments over 5 years.

The strongest argument in favor of preserving ONE_PLY comes from @locutus:
“If we use par example ONE_PLY=256 the parameter space is increases by the
factor 256. So it seems very unlikely that the optimal setting is in the
subspace of ONE_PLY=1.”

There is a strong theoretical impediment to fractional depth systems: the
transposition table uses depth to determine when a stored result is good
enough to supply an answer for a current search. If you have fractional
depths, then different pathways to the position can be at fractionally
different depths.

In the end, there are three separate times when a proposal to remove ONE_PLY
was defeated by the suggestion to “give it a few more months.” So… it seems
like time to remove this distraction from the community.

See the pull request here:
https://github.com/official-stockfish/Stockfish/pull/2289
2019-10-06 00:57:00 +02:00
nickpelling d232a4ae68 Clarify the mapping of files to queenside
This patch replaces the obscure expressions mapping files ABCDEFGH to ABCDDCBA
by explicite calls to an auxiliary function:

  old:   f = min(f, ~f)
  new:   f = map_to_queenside(f)

We used the Golbolt web site (https://godbolt.org) to check that the current
code for the auxiliary function is optimal.

STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 30292 W: 6756 L: 6651 D: 16885
http://tests.stockfishchess.org/tests/view/5d8676720ebc5971531d6aa1

Achieved with a bit of help from Sopel97, snicolet and vondele, thanks everyone!
Closes https://github.com/official-stockfish/Stockfish/pull/2325

No functional change
2019-09-24 10:05:54 +02:00
Stéphane Nicolet 302e0f70c6 Revert "Clarify the mapping of files to queenside"
This reverts commit 7756344d5d.
2019-09-23 09:10:28 +02:00
Stéphane Nicolet 7756344d5d Clarify the mapping of files to queenside
Author: @nickpelling

We replace in the code the obscure expressions mapping files ABCDEFGH to ABCDDCBA
by an explicite call to an auxiliary function :

  old:   f = min(f, ~f)
  new:   f = map_to_queenside(f)

We used the Golbolt web site (https://godbolt.org) to find the optimal code
for the auxiliary function.

STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 30292 W: 6756 L: 6651 D: 16885
http://tests.stockfishchess.org/tests/view/5d8676720ebc5971531d6aa1

No functional change
2019-09-23 08:54:20 +02:00
protonspring 270b241ec1 Simplify Weak Lever
This is a simplification that integrated WeakLever into doubled pawns.
Since we already check for !support for Doubled pawns, it is trivial
to check for weak lever by just checking more_than_one(lever).

We also introduce the Score * bool operation overload to remove some
casts in the code.

STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 26757 W: 5842 L: 5731 D: 15184
http://tests.stockfishchess.org/tests/view/5d77ee220ebc5902d384e5a4

Closes https://github.com/official-stockfish/Stockfish/pull/2295

No functional change
2019-09-12 09:44:40 +02:00
Stefan Geschwentner 61f44ce578 Update reverse move stats
For a good quiet non-pawn move consider the reverse move as bad
and update the main history with a negative stat bonus.

STC:
LLR: 2.95 (-2.94,2.94) [0.50,4.50]
Total: 19292 W: 4401 L: 4141 D: 10750
http://tests.stockfishchess.org/tests/view/5d7751d50ebc594e7864973c

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,3.50]
Total: 111952 W: 18762 L: 18275 D: 74915
http://tests.stockfishchess.org/tests/view/5d7771cf0ebc594e786498fa

Closes https://github.com/official-stockfish/Stockfish/pull/2294

Bench: 3914238
2019-09-11 18:37:08 +02:00
protonspring 3984b8f8f0 Consolidate CastlingSide and CastlingRights
This is a non-functional simplification that removes CastlingSide and
implements the functionality in CastlingRights (thanks to Jörg Oster
for a comment on the first version of this patch).

STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 53854 W: 12077 L: 12019 D: 29758
http://tests.stockfishchess.org/tests/view/5d517b940ebc5925cf107474

Closes https://github.com/official-stockfish/Stockfish/pull/2265

No functional change
2019-08-23 16:29:29 +02:00
protonspring aec918a2b6 Remove operators for color
This is a non-functional and untested simplification. The increment operator
for color isn't really necessary and seems a bit unnatural to me.

Passed STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 47027 W: 10589 L: 10518 D: 25920
http://tests.stockfishchess.org/tests/view/5d3472d10ebc5925cf0e8d3e

Closes https://github.com/official-stockfish/Stockfish/pull/2247

No functional change
2019-07-26 02:12:23 +02:00
Sergei Ivanov 8b4521df83 Do not define increment operators on Value, Depth and Direction
These operators are never used and do not make sense for these types.

No functional change.
2019-06-27 09:05:03 +02:00
Marco Costalba d39bc2efa1 Assorted trivial cleanups 5/2019
No functional change.

bench: 4178282
2019-06-09 14:57:08 +02:00
Joost VandeVondele 893a08a8c2 Allow for higher depths. (#2147)
High rootDepths, selDepths and generally searches are increasingly
common with long time control games, analysis, and improving hardware.
In this case, depths of MAX_DEPTH/MAX_PLY (128) can be reached,
and the search tree is truncated.

In principle MAX_PLY can be easily increased, except for a technicality
of storing depths in a signed 8 bit int in the TT. This patch increases
MAX_PLY by storing the depth in an unsigned 8 bit, after shifting by the
most negative depth stored in TT (DEPTH_NONE).

No regression at STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 42235 W: 9565 L: 9484 D: 23186
http://tests.stockfishchess.org/tests/view/5cdb35360ebc5925cf0595e1

Verified to reach high depths on
k1b5/1p1p4/pP1Pp3/K2pPp2/1P1p1P2/3P1P2/5P2/8 w - -
info depth 142 seldepth 154 multipv 1 score cp 537 nodes 26740713110 ...

No bench change.
2019-05-15 09:52:27 +02:00
SFisGOD 58bbbd176b Pawn value tweak
STC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 47166 W: 10664 L: 10311 D: 26191
http://tests.stockfishchess.org/tests/view/5c7dfc370ebc5925cffdf830

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 35439 W: 6034 L: 5767 D: 23638
http://tests.stockfishchess.org/tests/view/5c7e41020ebc5925cffdfe9b

Bench: 3470519
2019-03-05 14:54:25 +01:00
Marco Costalba 05f7d59a9a Assorted trivial cleanups 1/2019
To address #1862

No functional change.
2019-02-08 10:20:43 +01:00
Marco Costalba 3c576efa77 Delay castling legality check
Delay legality check of castling moves at search time,
just before making the move, as is the standard with all
the other move types.

This should avoid an useless and not trivial legality check
when the castling is then not tried later. For instance due
to a previous cut-off.

The patch is also a big simplification and allows to entirely
remove generate_castling()

Bench changes due to a different move sequence out of MovePicker.

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 45073 W: 9918 L: 9843 D: 25312
http://tests.stockfishchess.org/tests/view/5c2f176f0ebc596a450bdfb3

LTC:
LLR: 3.15 (-2.94,2.94) [-3.00,1.00]
Total: 10156 W: 1707 L: 1560 D: 6889
http://tests.stockfishchess.org/tests/view/5c2e7dfd0ebc596a450bcdf4

Verified with perft both in standard and Chess960 cases.

Closes https://github.com/official-stockfish/Stockfish/pull/1929

Bench: 3559104
2019-01-04 14:23:14 +01:00
protonspring fefc0c6789 simplify opposite_colors 2018-12-09 12:59:57 +01:00
Stéphane Nicolet cf5d683408 Stockfish 10-beta
Preparation commit for the upcoming Stockfish 10 version, giving a chance to catch last minute feature bugs and evaluation regression during the one-week code freeze period. Also changing the copyright dates to include 2019.

No functional change
2018-11-19 11:18:21 +01:00
SFisGOD cd732c080b Pawn and Piece Values Tuned at LTC
Failed STC
LLR: -2.96 (-2.94,2.94) [0.00,4.00]
Total: 27487 W: 5846 L: 5903 D: 15738
http://tests.stockfishchess.org/tests/view/5be1d3190ebc595e0ae2e5b8

Passed 1st LTC
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 38503 W: 6270 L: 5999 D: 26234
http://tests.stockfishchess.org/tests/view/5be1f5ef0ebc595e0ae2e750

Passed 2nd LTC
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 34016 W: 5584 L: 5326 D: 23106
http://tests.stockfishchess.org/tests/view/5be2a1970ebc595e0ae2f1b4

This pull request lead to an interesting discussion about testing
methodology for Stockfish:
https://github.com/official-stockfish/Stockfish/pull/1804

Bench: 3647775
2018-11-08 16:34:10 +01:00
SFisGOD 4a0db9ea3c Combo
Combo of two parameter tweaks and tuned values for Queen and ThreatByKing.

STC
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 20180 W: 4439 L: 4198 D: 11543
http://tests.stockfishchess.org/tests/view/5bd7b8250ebc595e0ae22e97

LTC
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 86312 W: 14106 L: 13685 D: 58521
http://tests.stockfishchess.org/tests/view/5bd803560ebc595e0ae23213

This combo consists of the following:

Queen Value (tuned values)
Iter: 72056, A: 5000, alpha 0.602000, gamma 0.101000, clipping old, rounding deterministic
param: QueenValueMg, best: 2528.91, start: 2528.00
param: QueenValueEg, best: 2687.12, start: 2698.00

ThreatByKing (tuned values)
Green STC (50.8k games)
http://tests.stockfishchess.org/tests/view/5bd1d5a00ebc595e0ae1cbec
LTC (I stopped this test at 71.2k games. It's likely yellow.)
http://tests.stockfishchess.org/tests/view/5bd263e70ebc595e0ae1d77e

WeakUnopposedPawn (tweak) by xoto (https://github.com/xoto10)
Green STC (102.8k games)
http://tests.stockfishchess.org/tests/view/5bd306bb0ebc595e0ae1e146
Yellow LTC (90.8k games)
http://tests.stockfishchess.org/tests/view/5bd3ea660ebc595e0ae1f16b

aspiTune1 (tweak) by vondele (https://github.com/vondele)
Green STC (125.9k games)
http://tests.stockfishchess.org/tests/view/5bd2ae100ebc595e0ae1dab0
Yellow LTC (107.9k games)
http://tests.stockfishchess.org/tests/view/5bd3eb700ebc595e0ae1f16f

Thank you @31m059 (Mark Tenzer) for helping me! Also, thank you very much
for recognizing my efforts. I genuinely appreciate it.

Bench: 3556672
2018-11-01 15:39:19 +01:00
mstembera 542a2b39ed Small simplification in castling rights
There is no need for a special struct with a static member
to generate castling rights.

No functional change.
2018-10-21 08:15:04 +02:00
Alain SAVARD 4d22d3e52d Remove pawncount array in imbalance
This is a natural follow up to last commit where values on the
QuadraticOurs diagonal and some piece value deltas were changed.
@Stefano80 tried to simplify the newly introduced pawncount array
using QuadraticOurs[1][1] =52 and a -30 adjustment on pawn values

His STC [-3,1] was green
http://tests.stockfishchess.org/tests/view/5b707f5b0ebc5902bdba2745
but not his LTC[-3,1]
http://tests.stockfishchess.org/tests/view/5b7095700ebc5902bdba2a49

So I started a 80000 30+0.3 SPSA on the QuadraticOurs diagonal and
on the piece values using @Stefano80 start values.

SPSA gave the new values QuadraticOurs[1][1] =38 and a -33 on pawn
values (the other changes on QuadraticOurs were kept, but were not
ignificant according to this test
http://tests.stockfishchess.org/tests/view/5b710ccb0ebc5902bdba2f27)

STC
http://tests.stockfishchess.org/tests/view/5b710b220ebc5902bdba2f19
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 50902 W: 11214 L: 11150 D: 28538

LTC
http://tests.stockfishchess.org/tests/view/5b7124ef0ebc5902bdba3106
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 34271 W: 5852 L: 5753 D: 22666

Closes https://github.com/official-stockfish/Stockfish/pull/1735

bench: 4738555
2018-08-14 08:36:27 +02:00
GuardianRM 41cc4eb953 Non-linear bonus for pawn count
This patch introduces a non-linear bonus for pawns, along with some
(linear) corrections for the other pieces types.

The original values were obtained by a massive non-linear tuning of both
pawns and other pieces by GuardianRM, while Alain Savard and Chris Cain
later simplified the patch by observing that, apart from the pawn case, the
tuned corrections were in fact almost affine and could be incorporated in
our current code base via the piece values in types.h (offset) and the diagonal
of the quadratic matrix (slope). See discussion in PR#1725 :
https://github.com/official-stockfish/Stockfish/pull/1725

STC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 42948 W: 9662 L: 9317 D: 23969
http://tests.stockfishchess.org/tests/view/5b6ff6e60ebc5902bdba1d87

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 19683 W: 3409 L: 3206 D: 13068
http://tests.stockfishchess.org/tests/view/5b702dbd0ebc5902bdba216b

How to continue from there?
- Maybe the non-linearity for the pawn value could be somewhat tempered
  again and a simpler linear correction for pawns would work?

Closes https://github.com/official-stockfish/Stockfish/pull/1734

Bench: 4681496
2018-08-12 18:40:11 +02:00
Stefano Cardanobile b5581b7779 Combo of several promising parameter tweaks
Combo of several tuning patches which finished yellow at LTC.

[STC](http://tests.stockfishchess.org/tests/view/5b6ead340ebc5902bdba14ce)
LR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 10668 W: 2445 L: 2239 D: 5984
Elo: 6.25 [1.76,10.69] (95%)

[LTC](http://tests.stockfishchess.org/tests/view/5b6eb50e0ebc5902bdba151f)
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 23761 W: 4155 L: 3923 D: 15683
Elo: 3.02 [0.29,5.67] (95%)

Original patches:
- [Piece values](http://tests.stockfishchess.org/tests/view/5b6d2cc00ebc5902bdba02d5) by Stefano Cardanobile
- [Stat bonus](http://tests.stockfishchess.org/tests/view/5b6adbc90ebc5902bdb9da73) by Stefan Geschwentner
- [Rook on pawn](http://tests.stockfishchess.org/tests/view/5b62a95b0ebc5902bdb961c0) by Mark Tenzer
- [Hanging bonus](http://tests.stockfishchess.org/tests/view/5b5d2fa00ebc5902bdb90855) by Ivan Ilvec
- [ss tweak](http://tests.stockfishchess.org/tests/view/5b58b7240ebc5902bdb89025) by miguel-l

Bench: 4694813
2018-08-12 10:09:30 +02:00
DU-jdto a05793517f Minor code style tweaks
No functional change.
2018-07-18 08:26:33 +02:00
Stefano80 213166ba22 Always scale using pawn contribution
This is a further step in the long quest for a simple way of determining
scale factors for the endgame.

Here we remove the artificial restriction in evaluate_scale_factor()
based on endgame score. Also SCALE_FACTOR_ONEPAWN can be simplified
away. The latter is a small non functional simplification with respect
to the version that was testedin the framework, verified on bench with
depth 22 for good measure.

Passed STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 49438 W: 9999 L: 9930 D: 29509
http://tests.stockfishchess.org/tests/view/5ae20c8b0ebc5963175205c8

Passed LTC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 101445 W: 15113 L: 15110 D: 71222
http://tests.stockfishchess.org/tests/view/5ae2a0560ebc5902a1998986

How to continue from there?

Maybe the general case could be scaled with pawns from both colors
without losing Elo. If that is the case, then this could be merged
somehow with the scaling in evaluate_initiative(), which also uses
a additive malus down when the number of pawns in the position goes
down.

Closes https://github.com/official-stockfish/Stockfish/pull/1570

Bench: 5254862
2018-04-29 07:26:25 +02:00