1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00
Commit graph

3968 commits

Author SHA1 Message Date
Marco Costalba
2a48e7a69c Simplify encoding of remaining pieces 2016-05-07 09:53:16 +02:00
Alain SAVARD
4b9ed6566a Unsafe checks
Introducing a new multi-purpose penalty related to King safety, which
includes all kind of potential checks (from unsafe or unavailable
squares currently occupied by some other piece)

This will indirectly detect and reward some pins, discovered checks, and
motifs such as square vacation, or rook behind its pawn and aligned with
King (example Black Rg8, g7 against Kg1),
and penalize some pawn blockers (if they move, it allows a discovered
check by the pawn).

And since it looks also at protected squares, it detects some potential
defense overloading.

Finally, the rook contact checks had been removed some time ago. This
test will give a small bonus for them, as well as for bishop contact
checks.

Passed STC
http://tests.stockfishchess.org/tests/view/5729ec740ebc59301a354b36
LLR: 2.94 (-2.94,2.94) [0.00,5.00]
Total: 13306 W: 2477 L: 2296 D: 8533

and LTC
http://tests.stockfishchess.org/tests/view/572a5be00ebc59301a354b65
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 20369 W: 2750 L: 2565 D: 15054

bench: 9298175
2016-05-06 20:04:57 +02:00
Marco Costalba
24338c2c66 Some cleanup after previous big patch 2016-05-06 13:59:13 +02:00
Marco Costalba
6a260a7d66 Move all under probe_table()
Still some clean up to do but mainly
it is finished and it works!
2016-05-06 10:17:01 +02:00
Marco Costalba
7dd6e34c10 Call decompress_pairs() from within probe_table() 2016-05-06 09:11:35 +02:00
Marco Costalba
8abce63f34 Add pawns to encode_position() 2016-05-05 22:10:22 +02:00
Marco Costalba
16019f47c8 Fix a subtle overflow issue
Found by stuwph on 6-men TB.
2016-05-05 18:05:49 +02:00
Marco Costalba
5e4cd3fc0d Retire __popcnt64 intrinsic
Just use _mm_popcnt_u64() that is available
both for MSVC abd Intel compiler.

Verified on MSVC that the produced assembly
has the hardware 'popcnt' instruction.

No functional change.
2016-05-05 09:09:07 +02:00
VoyagerOne
5486911e01 Simplify History LMR Formula
STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 41713 W: 7589 L: 7504 D: 26620

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 41353 W: 5484 L: 5391 D: 30478

Bench: 8946983
2016-05-05 08:53:50 +02:00
Marco Costalba
e3cb2659f9 Retire some support tables
And rename MapB1D1D3[] to MapA1D1D4[] because
it is used to map piece on diagonal too when
we don't apply the 3-pieces encoding.
2016-05-03 16:48:25 +02:00
Marco Costalba
d9ec75a2ca Fully document piece enccoding
Use the original Ronald de Man explanations
on talkchess.
2016-05-03 07:03:08 +02:00
Marco Costalba
3487eb9f9e Fix a warning with MSVC
Introduced by 2dd24dc4e6 ("Use popcount intrinsic with Intel")

No functional change.
2016-05-01 15:10:33 +02:00
joergoster
dc0030de4f Fix LazySMP when searching to a fixed depth.
Currently, helper threads will only search up to the
specified depth limit. Now let them search until the
main thread has finished the specified depth.

On the other hand, we don't want to pick a thread with
a higher search depth.

This may be considered cheating. ;-)

No functional change.
2016-05-01 14:30:50 +02:00
erbsenzaehler
2dd24dc4e6 Use popcount intrinsic with Interl compiler
It seems that icc used our fallback version of popcount.
Now use intrinsics.

icc version 16.0.2 (gcc version 5.3.0 compatibility)
bmi2 compile
uname -r 4.5.1-1-ARCH

20xbench gives a nice speedup
./stockfish-icc-master 2161515 +- 34462
./stockfish-icc-sse42 2260857 +- 50349
2016-05-01 14:18:16 +02:00
Krgp
8f934dff9a Remove useless -mbmi flag in Makefile
I could not find anything documented that is necessary that prepending -mbmi to -mbmi2 gives some benefit.
Instead at
https://gcc.gnu.org/onlinedocs/gcc/x86-Built-in-Functions.html#x86-Built-in-Functions

The following built-in functions are available when -mbmi is used. All of them generate the machine instruction that is part of the name.
unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);

The following built-in functions are available when -mbmi2 is used. All of them generate the machine instruction that is part of the name.
unsigned int _bzhi_u32 (unsigned int, unsigned int)
unsigned int _pdep_u32 (unsigned int, unsigned int)
unsigned int _pext_u32 (unsigned int, unsigned int)
unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
unsigned long long _pext_u64 (unsigned long long, unsigned long long)

and at
https://gcc.gnu.org/ml/gcc/2014-02/msg00204.html

