1
0
Fork 0
Commit Graph

3416 Commits (413b24380993cfdb7578ebe10b6a71b51bd8fb5b)

Author SHA1 Message Date
Marco Costalba 413b243809 Coding style in TT code
In particular seems more natural to return
bool and TTEntry on the same line, actually
we should pass and return them as a pair,
but due to limitations of C++ and not wanting
to use std::pair this can be an acceptable
compromise.

No functional change.

Resolves #157
2014-12-14 23:49:00 +00:00
Gary Linscott 0edb6348d2 Fix compile for some versions of mingw
The bswap intrinsics are specific to the compiler, not the
host platform.

No functional change.

Resolves #155
2014-12-14 14:45:43 -05:00
mstembera 14cf27e6f6 Avoid searching TT twice for the same key/position during probe() and store().
Just keep the pointer and remove code from tt.cpp

STC
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 13620 W: 2810 L: 2665 D: 8145

LTC
LLR: 2.97 (-2.94,2.94) [0.00,6.00]
Total: 13021 W: 2238 L: 2073 D: 8710STC http://tests.stockfishchess.org/tests/view/548436860ebc59331739b90c

STC 4MB
ELO: 2.41 +-2.2 (95%) LOS: 98.6%
Total: 40000 W: 8175 L: 7897 D: 23928

LTC 16MB
ELO: 1.78 +-2.0 (95%) LOS: 96.1%
Total: 39683 W: 6763 L: 6560 D: 26360

Resolves #151

Bench: 8116521
2014-12-13 07:22:37 +00:00
Gary Linscott 7b4828b68c Only use _ReadWriteBarrier on MSVC
It was causing compile errors when cross-compiling using mingw.

No functional change.
2014-12-11 14:56:24 -05:00
joergoster f6d220ab14 Halve StormDanger bonus for blocked pawn on A/H file
STC
LLR: 2.95 (-2.94,2.94) [-1.50,4.50]
Total: 3410 W: 758 L: 641 D: 2011

LTC
LLR: 2.95 (-2.94,2.94) [0.00,6.00]
Total: 33225 W: 5708 L: 5445 D: 22072

Bench: 8465811

Resolves #153
2014-12-11 13:08:29 -05:00
Gary Linscott afafdf7b73 MSVC compiling fixes
No functional change.

Resolves #150
2014-12-11 13:03:44 -05:00
Joona Kiiski b15dcd9774 Fix profile build for syzygy
Touch source files under syzygy directory to force recompilation
after collecting profile data.

No functional change

Resolves #149
2014-12-10 17:59:41 +00:00
Joona Kiiski 94dd204c3b Retire 'os' flag from Makefile
Appears to be unused

No functional change

Resolves #147
2014-12-10 17:57:55 +00:00
Marco Costalba 5943600a89 Assorted nitpicking code-style
No functional change.
2014-12-10 12:38:13 +01:00
Marco Costalba 589c711449 Clarify when forcing the moves loop
In some cases we want to go direcly to the moves loop
without checking for early return. The patch make this
logic more clear and consistent.

Tested for no regression, passed STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 25282 W: 5136 L: 5022 D: 15124

and LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 72007 W: 12133 L: 12095 D: 47779

bench: 9316798
2014-12-10 12:35:21 +01:00
Ernesto Gatti 158864270a Simpler PRNG and faster magics search
This patch replaces RKISS by a simpler and faster PRNG, xorshift64* proposed
by S. Vigna (2014). It is extremely simple, has a large enough period for
Stockfish's needs (2^64), requires no warming-up (allowing such code to be
removed), and offers slightly better randomness than MT19937.

Paper: http://xorshift.di.unimi.it/
Reference source code (public domain):
http://xorshift.di.unimi.it/xorshift64star.c

The patch also simplifies how init_magics() searches for magics:

- Old logic: seed the PRNG always with the same seed,
  then use optimized bit rotations to tailor the RNG sequence per rank.

- New logic: seed the PRNG with an optimized seed per rank.

This has two advantages:
1. Less code and less computation to perform during magics search (not ROTL).
2. More choices for random sequence tuning. The old logic only let us choose
from 4096 bit rotation pairs. With the new one, we can look for the best seeds
among 2^64 values. Indeed, the set of seeds[][] provided in the patch reduces
the effort needed to find the magics:

64-bit SF:
Old logic -> 5,783,789 rand64() calls needed to find the magics
New logic -> 4,420,086 calls

32-bit SF:
Old logic -> 2,175,518 calls
New logic -> 1,895,955 calls

