1
0
Fork 0
Commit Graph

201 Commits (riscv64-cartesi)

Author SHA1 Message Date
Stéphane Nicolet b862c8d4be Small clean-up
Bench: 4321677
2021-03-31 08:12:25 +02:00
bmc4 5089061659 Change definition of between_bb()
We remark that in current master, most of our use cases for between_bb() can be
optimized if the second parameter of the function is added to the segment. So we
change the definition of between_bb(s1, s2) such that it excludes s1 but includes s2.

We also use a precomputed array for between_bb() for another small speed gain
(see https://tests.stockfishchess.org/tests/view/604d09f72433018de7a389fb).

Passed STC:
LLR: 2.96 (-2.94,2.94) {-0.25,1.25}
Total: 18736 W: 1746 L: 1607 D: 15383
Ptnml(0-2): 61, 1226, 6644, 1387, 50
https://tests.stockfishchess.org/tests/view/60428c84ddcba5f0627bb6e4

Yellow LTC:
LTC:
LLR: -3.00 (-2.94,2.94) {0.25,1.25}
Total: 39144 W: 1431 L: 1413 D: 36300
Ptnml(0-2): 13, 1176, 17184, 1178, 21
https://tests.stockfishchess.org/tests/view/605128702433018de7a38ca1

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

---------

Verified for correctness by running perft on the following position:

./stockfish
position fen 4rrk1/1p1nq3/p7/2p1P1pp/3P2bp/3Q1Bn1/PPPB4/1K2R1NR w - - 40 21
go perft 6

Nodes searched: 6136386434

--------

No functional change
2021-03-18 00:21:41 +01: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
Antoine Champion 9b1274aba3 Clean functions returning by const values
The codebase contains multiple functions returning by const-value.
This patch is a small cleanup making those function returns
by value instead, removing the const specifier.

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

No functional change
2021-03-07 14:05:01 +01:00
Joost VandeVondele c4d67d77c9 Update copyright years
No functional change
2021-01-08 17:04:23 +01:00
Joost VandeVondele 5f1843c9cb Small trivial cleanups
closes https://github.com/official-stockfish/Stockfish/pull/2801

No functional change
2020-08-23 01:53:41 +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
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
NguyenPham d0cb9b286f show coordinates when displaying board
closes https://github.com/official-stockfish/Stockfish/pull/2723

No functional change
2020-06-09 18:28:20 +02:00
Joost VandeVondele 383b12e1a5 small cleanups
closes https://github.com/official-stockfish/Stockfish/pull/2653

No functional change
2020-05-23 13:27:16 +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 209e94203f Small cleanups
https://github.com/official-stockfish/Stockfish/pull/2584

No functional change.
2020-03-30 22:46:07 +02:00
protonspring 7f623206f4 Rewrite initialization of PseudoMoves
This is a non-functional code style change. I believe master is a bit convoluted
here and propose this version for clarity.

No functional change
2020-01-10 01:58:27 +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
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
Marco Costalba 4e72e2a964 Assorted trivial cleanups 4/2019
No functional change.
2019-05-02 19:30:26 +02:00
protonspring a858b5a84e Remove DistanceRing #2107
Remove the DistanceRing array. This reduces the
memory footprint by about 4kb.

http://tests.stockfishchess.org/tests/view/5cba35350ebc5925cf020d7f
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 101421 W: 22491 L: 22528 D: 56402

No functional change.
2019-04-20 08:34:14 +02:00
protonspring f98c77413b Remove BetweenBB Array #2076
Non functional change.
2019-04-09 13:46:12 +02:00
Marco Costalba 82ad9ce9cf
Assorted trivial cleanups 3/2019 (#2030)
No functional change.
2019-03-31 11:47:36 +02:00
protonspring c858990377 Replace std::mins/max with clamp function (#2062)
Adding a clamp function makes some of these range limitations a bit prettier and removes some #include's.

STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28117 W: 6300 L: 6191 D: 15626
http://tests.stockfishchess.org/tests/view/5c9aa1df0ebc5925cfff8fcc

Non functional change.
2019-03-31 10:48:27 +02:00
protonspring 796d0ad70e Accessor for SquareBB #2067
This is a non-functional code style change.

If we add an accessor function for SquareBB we can consolidate all of the asserts. This is also a bit cleaner because all SquareBB accesses go through this method making future changes easier to manage.

STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 63406 W: 14084 L: 14045 D: 35277
http://tests.stockfishchess.org/tests/view/5c9ea6100ebc5925cfffc9af

No functional change.
2019-03-31 10:43:20 +02:00
protonspring b8efa0daac Remove popcount16() (#2038)
This is a non-functional simplification / code-style change.

This popcount16 method does nothing but initialize the PopCnt16 arrays.

This can be done in a single bitset line, which is less lines and more clear. Performance for this code is moot.

No functional change.
2019-03-10 10:53:39 +01:00
Marco Costalba 2bceba7f51 Assorted trivial cleanups 2/2019
No functional change.
2019-03-05 11:13:02 +01:00
protonspring dd4796fcd5 Remove Some Bitboard Arrays (#1963)
This is non-functional. These 5 arrays are simple enough to calculate real-time and maintaining an array for them does not help. Decreases the memory footprint.

This seems a tiny bit slower on my machine, but passed STC well enough. Could someone verify speed?

STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 44745 W: 9780 L: 9704 D: 25261
http://tests.stockfishchess.org/tests/view/5c47aa2d0ebc5902bca13fc4

The slowdown is minimal even in 32 bit case (thanks to @mstembera for testing):

Compiled using make build ARCH=x86-32 CXX=i686-w64-mingw32-c++ and benched
This patch only:

```
Results for 40 tests for each version:

            Base      Test      Diff      
    Mean    1455204   1450033   5171      
    StDev   49452     34533     59621     

p-value: 0.465
speedup: -0.004
```

No functional change.
2019-02-08 09:54:38 +01:00
Maciej Żenczykowski 8df1cd10df Use int8_t instead of int for SquareDistance[]
This patch saves (4-1) * 64 * 64 = 12KiB of cache.

STC
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 176120 W: 38944 L: 38087 D: 99089
http://tests.stockfishchess.org/tests/view/5c4c9f840ebc593af5d4a7ce

LTC
As a pure speed up, I've been informed it should not require LTC.

No functional change
2019-01-29 17:26:24 +01:00
protonspring 3300517ecb Remove AdjacentFiles
This is a non-functional simplification that removes the AdjacentFiles array.
This array is simple enough to calculate that the pre-calculated array provides
no benefit. Reduces the memory footprint.

STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 74839 W: 16390 L: 16373 D: 42076
http://tests.stockfishchess.org/tests/view/5c3d75920ebc596a450cfb67

No functionnal change
2019-01-17 08:11:09 +01:00
Marco Costalba eb6d7f537d
Assorted trivial cleanups (#1894)
To address https://github.com/official-stockfish/Stockfish/issues/1862

No functional change.
2019-01-01 14:10:26 +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
protonspring 8a4821923a make DistanceRing more consistent
This is a non-functional change. By pre-incrementing minKingPawnDistance
instead of post-incrementing, we can remove this -1.

This also makes DistanceRing more consistent with the rest of stockfish
since it now holds an actual "distance" instead of a less natural distance-1.

In current master, PseudoAttacks[KING][ksq] == DistanceRingBB[ksq][0]
With this patch, it will be PseudoAttacks[KING][ksq] == DistanceRingBB[ksq][1]
ie squares at distance 1 from the king. This is more natural use of distance.

The current array size DistanceRingBB[SQUARE_NB][8] is still OK with the new
definition, because maximum distance between two squares on a chess board is
seven (for example Kh1 and a8).

No functional change.
2018-08-29 01:07:38 +02:00
DU-jdto a05793517f Minor code style tweaks
No functional change.
2018-07-18 08:26:33 +02:00
protonspring af6072c8b7 Remove make_bitboard()
In current master, the function make_bitboard() does nothing apart from
helping initialize the SquareBB[] array. This seems like an unnecessary
abstraction layer.

The advantage of make_bitboard() is we can define a bitboard, in a simple
and general way, not only from a single square but also from a list of
squares. It is more elegant, faster and  readable than combining multiple
SquareBB explicitly, but the last complex use case in evaluation was
simplified away a few months ago.

If make_bitboard() becomes useful again to define complicated bitboards,
it will be easy enough to reintroduce it using this pull request as
an implementation reference.

No functional change.
2018-06-26 09:08:15 +02:00
mstembera 76f9cd4df1 Some small changes
1) Use make_bitboard() in Bitboards::init()

2) Fix MSVC warning: search.h(85): warning C4244: '=': conversion from
   'TimePoint' to 'int', possible loss of data.

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

No functional change.
2018-04-01 02:32:55 +02:00
lucasart edf4c07d25 Use intrinsics only for LSB/MSB
The NO_BSF does not cover any real life use-case today. The only compilers that
can compile SF today, with the current Makefile and no source code changes, are
either GCC compatible (define __GNUC__) or MSVC compatible (define _MSC_VER). So
they all support LSB/MSB intrinsics.

This patch simplifies away the software fall-backs of LSB/MSB that were still
in Stockfish code, but unused in any of the officially supported compilers.

Note the (legacy) MSVC/WIN32 case, where we use a 32-bit BSF/BSR solution, as
64-bit intrinsics aren't available there.

Discussed in: https://github.com/official-stockfish/Stockfish/pull/1447
and:          https://github.com/official-stockfish/Stockfish/pull/1479

No functional change.
2018-03-14 01:31:21 +01:00
Joost VandeVondele 9afa1d7330 New Year 2018
Adjust copyright headers.

No functional change.
2018-01-01 13:18:10 +01:00
syzygy1 822695d4d3 Use a Direction enum for Square deltas
Currently the NORTH/WEST/SOUTH/EAST values are of type Square, but conceptually they are not squares but directions. This patch separates these values into a Direction enum and overloads addition and subtraction to allow adding a Square to a Direction (to get a new Square).

I have also slightly trimmed the possible overloadings to improve type safety. For example, it would normally not make sense to add a Color to a Color or a Piece to a Piece, or to multiply or divide them by an integer. It would also normally not make sense to add a Square to a Square.

This is a non-functional change.
2017-12-04 17:52:31 +01:00
Marco Costalba c0cb713a00 Indentation fix in index()
No functional change.

Closes #1158
2017-07-02 22:00:29 -07:00
Alain SAVARD 6d24ef8585 Tidy up
No functional change

Closes #1148
2017-07-02 21:53:45 -07:00
mstembera 69eb391cd7 Magic::index()
Make magic_index() a member of Magic since it uses all it's members
and keep us from having to pass the function pointer around to
init_magics().

No functional change

Closes #1146
2017-06-28 17:11:17 -07:00
Marco Costalba 27ba611a3d Better naming in endgame code
And small clean-up of magic bitboards code.

No functional change.

Closes #1138
2017-06-16 19:33:44 -07:00
mstembera 659990b43f Reordering magic data
Gather all magic relevant data into a struct.

This changes memory layout putting everything necessary for processing a single square
in the same memory location thus speeding up access.

Original patch by @snicolet

No functional change.

Closes #1127
Closes #1128
2017-06-06 10:22:12 -07:00
Marco Costalba e06a117d5e Retire the misdesigned StepAttacks[] array.
StepAttacks[] is misdesigned, the color dependance is specific
to pawns, and trying to generalise to king and knights, proves
neither useful nor convinient in practice.

So this patch reformats the code with the following changes:

- Use PieceType instead of Piece in attacks_() functions

- Use PseudoAttacks for KING and KNIGHT

- Rename StepAttacks[] into PawnAttacks[]

Original patch and idea from Alain Savard.

No functional change.

Closes #1086
2017-04-28 20:33:30 -07:00
Joost VandeVondele d8f683760c Adjust copyright headers to 2017 (#965)
No functional change.
2017-01-11 08:46:29 +01:00
Stéphane Nicolet 7ae3c05795 Rename shift_bb() to shift()
Rename shift_bb() to shift(), and DELTA_S to SOUTH, etc.
to improve code readability, especially in evaluate.cpp
when they are used together:

    old b = shift_bb<DELTA_S>(pos.pieces(PAWN))
    new b = shift<SOUTH>(pos.pieces(PAWN))

While there fix some small code style issues.

No functional change.
2016-09-25 10:45:10 +02:00
Marco Costalba d30994ecd5 Hide global visibility when not needed
Also move PieceValue definition in psqt.cpp,
where it is initialized.

Fix a warning in popcount16() with Intel compiler

No functional change.
2016-04-09 10:42:04 +02:00
mstembera 8fb45caade Simplify popcnt
Also a speedup(about 1%) on 64-bit w/o hardware popcnt

Retire Max15 and Full template parameters
(Contributed by Marco Costalba)

Now that we have just SW and HW versions, use
template default parameter to get rid of explicit
template parameters.

Retire bitcount.h and move the only defined
function to bitboard.h

No functional change

Resolves #620
2016-04-08 18:52:15 +01:00
lucasart f256388e08 Guard against UB in lsb/msb
lsb(b) and msb(b) are undefined when b == 0. This can lead to subtle bugs, where
the resulting code behaves differently on different configurations:
- It can be the home grown software LSB/MSB
- It can be the compiler generated software LSB/MSB (when using compiler
  intrinsics without the right compiler flags to allow compiler to use hardware
  LSB/MSB). Which of course depends on the compiler.
- It can be hardware LSB/MSB generated by the compiler.
- Not to mention that hardware LSB/MSB can return different value on different
  hardware when b == 0.

No functional change

Resolves #610
2016-03-31 13:22:37 +01:00
Marco Costalba db4b0d8b7d Rewrite bsfq management
Use compiler intrinsics when possible to
avoid writing platform specific asm code.

Tested on Windows 7 with MSVC 2013 and mingw 4.8.3 (32 and 64 bit)
and on Linux Mint with g++ 4.8.4 and clang 3.4 (32 and 64 bit).

No functional change

Resolves #609
2016-03-28 15:46:55 +01:00
ppigazzini d4af15f682 Update AUTHORS and copyright notice
No functional change

Resolves #555
2016-01-02 09:43:51 +00:00
Marco Costalba 9742fb10fd Update Copyright year
No functional change.

Resolves #554
2016-01-01 10:17:36 +00:00
gguliash 84a641b8bb A small code simplification
No functional change

Resolves #411
2015-08-30 19:58:32 +01:00