Remove the involved size[] array to get the
sizes from setup_pairs().
Now code it is more self-documenting because each
table is associated with its clear size.
Currently we malloc a single memory
chunk in which we shuffle all kind of
different stuff in a very tricky way,
for instance see PairsData::base[1]
that is a hack used as a pointer to
data instead of an actual array (no
wonder C++ compiler complains!).
This patch rewrites all this in a way
to avoid hacky allocations and instead
to rely on the standard containers to
do their job.
This is the base for future work.
Now, Binomial[k][n] = Bin(k, n), instead of Binomial[k-1][n] = Bin(k, n).
Better document the Pascal triangle:
* Sum the above and the one to the left of it.
* Values outside the triangle are zero. This was not checked for k=n previously,
and the code implicitly relied on zero initialization of Binomial[]. That
reliance was made more confusing by the initial assignment before the loop.
No functional change.
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.
Seems to give around 1% speed-up for CPUs with popcnt support.
Seems to give a very minor speed-up for CPUs without popcnt.
No functional change
Resolves#646
* 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.