In the 64-bit case, init_magics() take 25 ms less to complete (Intel Core i5).

Finally, when playing with strength handicap, non-determinism is achieved
by setting the seed of the static RNG only once. Afterwards, there is no need
to skip output values.

The bench only changes because the Zobrist keys are now different (since they
are random numbers straight out of the PRNG).

The RNG seed has been carefully chosen so that the
resulting Zobrist keys are particularly well-behaved:

1. All triplets of XORed keys are unique, implying that it
   would take at least 7 keys to find a 64-bit collision
   (test suggested by ceebo)

2. All pairs of XORed keys are unique modulo 2^32

3. The cardinality of { (key1 ^ key2) >> 48 } is as close
   as possible to the maximum (65536)

Point 2 aims at ensuring a good distribution among the bits
that determine an TT entry's cluster, likewise point 3
among the bits that form the TT entry's key16 inside a
cluster.

Details:

     Bitset   card(key1^key2)
     ------   ---------------
RKISS
     key16     64894   = 99.020% of theoretical maximum
     low18    180117   = 99.293%
     low32    305362   = 99.997%

Xorshift64*, old seed
     key16     64918   = 99.057%
     low18    179994   = 99.225%
     low32    305350   = 99.993%

Xorshift64*, new seed
     key16     65027   = 99.223%
     low18    181118   = 99.845%
     low32    305371   = 100.000%

Bench: 9324905

Resolves #148
2014-12-08 08:18:26 +08:00
Gary Linscott a87da2c4b3 Add some tablebase positions to bench
This makes it easier to check for regressions in the tablebase code.

Bench: 9489202
5-man bench: 8943906

Resolves #145
2014-12-08 07:58:05 +08:00
hxim fbb53524ef Rename some variables for more clarity.
No functional change.

Resolves #131
2014-12-08 07:53:33 +08:00
Marco Costalba ba1464751d Explicitly pass RootMoves to TB probes
Currently Search::RootMoves is accessed and even
modified by TB probing functions in a hidden
and sneaky way.

This is bad practice and makes the code tricky.
Instead explicily pass the vector as function
argument so to clarify that the vector is modified
inside the functions.

No functional change.
2014-12-06 15:08:21 +00:00
Marco Costalba eeb6d923fa Move TB stuff under Tablebases namespace
Simplified also some logic while there.

TBLargest needs renaming too, but itis for
a future patch because touches also syzygy
directory stuff.

No functional change.
2014-12-06 14:58:00 +00:00
Marco Costalba c30eb4c9c9 Refactor syzygy code in search
Move to SF coding style.

Also skip calculating piece count in search()
when TB are not found (!TBCardinality)

No functional change.
2014-12-06 14:35:50 +00:00
Joona Kiiski 35c1ccef39 Retire support for Haiku installation directory from Makefile
- It is out of the scope of the project.
- It is the responsibility of Haiku package maintainer to
  configure this.

No functional change

Resolves #143
2014-12-06 14:23:08 +00:00
Joona Kiiski 0935dca9a6 Retire hackish support for aCC and HP-UX from Makefile
- It is out of scope of the project.
- We have no way to verify that it even works anymore

No functional change

Resolves #142
2014-12-06 14:19:39 +00:00
Marco Costalba 314d446518 Retire total_piece_count()
We really don't need to uglify in this way
our nice count() API with this ad-hoc hack.

So remove the hack and use the already
existing infrastructure.

No functional change.

Resolves #134
2014-11-30 20:37:24 +00:00
hxim c014444f09 Remove CONNECTED_KINGS from Syzygy code
No functional change

Resolves #140
2014-11-30 20:24:32 +00:00
Rodrigo Exterckötter Tjäder 9b4e123fbe Cleaning Syzygy profiling data
Updating the makefile so that the clean and gcc-profile-clean targets also
remove the profiling data files in the syzygy directory.

No functional change.

Resolves #136
2014-11-30 19:53:04 +00:00
Marco Costalba a43f633c19 Rewrite TBScore in uci_pv()
Streamline the code and make
it understandable.

No functional change.

Resolves #135
2014-11-30 19:35:35 +00:00
Marco Costalba 66f5cd3f9d Retire #ifdef SYZYGY macro
It just clutters the code for no
real reason.

No functional change.

Resolves #139
2014-11-30 19:23:17 +00:00
mstembera fe07ae4cb4 Bitbase index() from ADD to OR.
No functional change.

Resolves #132
2014-11-26 07:56:48 +08:00
lucasart 2c52147dbf Introduce ratio operation
Just like in Physics, the ratio of 2 things in the same unit, should be
without unit.

