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

165 commits

Author SHA1 Message Date
root
81498ecce4 Reduce 2015-01-10 14:26:06 +00:00
root
aefabaa70f Reduce 2015-01-10 14:22:16 +00:00
root
7932397ed9 Simplify 2015-01-10 14:19:06 +00:00
root
18d2ca5055 Remove Rank 2015-01-10 14:14:17 +00:00
root
32ff92de2f Further reduce 2015-01-10 14:10:48 +00:00
root
c091add4fd Simplify 2015-01-10 14:06:35 +00:00
root
9fbd8f4f72 Further reduce 2015-01-10 14:05:41 +00:00
root
63136b8c68 bitboard.cpp reduce more 2015-01-10 14:04:00 +00:00
root
57e512b7a3 Simplify bitboard.cpp 2015-01-10 13:35:49 +00:00
root
80d2d47f7d Retire bitcount 2015-01-10 13:25:38 +00:00
root
0dca235bb1 Reduce init() more 2015-01-10 13:21:18 +00:00
root
2f7d17bc35 Reduce init() code 2015-01-10 13:19:47 +00:00
root
7df483068d Remove SquareBB 2015-01-10 13:18:43 +00:00
root
1aa5432cb2 Reduce bitboard.cpp 2015-01-10 12:47:14 +00:00
root
48de70cdb8 Remove copyright 2015-01-10 12:42:25 +00:00
root
0ee389b782 Remove attacks 2015-01-10 12:31:45 +00:00
root
a69619e174 Remove magics 2015-01-10 12:28:12 +00:00
root
d399001462 Retire FORCE_INLINE 2015-01-10 12:10:49 +00:00
root
460e64667a Reduce types.h 2015-01-10 12:05:26 +00:00
root
c0fb31cac3 rm misc.h 2015-01-10 11:53:59 +00:00
Marco Costalba
3fda064a66 Retire one implementation of pop_lsb()
We have two implementations that are equivalent,
so retire one.

Plus usual tidy up of comments and code reshuffle.

No functional change.
2015-01-03 22:16:30 +01:00
Marco Costalba
91cc82aa25 Let material probing to access per-thread table
It is up to material (and pawn) table look up
code to know where the per-thread tables are,
so change API to reflect this.

Also some comment fixing while there

No functional change.
2015-01-02 21:31:02 +01:00
Marco Costalba
5943600a89 Assorted nitpicking code-style
No functional change.
2014-12-10 12:38:13 +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
hxim
fbb53524ef Rename some variables for more clarity.
No functional change.

Resolves #131
2014-12-08 07:53:33 +08: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
375797d51c Retire CACHE_LINE_ALIGNMENT
Speed tests showed no benefit.

No functional change.

Resolves #97
2014-11-07 14:27:04 -05:00
David Zar
68171ecaca Small code style reformatting
No functional change.
2014-07-29 06:52:32 +08:00
Marco Costalba
9b30913996 Avoid 'double assigments' tricks
Bitboard init code is already noteasy to follow,
so don't make it even harder using 'smart' code.

Also reindent a while loop in standard way.

No functional change.
2014-07-07 21:53:25 +08:00
Marco Costalba
da2f8880b9 Switch to hardware PEXT
Retire software pext and introduce hardware
call when USE_PEXT is defined during compilation.

This is a full complete implementation of sliding
attacks using PEXT.

No functional change.
2014-04-12 08:55:30 +02:00
Marco Costalba
c556fe1d71 Implement PEXT based attacks
According to:

https://chessprogramming.wikispaces.com/BMI2#PEXTBitboards

No functional change.
2014-04-12 08:55:30 +02:00
Marco Costalba
2bfe61c33b Add PEXT software implementation
For development/debug purposes.

No functional change.
2014-04-12 08:55:30 +02:00
Marco Costalba
64d29a6330 Sync some common names
No functional change.
2014-04-06 11:26:12 +02:00
Marco Costalba
bc183b0c04 Retire last usage of operator|(File f, Rank r)
This for some reason was missed.

