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.
* 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
In this position we should have draw for repetition:
position fen rnbqkbnr/2pppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 moves g1f3 g8f6 f3g1
go infinite
But latest patch broke it.
Actually we had two(!) very subtle bugs, the first is that Position::set()
clears the passed state and in particular 'previous' member, so
that on passing setupStates, 'previous' pointer was reset.
Second bug is even more subtle: SetupStates was based on std::vector
as container, but when vector grows, std::vector copies all its contents
to a new location invalidating all references to its entries. Because
all StateInfo records are linked by 'previous' pointer, this made pointers
go stale upon adding more element to setupStates. So revert to use a
std::deque that ensures references are preserved when pushing back new
elements.
No functional change.