Example use case:
- Ratio of a Depth by a Depth (eg. ONE_PLY) should be an int.
- Ratio of a Value by a Value (eg. PawnValueEg) should be an int.

Remove a bunch of useless const while there.

No functional change.

Resolves #128
2014-11-26 07:55:57 +08:00
Ronald de Man 7caa6cd338 Syzygy tablebases
Adds support for Syzygy tablebases to Stockfish.  See
the Readme for information on using the tablebases.

Tablebase support can be enabled/disabled at the Makefile
level as well, by setting syzygy=yes or syzygy=no.

Big/little endian are both supported.

No functional change (if Tablebases are not used).

Resolves #6
2014-11-26 07:49:58 +08:00
Gary Linscott 4509eb1342 Fix out-of-bound array access printing ponder move
It is possible that we won't have a ponder move if our PV
is too short.  In that case, just don't print a ponder move.

No functional change

Resolves #130
2014-11-24 08:53:00 +08:00
Gary Linscott 7ad59d9ac9 Fix pondering
The UCI specification states that an engine can never exit the search
while pondering.

No functional change.

Resolves #118
2014-11-24 08:50:36 +08:00
Jonathan Calovski 48127fe5d3 Amend defended
Amend defended to remove now redundant condition.

No functional change.

Resolves #125
2014-11-22 05:46:59 +08:00
Marco Costalba 84408e5cd6 Fix doubled pawns asymmetry
When evaluating double pawns we use always
lsb() to extract the frontmost square.

This breaks evaluation color symmetry as is
possible to verify with an instrumented evaluate()

  Value evaluate(const Position& pos) {

    Value v = do_evaluate<false>(pos);
    Position p = pos;
    p.flip();
    assert(v == do_evaluate<false>(p));
    return v;
  }

Passed no regression test:

STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 21035 W: 4244 L: 4122 D: 12669

LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 39839 W: 6662 L: 6572 D: 26605

bench: 8255966
2014-11-21 20:40:25 +01:00
Marco Costalba 79232be02a Further tweak accurate pv
It is a non functional change, but because
we now skip copying of pv[] in SpNode, patch
has been tested for regression with 3 threads:

STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 54668 W: 9873 L: 9809 D: 34986

No functional change.
2014-11-21 20:37:45 +01:00
hxim 0a1f54975f Fix some comments
No functional change.

Resolves #123
2014-11-19 06:39:17 +08:00
Gary Linscott bffe32f4fe Fix fen output for castling rights
This is a regression from 428962a

We have to cast to char here, otherwise the compiler
interprets it as an integer, and writes a number.

No functional change

Resolves #122
2014-11-19 06:37:59 +08:00
Marco Costalba 4aca11ae2a Codying style in accurate PV
This is the first of a patch series to
rearrange and simplify accurate PV.

In this patch there is simple coding
style and reformatting stuff.

Verified with fishtest it does not crash
with MAX_PLY = 8

No functional change.
2014-11-18 11:57:57 +01:00
Marco Costalba 1a939cd8c8 Fix a warning on Intel C++
warning #2259: non-pointer conversion from "int" to
"uint8_t={unsigned char}" may lose significant bits

No functional change.
2014-11-17 12:56:48 +01:00
sf-x d65c9a3262 Use PHASE_MIDGAME in game_phase()
No functional change

Resolves #117
2014-11-17 07:50:33 +08:00
Rodrigo Exterckötter Tjäder 99f2c1a2a6 Clear token before reading from input
Previously token would keep its value from the previous line when an empty
line was input, leading to unexpected behaviour.

No functional change

Resolves #119
2014-11-17 07:48:30 +08:00
lucasart 3b1f552b08 Half History Max
STC
LLR: 3.35 (-2.94,2.94) [-0.50,3.50]
Total: 17993 W: 3740 L: 3508 D: 10745

LTC
LLR: 3.25 (-2.94,2.94) [0.00,4.00]
Total: 21346 W: 3691 L: 3453 D: 14202

Bench: 7694316

Resolves #120
2014-11-17 07:04:58 +08:00
Marco Costalba 4840643fed Use DEPTH_MAX instead of MAX_PLY
When comparing to a Depth it is more
consistent to use DEPTH_MAX instead
of a int.

This is a subtle difference because we use
ply and depth almost interchangably in SF,
but they are different. FOr counting plies
makes ense to continue using ints, while
for Depth we have our specific enum.

This cleanly fixes a new Clang 3.5 warning:

