This is a first step to cleanup that part of
initialization code.
Apparently init functions are harder to read now,
but this is only temporary: this is a prerequisite
for future work.
As a side benefit we can now get rid of the ancillary
struct and define them directly in teh main ones, even
using anonymous structs!
Pointer members of WDLEntry and DTZEntry must be null, so they can be freed.
Whether unmap() behaves like free() and tolerates a NULL pointer (treated as
no-op) is unclear. Better safe than sorry, so test data before calling unmap().
Simplify hasUniquePieces calculation while at it.
No functional change.
Avoid explicitly freeing the objects.
Because d'tor involves file unmapping, some
care must be taken to avoid accidentaly destroy
the object (even temporarly), for instance when
reordering the list.
As a side effect, we can now restore the original
main.cpp, fully in sync with master branch.
It is just an intermediate struct, use DTZEntry directly.
This allow us to remove a malloc ad simplify freeing.
Confirmed with Valgrind there are no memory leaks.
Super big patch that completely rewrite
data layout to avoid casting of pointer
back and forth different structs.
Unfortunatly it is not possible to write
the patch in small steps because all the
data structs where deeply mixed and once
you touch one part you need to chaneg also
the others.
Functionality s unchanged and this is already
a big success, now we have a proper base above
which to di further clean up work.
Verified with Valgrind there are no memory leaks.
Use std::deque instead because it preserves references
to its elements when resizing (std::vector does not).
DTZ_table is still an array because it seems its size
is fixed and does not depend on TB exsisting files.
Given a position probe_ab() does a kind of qsearch,
but instead of evaluating the position at the begin,
through a table look up, it performs a depth-first
search and only at the end checks for current position
score.
Also replace platform specific byte swap with
a software version. Amazingly it seems it is
even faster now!
Also removing the templatized form does not slow down.
* document 0x38
* remove useless enc_type
For whatever reason (?), syzygy tables have the information to play a stupid
chess variant that (apparently) can result in having only 1 King on the board
instead of 2. Obviously, we do not care about this "game" which is neither
Chess, nor Chess960, so get rid of that useless code.
No functional change.
* Properly include tbcore.cpp
* Merge *cpp files
* Additional reshuffle and consolidation
* Cosmetic touch
- run: astyle -A3 -s4 -f -xn -xc -xl *.cpp *.h. Mainly this breaks blocks (if,
do, while, for etc.)
- remove static_cast<>: inconsistently used, and ugly. Prefer C-style cast.
Eventually, the code will be rewritten so that less casting is needed...
No functional change.
* Avoid encode/decode madness in init_tb
We encode pieces in a string passed to init_tb() that
just decodes the exactly same string to get the pieces back!
Sanitize this madness.
No functional change.
* Further cleanup init_tb
* Avoid useless intermediate conversions of TB paths
In many cases original information is converted to
an intermediate form to be then further used later.
In many cases this intermediate form is useless and
the original information can be used directly instead.
This patch removes a typical case.
Also simplified open_tb() signature.
* Address some Lucas review comments
And passed in do_move(), this ensures maximum efficiency and
speed and at the same time unlimited move numbers.
The draw back is that to handle Position init we need to
reserve a StateInfo inside Position itself and use at
init time and when copying from another Position.
After lazy SMP we don't need anymore this gimmick and we can
get rid of this special case and always pass an external
StateInfo to Position object.
Also rewritten and simplified Position constructors.
Verified it does not regress with a 3 threads SMP test:
ELO: -0.00 +-12.7 (95%) LOS: 50.0%
Total: 1000 W: 173 L: 173 D: 654
No functional change.
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
v = value without ep capture being considered
v1 = value of the ep capture
The correct logic is:
if without e.p. capture we are losing, and the value of e.p is either draw, or win or "loss, but 50 move rule saves us", then we should use the value of ep capture.
Credit and thanks to syzygy1 and lantonov !
No functional change (except with syzygy bases)
Resolves#415Resolves#394
This micro-optimization only complicates the code and provides no benefit.
Removing it is even a speedup on my machine (i7-3770k, linux, gcc 4.9.1):
stat test master diff
mean 2,403,118 2,390,904 12,214
stdev 12,043 10,620 3,677
speedup 0.51%
P(speedup>0) 100.0%
No functional change.
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.
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