No functional change.
2014-03-23 10:42:37 +01:00
Marco Costalba
de2ba70830 Simplify Bitboards::pretty
No functional change.
2014-03-01 13:10:05 +01:00
Marco Costalba
b3470d7ab1 Fix magic boosters conversion
Fix small overflow error while converting
magic boosters from right rotate to left rotate,
in particular booster 38 was converted to 4122
instead of the corrcet value 26.

Formula used was:

s1 = original & 63, s2 = (original >> 6) & 63;
new = (64 - s1) | ((64 - s2) << 6);

Instead of:

s1 = original & 63, s2 = (original >> 6) & 63;
new = ((64 - s1) & 63) | (((64 - s2) & 63) << 6);

This has no impact in number of cycles needed, but
just in the resultig number that yields to a rotate
amount bigger than 63.

Spotted by Ehsan Rashid.

No functional change.
2014-02-14 10:43:37 +01:00
Marco Costalba
e6523e56b8 Move magic random to RKISS
When initializing the magic numbers used to
compute sliding attacks, we endless generate a
random and test it as a possible magic.

In the general case this takes a lot of iterations,
but here, insteaad of picking a casual random, we
rotate it a couple of times and generate a number that
we know has a good probability to be a magic candidate.

This is becuase the quantities by which we rotate the
number are known in advance to produce quickly a good
canidate.

The patch, inspired by DON, just moves the shuffle to RKISS
changing the boosters to take in account a left rotation
instead of a right rotation as in the original.

No functional change.
2014-02-12 14:47:36 +01:00
Marco Costalba
41641e3b1e Assorted tweaks from DON
Mainly renames and some little code style improvment,
inspired by looking at DON sources:

https://github.com/erashid/DON

No functional change.
2014-02-09 17:31:45 +01:00
Marco Costalba
c9dcda6ac4 Update copyright year
No functional change.
2014-01-02 01:49:18 +01:00
Marco Costalba
4630ab5743 More work on Bitboards::init()
No functional change.
2013-12-07 12:32:18 +01:00
Marco Costalba
1ff5ce8863 More readable init of MS1BTable[]
Because now it uses lsb(), the BSFTable[] must be
already initialized.

No functional change.
2013-12-07 11:35:26 +01:00
Marco Costalba
b71418defa Further simplify Bitboards init()
No functional change.
2013-12-07 10:57:05 +01:00
Jerry Donald
a8af78c833 Another round of spelling fixes
And also renamed a loop variable while there.

No functional change.
2013-12-02 23:51:29 +01:00
Richard Lloyd
13a73f67c0 Big assorted spelling fixes
No functional change.
2013-12-02 20:29:35 +01:00
Marco Costalba
5f2bf91ad1 Rename Bitboards print to pretty
To align to same named Position function and
avoid using std::cout directly.

Also remove some stale <iostream> include while
there.

No functional change.
2013-11-30 11:32:49 +01:00
Marco Costalba
034a2b04f2 Rewrite some bitboard init code
And move the static function Position::attacks_from() to
bitboard code renaming it attacks_bb()

No functional change.
2013-11-30 11:02:56 +01:00
Marco Costalba
a518d5d3ad Simplify squares_aligned()
Use newly introduced LineBB[]

No functional change.
2013-11-10 12:05:19 +01:00
Chris Caino
091aff0445 Evaluate mobility of pinned pieces exactly
Previously some squares could be "incorrectly" awarded
to a pinned piece.

e.g. in 3k4/1q6/3b4/3Q4/8/5K2/B7/8 b - - 0 1 the black
bishop get 4 squares too many and the white queen gets 6.

Passed both short TC.
LLR: 2.97 (-2.94,2.94) [-1.50,4.50]
Total: 4871 W: 934 L: 817 D: 3120

And long TC:
LLR: 2.96 (-2.94,2.94) [0.00,6.00]
Total: 38968 W: 6113 L: 5837 D: 27018

bench: 9282549
2013-11-10 11:52:38 +01:00
Lucas Braesch
7f142d6817 Use prefix operators wherever possible
No functional change.
2013-10-05 18:10:43 +02:00
Kojirion
a71209868b Use pre-increment also for native types
Now that we use pre-increment on enums, it
make sense, for code style uniformity, to
swith to pre-increment also for native types,
although there is no speed difference.

No functional change.
2013-09-15 09:17:21 +02:00