( "... The real optimization comes from being able to use pext
(parallel bit extract), which can implement several bextr expressions in
parallel.")

Apart from that we don't use all -msse -msse2 -msse3 -msse4.2 etc. but just -msse3 (or -msse4.2) only.

As regards to the speedup within noise level - this pull request is actually reversal of mcostalba#198 wherein prepending -mbmi to -mbmi2 was claimed to be 0.3% faster and here (removing -mbmi) gives 0.4% speed gain.
2016-05-01 14:11:28 +02:00
Marco Costalba
b20c26ad3b Better document set_sizes
In particular clarify the data layout.

Remove a bunch of useless casts while
there.
2016-05-01 13:20:31 +02:00
Marco Costalba
3328ab35bf Move some common fields under precomp 2016-05-01 09:53:28 +02:00
Stéphane Nicolet
2694ef23c3 Isolated pawn simplification
STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 117822 W: 21697 L: 21744 D: 74381

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 92307 W: 12330 L: 12305 D: 67672

Bench: 8813983

Resolves #659
2016-04-30 22:23:22 +01:00
Marco Costalba
5cbbeaf28e Better document init() 2016-04-30 10:58:44 +02:00
Marco Costalba
6a802b2473 Rewrite number conversion functions 2016-04-30 07:55:33 +02:00
Marco Costalba
e4045c312b Unify set_norms() 2016-04-29 18:41:46 +02:00
Marco Costalba
431767b592 Merge DTZ initializations
I have also found a simpler way to avoid some
template gymnic.
2016-04-29 17:53:04 +02:00
Marco Costalba
ef69f37f82 Merge WDL initializations
Same initialization logic for both
pawns and pieces.

The advantage of this patch is that we reduce
redundancy and get a single (source) code path
for both cases. This is easier to understand
and to mantain.

Note: This patch makes use of some advanced template
techniques like SFINAE, decltype and the new function
declaration syntax (with trailing return type). This
is not just a show-off, but it is really needed in
this case.
2016-04-29 09:37:36 +02:00
Marco Costalba
7a600ed986 Unify set_factors()
This is needed for future work.
2016-04-29 07:37:56 +02:00
Marco Costalba
8ed3859aad Explicit size calculation
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.
2016-04-28 17:57:00 +02:00
Marco Costalba
a0d7801405 Use some more loops in WDLEntry::init
And remove a lot of code.
2016-04-28 16:13:15 +02:00
Marco Costalba
bfa2d923a7 Fix a compile issue with mingw 5.3 2016-04-28 14:04:29 +02:00
Marco Costalba
9cf110a2ae Get rid of PairsData allocation kludge
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.
2016-04-28 13:59:09 +02:00
Marco Costalba
efc8557b2d Further cleanup of init stuff
Let WDL and DTZ init to be in sync as
much as possible.
2016-04-27 18:02:44 +02:00
Marco Costalba
48ef73fc6c Further cleanup init() functions 2016-04-27 14:33:03 +02:00
lucasart
369c7f416f Better document Binomial[]
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.
2016-04-27 20:00:36 +08:00
Marco Costalba
f83a6f54e4 Retire subfactor()
Directly lookup in Binomial[] table.
2016-04-27 09:16:12 +02:00
Marco Costalba
145c9d943b Improve TBFile API
Do more work inside TBFile::map() and
simplify the init functions.
2016-04-27 09:01:08 +02:00
Marco Costalba
0fcc2addd1 First attempt at WDLEntry::init()
Still a lot to do...
2016-04-26 20:45:51 +02:00
Marco Costalba
e480cc108a Rearrange DTZ struct
Redefine some fields in a more consistent way.
2016-04-26 18:13:31 +02:00
Marco Costalba
91b9463ec3 Inline a bunch of single-use functions
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!
2016-04-26 17:53:19 +02:00
Marco Costalba
d91b6f9a17 Remove pointer usage in init() members
Now that these functions are struct
members, we don't need to use pointers
anymore.
2016-04-26 14:21:02 +02:00
lucasart
a9abb35c9c Constructed objects must be destructible
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.
2016-04-26 13:46:14 +02:00
Marco Costalba
578e94629b Add DTZEntry constructor
And sync WDL and DTZ initializations
2016-04-26 12:09:37 +02:00
Marco Costalba
3104915cd1 Add WDLEntry constructor 2016-04-26 09:58:13 +02:00
Marco Costalba
bb9d42f425 Rename structs
Use a more consistent naming convention
2016-04-26 09:27:37 +02:00
Marco Costalba
9e24e68419 Add struct destructors
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.
2016-04-26 09:13:27 +02:00
Marco Costalba
c7c4ab8186 Get rid of DTZEntryList
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.
2016-04-25 14:43:28 +02:00
Marco Costalba
d3f748c285 Get rid of wild struct aliasing casting
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.
2016-04-25 10:43:57 +02:00
Marco Costalba
10b11da913 Restore back DTZ_list size limit
We will remove it when we will have
a better understanding of the code base,
for now just stick to the original
functionality.
2016-04-25 09:01:33 +02:00
Marco Costalba
4119955044 Get rid of get_key()
And also of namespace Zobrist: there is no more need
for TB code to look at Position's internals.
2016-04-24 21:46:06 +02:00
Marco Costalba
fe6ba8d805 Retire load_dtz_table() 2016-04-24 20:49:07 +02:00
Marco Costalba
637f5b5ecb Convert DTZ_table to a std::list
Because it is used as a list, with a LRU
replacement policy and LRU enries order.

Also drop the hardcoded limit on max 64 entries.
2016-04-24 18:50:06 +02:00
Marco Costalba
216e8cc195 Get rid of fixed size array
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.
2016-04-24 14:33:41 +02:00
Marco Costalba
1a8e0416bb Document encode_piece
Retire Flipdiag[] while there
2016-04-24 14:07:13 +02:00