No functional change.
2014-11-15 05:36:49 +01:00
Gary Linscott 4739037f96 100% accurate PV display
This gives SF accurate PVs, such that the evaluation of the leaf node in
the PV matches the score backed up to the root (99% of the time.
q-search will use the value stored in the hash table instead of the eval
value sometimes).

One drawback is that fail-high/low only get a minimal 2 move PV.

It doesn't add any additional overhead to the non-PV codepath except an
extra eight bytes to the SearchStack structure in multi-threaded
searches.

A core part of this is not pruning based on TT score in PV nodes. This
was measured as not being a regression at multiple TCs, except for one
exception, fast TC with huge hash, which is not realistic for longer
searches.

STC - 1 thread, 128 mb hash
ELO: 1.42 +-3.1 (95%) LOS: 81.9%
Total: 20000 W: 4078 L: 3996 D: 11926

STC - 3 thread, 128 mb hash
ELO: -3.60 +-2.9 (95%) LOS: 0.8%
Total: 20000 W: 3575 L: 3782 D: 12643

STC - 3 thread, 8 mb hash
ELO: 0.12 +-2.9 (95%) LOS: 53.3%
Total: 20000 W: 3654 L: 3647 D: 12699

LTC - 3 thread, 32mb hash
ELO: 2.29 +-2.0 (95%) LOS: 98.8%
Total: 35740 W: 5618 L: 5382 D: 24740

Bench: 6984058

Resolves #102
2014-11-12 16:16:33 -05:00
lucasart 234344500f Use quiet ttMove in qsearch() (7962287)
Daniel Jose reported that it was an elo gain in his engine:
http://www.talkchess.com/forum/viewtopic.php?t=54290

STC: Hash=16
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 33067 W: 6670 L: 6571 D: 19826

LTC: Hash=64
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 41181 W: 7008 L: 6920 D: 27253

And another one to verify no regression with hash pressure:

STC: Hash=4
LLR: 2.96 (-2.94,2.94) [-4.00,0.00]
Total: 25085 W: 5059 L: 4991 D: 15035

Verified that qsearch does not explode after this patch (recapture threshold).

Bench 7962287

Resolves #112
2014-11-12 21:06:14 +00:00
Marco Costalba b777b17f6f Use if/else instead of goto
Real men jump/branch by hand...but
we prefer the humble way.

Moved also some uci info code where it
belongs, while there.

No functional change.

Resolves #110
2014-11-12 21:02:20 +00:00
Marco Costalba db4b8ee000 Use Depth instead of int in search
And make it more ONE_PLY value independent,
although we are not there yet.

No functional change.

Resolves #111
2014-11-12 21:00:16 +00:00
lucasart c6d45c60b5 Profile Build with Hash=16
16MB for 1" searches is more comensurate with the average use case.

And 16 is the default used by stockfish bench, so it makes sense to be
consistent, if only to have the same minimum memory requirement for using
SF and compiling it with PGO.

No functional change.

Resolves #109
2014-11-10 23:06:12 +00:00
lucasart d709a5f1c5 Fix bounds of FutilityMoveCounts
This is a left-over from ONE_PLY == 2.

No functional change.

Resolves #107
2014-11-09 20:13:56 +00:00
Marco Costalba 1b0df1ae14 Retire pvMove in search()
Now we can directly replace it with
the definition resulting in simpler
and possibly faster code because
PvNode is evaluated at compile time.

No functional change.
2014-11-09 20:36:28 +01:00
Marco Costalba 57fdfdedcf Assorted code-style triviality
No functional change.
2014-11-09 20:17:29 +01:00
Marco Costalba 6fb0a1bc40 Introduce distance() and unify some API
Original work by Lucas.

No functional change.
2014-11-09 10:27:04 +01:00
lucasart 8631b08d97 Codestyle massage Search::init()
* remove some erroneous comments, that were based on the ONE_PLY == 2.
* rename hd to d, because there's no more half-depth in SF.
* rescope variables into the for loops.
* reindent the for loops correctly.
* add a comment to explain the eval improving part (not so obvious to read
this code as array has 4 dimensions).

No functional change.
2014-11-08 10:56:51 -05:00
lucasart 3d2aab11d8 Be more optimistic in aspiration window
Be more optimistic wrt search instability, and set the unviolated bound
half window.

STC
LLR: 2.96 (-2.94,2.94) [-1.00,4.00]
Total: 16362 W: 3371 L: 3197 D: 9794

LTC
LLR: 2.94 (-2.94,2.94) [0.00,5.00]
Total: 21666 W: 3780 L: 3569 D: 14317

Bench: 6807896

Resolves #105
2014-11-08 10:47:56 -05:00