stockfish
5 years agoApex Pawns
Alain SAVARD [Thu, 26 Feb 2015 17:50:35 +0000 (01:50 +0800)]
Apex Pawns

Pawns which are supported already have a bonus. Apex are pawns which are
supported twice.
This patch gives an additional 50% bonus for them.

STC
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 6549 W: 1333 L: 1209 D: 4007

LTC
LLR: 2.95 (-2.94,2.94) [0.00,6.00]
Total: 18002 W: 3037 L: 2850 D: 12115

Bench: 8069601

Resolves #267

5 years agoUse only 'level' as late join metric
Marco Costalba [Thu, 19 Feb 2015 13:14:20 +0000 (14:14 +0100)]
Use only 'level' as late join metric

It seems other metric are useless, this allow us
to simplify the code and to prune useless stuff.

STC 20K games 4 threads
ELO: -0.76 +-2.8 (95%) LOS: 29.9%
Total: 20000 W: 3477 L: 3521 D: 13002

STC 10K games 16 threads
ELO: 1.36 +-3.9 (95%) LOS: 75.0%
Total: 10000 W: 1690 L: 1651 D: 6659

bench: 8253813

5 years agoFurther refine SMP code
Marco Costalba [Sat, 21 Feb 2015 10:33:03 +0000 (11:33 +0100)]
Further refine SMP code

Backported from C++11 branch:

https://github.com/official-stockfish/Stockfish/commit/7ff965eebfbc17d2b
https://github.com/official-stockfish/Stockfish/commit/e74c2df907d5336d3d2b

Fully verified it is equivalent to master (see log msg
of individual commits for details).

No functional change.

5 years agoFix comment for kingAdjacentZoneAttacksCount
Stéphane Nicolet [Thu, 19 Feb 2015 20:33:07 +0000 (21:33 +0100)]
Fix comment for kingAdjacentZoneAttacksCount

The comment for kingAdjacentZoneAttacksCount[] was bogus, using
reversed semantics for color.

No functional change

Resolves #262

5 years agoMobile phalanxes
snicolet [Fri, 20 Feb 2015 19:56:57 +0000 (19:56 +0000)]
Mobile phalanxes

Try to create mobile phalanxes

STC:
LLR: 2.97 (-2.94,2.94) [-1.50,4.50]
Total: 52393 W: 10912 L: 10656 D: 30825

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,6.00]
Total: 30398 W: 5315 L: 5063 D: 20020

Bench: 8253813

Resolves #261

5 years agoClarify we don't late join with only 2 threads
Marco Costalba [Thu, 19 Feb 2015 22:12:59 +0000 (23:12 +0100)]
Clarify we don't late join with only 2 threads

Thanks to Gary for pointing this out.

No functional change.

5 years agoUse size_t consistently across thread code
Marco Costalba [Thu, 19 Feb 2015 09:43:28 +0000 (10:43 +0100)]
Use size_t consistently across thread code

No functional change.

5 years agoRetire redundant sp->slavesCount field
Marco Costalba [Thu, 19 Feb 2015 09:27:24 +0000 (10:27 +0100)]
Retire redundant sp->slavesCount field

It should be used slavesMask.count() instead.

Verified 100% equivalent when sp->allSlavesSearching:

dbg_hit_on(sp->allSlavesSearching, sp->slavesCount != sp->slavesMask.count());

No functional change.

5 years agoFix a warning under MSVC
Marco Costalba [Thu, 19 Feb 2015 09:18:24 +0000 (10:18 +0100)]
Fix a warning under MSVC

Assignment of size_t to int.

No functional change.

5 years agoAdd a couple of asserts to late join
Marco Costalba [Thu, 19 Feb 2015 09:08:29 +0000 (10:08 +0100)]
Add a couple of asserts to late join

Document and clarify that we cannot rejoin on ourselves
and that we never late join if we are master and all
slaves have finished, inded in this case we exit idle_loop.

No functional change.

5 years agoRemove useless condition in late join
Marco Costalba [Thu, 19 Feb 2015 08:51:17 +0000 (09:51 +0100)]
Remove useless condition in late join

In case of Threads.size() == 2 we have that sp->allSlavesSearching
is always false (because we have finished our search), bestSp is
always NULL and we never late join, so there is no need to special
case here.

Tested with dbg_hit_on(sp && sp->allSlavesSearching) and
verified it never fires.

No functional change.

5 years agoCompute SplitPoint::spLevel on the fly
Marco Costalba [Tue, 17 Feb 2015 09:10:58 +0000 (10:10 +0100)]
Compute SplitPoint::spLevel on the fly

And retire a redundant field. This is important also
from a concept point of view becuase we want to keep
SMP structures as simple as possible with the only
strictly necessary data.

Verified with

dbg_hit_on(sp->spLevel != level)

that the values are 100% the same out of more 50K samples.

No functional change.

5 years agoSimplify attackUnits formula
Marco Costalba [Tue, 17 Feb 2015 07:23:35 +0000 (08:23 +0100)]
Simplify attackUnits formula

Use '/ 8' instead of '* 31 / 256'

Passed STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 55077 W: 10999 L: 10940 D: 33138

And LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 14751 W: 2530 L: 2400 D: 9821

bench: 7911944

5 years agoImprove smp performance for high number of threads
Joona Kiiski [Sat, 14 Feb 2015 20:46:00 +0000 (20:46 +0000)]
Improve smp performance for high number of threads

Balance threads between split points.

There are huge differences between different machines and autopurging makes it very difficult to measure the improvement in fishtest, but the following was recorded for 16 threads at 15+0.05:

    For Bravone (1000 games): 0 ELO
    For Glinscott (1000 games): +20 ELO
    For bKingUs (1000 games): +50 ELO
    For fastGM (1500 games): +50 ELO

The change was regression for no one, and a big improvement for some, so it should be fine to commit it.
Also for 8 threads at 15+0.05 we measured a statistically significant improvement:
ELO: 6.19 +-3.9 (95%) LOS: 99.9%
Total: 10325 W: 1824 L: 1640 D: 6861

Finally it was verified that there was no (significant) regression for

4 threads:
ELO: 0.09 +-2.8 (95%) LOS: 52.4%
Total: 19908 W: 3422 L: 3417 D: 13069

2 threads:
ELO: 0.38 +-3.0 (95%) LOS: 60.0%
Total: 19044 W: 3480 L: 3459 D: 12105

1 thread:
ELO: -1.27 +-2.1 (95%) LOS: 12.3%
Total: 40000 W: 7829 L: 7975 D: 24196

Resolves #258

5 years agoCompute checkers from scratch
lucasart [Mon, 16 Feb 2015 01:34:26 +0000 (09:34 +0800)]
Compute checkers from scratch

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.

5 years agoFurther simplify KingDanger init
Marco Costalba [Sat, 14 Feb 2015 14:55:11 +0000 (15:55 +0100)]
Further simplify KingDanger init

And remove a tale whitespace while there.

No functional change.

5 years agoSmall bonus for all safe pawn pushes
snicolet [Fri, 13 Feb 2015 21:33:00 +0000 (21:33 +0000)]
Small bonus for all safe pawn pushes

Pawn flexibility: add a small bonus for all safe pawn pushes

STC:
LLR: 2.70 (-2.94,2.94) [-1.50,4.50]
Total: 18233 W: 3705 L: 3557 D: 10971

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,6.00]
Total: 17684 W: 3042 L: 2854 D: 11788

Bench: 7369224

Resolves #253

5 years agoFix KingDanger[] array initialization
hxim [Mon, 9 Feb 2015 18:12:04 +0000 (19:12 +0100)]
Fix KingDanger[] array initialization

Use integer arithmetic instead of floating point arithmetic.
Floating point arithmetic was causing different results for some 32-bit compiles

No functional change

Resolves #249
Resolves #250

5 years agoPawn Center Bind Bonus
Joona Kiiski [Sun, 8 Feb 2015 19:20:39 +0000 (19:20 +0000)]
Pawn Center Bind Bonus

Bonus for two pawns controlling the same central square

STC:

LLR: 3.14 (-2.94,2.94) [-1.50,4.50]
Total: 15974 W: 3291 L: 3133 D: 9550

LTC:

LLR: 3.24 (-2.94,2.94) [0.00,6.00]
Total: 10449 W: 1837 L: 1674 D: 6938

Idea from Lyudmil Tsvetkov.

Bench: 7699138

Resolves #248

5 years agoRename dbg_hit_on_c() to dbg_hit_on()
Marco Costalba [Sat, 7 Feb 2015 10:15:38 +0000 (11:15 +0100)]
Rename dbg_hit_on_c() to dbg_hit_on()

Use an overload instead of a new named function.

I have found this handier and easier when adding
some quick debug code.

No functional change.

5 years agoRemoves useless templates, some of which lead to code duplication: is_K*() functions.
lucasart [Sat, 7 Feb 2015 09:09:56 +0000 (09:09 +0000)]
Removes useless templates, some of which lead to code duplication: is_K*() functions.

No functional change

Resolves #245

5 years agoAdd bonus for pawn attack threats
Stefan Geschwentner [Tue, 3 Feb 2015 03:16:50 +0000 (11:16 +0800)]
Add bonus for pawn attack threats

Latent pawn attacks: Add a bonus to safe pawn pushes which attacks an
enemy piece.  Based on an idea of Lyudmil Tsvetkov.

STC:
LLR: 2.95 (-2.94,2.94) [-1.50,4.50]
Total: 7925 W: 1666 L: 1537 D: 4722

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,6.00]
Total: 40109 W: 6841 L: 6546 D: 26722

Bench: 7696257

Resolves #240

5 years agoProfile build options
mstembera [Tue, 3 Feb 2015 03:09:37 +0000 (11:09 +0800)]
Profile build options

I went through all the individual compile options that differ between
-fprofile-generate/-fprofile-use  and  -fprofile-arcs/-fbranch-probabilities
and distilled the speed difference down to only turning off
-fno-peel-loops and -fno-tracer.  Using this we still get the full speedup
(maybe a bit more because other optimizations stay on) and it's also much cleaner
because we can get rid of the "@rm -f ucioption.gc*" hack for all versions of gcc.

No functional change.

Resolves #237

5 years agoImproved King Safety values
NicklasPersson [Mon, 2 Feb 2015 20:00:52 +0000 (04:00 +0800)]
Improved King Safety values

From an SPSA-session on king safety.

STC:
ELO: 3.21 +-2.1 (95%) LOS: 99.8%
Total: 40000 W: 8181 L: 7812 D: 24007

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 47765 W: 8091 L: 7785 D: 31889

Bench: 8589262

Resolves #241

5 years agoFix a MSVC warning
Marco Costalba [Sat, 31 Jan 2015 09:19:00 +0000 (10:19 +0100)]
Fix a MSVC warning

warning C4805: '|' : unsafe mix of type 'Bitboard' and type 'bool' in operation

No functional change.

5 years agoRessurrect hashfull patch
Jean-Francois Romang [Sun, 25 Jan 2015 07:57:51 +0000 (08:57 +0100)]
Ressurrect hashfull patch

This is an old patch from Jean-Francois Romang to send
UCI hashfull info to the GUI:
https://github.com/mcostalba/Stockfish/pull/60/files

It was wrongly judged as a slowdown, but it takes much
less than 1 ms to run, indeed on my core i5 2.6Ghz it
takes about 2 microsecs to run!

Regression test is good:

STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 7352 W: 1548 L: 1401 D: 4403

LTC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 61432 W: 10307 L: 10251 D: 40874

I have set the name of the author to the original
one.

No functional change.

5 years agoSimplify skill level and reduce ELO
Marco Costalba [Sun, 25 Jan 2015 18:22:43 +0000 (19:22 +0100)]
Simplify skill level and reduce ELO

This patch has two positive effects:

- Retire a hackish formula and leave
  just a natural, simple and plain one.

- Reduce strenght at very low level, but
  don't impact medium/high levels.

Actually even at level 0, SF is still too
strong for many beginners (this was reported
many times for instance on Droidfish user
comments on Google Play).

Test on fishtest shows that ELO drop is around
170 ELO at level 0 (good!), 130 ELO at level 1
and smoothly reduces (as expected) until level
10 where the drop is just of 8 ELO.

No functional change.

5 years agoSimplify backward pawn definition
Alain SAVARD [Mon, 26 Jan 2015 16:05:53 +0000 (11:05 -0500)]
Simplify backward pawn definition

Make use of 'lever' attribute

No functional change

Resolves #234

5 years agoKing safety tuning with values obtained by SPSA.
NicklasPersson [Wed, 28 Jan 2015 21:00:09 +0000 (21:00 +0000)]
King safety tuning with values obtained by SPSA.

Part I:

LTC:

LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 11529 W: 2075 L: 1882 D: 7572

Part II:

LTC:

ELO: 2.07 +-2.1 (95%) LOS: 97.3%
Total: 34859 W: 5967 L: 5759 D: 23133

Bench: 7374604

Resolves #228

5 years agoRestore development version
Joona Kiiski [Wed, 28 Jan 2015 20:53:50 +0000 (20:53 +0000)]
Restore development version

No functional change

5 years agoStockfish 6
Joona Kiiski [Tue, 27 Jan 2015 20:27:38 +0000 (20:27 +0000)]
Stockfish 6

Stockfish bench signature is: 8918745

5 years agoStockfish 6 Release Candidate 3
Joona Kiiski [Sun, 25 Jan 2015 22:03:57 +0000 (22:03 +0000)]
Stockfish 6 Release Candidate 3

- Fix a skill level problem: Don't allow move pruning at root node
- Revert "Fix profile build for gcc on Mac OSX". Results for a faster binary in x86-64.
- Fix a MSVC warning

Bench: 8918745

5 years agoFix a skill level problem: Don't allow move pruning at root node
Stefan Geschwentner [Sat, 24 Jan 2015 21:05:06 +0000 (22:05 +0100)]
Fix a skill level problem: Don't allow move pruning at root node

Bench: 8918745

Resolves #231

5 years agoRevert "Fix profile build for gcc on Mac OSX"
Joona Kiiski [Sun, 25 Jan 2015 21:46:02 +0000 (21:46 +0000)]
Revert "Fix profile build for gcc on Mac OSX"

Seems to be a performance regression for standard build.

For SF6 people compiling on Mac OSX using profile-build option
just need to make necessary adjustments manually...

No functional change

Resolves #223

5 years agoFix a MSVC warning at W4
Marco Costalba [Mon, 19 Jan 2015 07:11:43 +0000 (08:11 +0100)]
Fix a MSVC warning at W4

Warning is C4512 (assignment operator could not be generated)

Now, apart the foreign syzygy code, everything compiles
without warnings at warning level 4.

Backported from C++11 branch.

No functional change.

5 years agoStockfish 6 Release Candidate 2
Joona Kiiski [Sat, 24 Jan 2015 19:38:59 +0000 (19:38 +0000)]
Stockfish 6 Release Candidate 2

- Fix a compilation issue related to BMI2 PEXT instruction
- Retrieve a ponder move from TT if PV is only one move long

Bench: 8080602

No functional change

5 years agoDon't use _pext_u64() directly
Marco Costalba [Tue, 20 Jan 2015 21:17:22 +0000 (22:17 +0100)]
Don't use _pext_u64() directly

This intrinsic to call BMI2 PEXT instruction is
defined in immintrin.h. This header should be
included only when USE_PEXT is defined, otherwise
we define _pext_u64 as 0 forcing a nop.

But under some mingw platforms, even if we don't
include the header, immintrin.h gets included
anyhow through an include chain that starts with
STL <algorithm> header. So we end up both defining
_pext_u64 function and at the same time defining
_pext_u64 as 0 leading to a compile error.

The correct solution is of not using _pext_u64 directly.

This patch fixes a compile error with some mingw64
package when compiling with x86-64.

No functional change.

Resolves #222

5 years agoTry hard to retrieve a ponder move
Marco Costalba [Tue, 20 Jan 2015 08:13:30 +0000 (09:13 +0100)]
Try hard to retrieve a ponder move

In case we stop the search during a fail-high
it is possible we return to GUI without a ponder
move. This patch try harder to find a ponder move
retrieving it from TT. This is important in games
played with 'ponder on'.

bench: 8080602

Resolves #221

5 years agoStockfish 6 Release Candidate 1
Joona Kiiski [Sat, 17 Jan 2015 23:19:18 +0000 (23:19 +0000)]
Stockfish 6 Release Candidate 1

Bench: 8080602

No functional change

Resolves #218

5 years agoFix profile build for gcc on Mac OSX
Joona Kiiski [Sun, 18 Jan 2015 09:04:49 +0000 (09:04 +0000)]
Fix profile build for gcc on Mac OSX

Switch back to using -fprofile-generate and
-fprofile-use flags

No functional change

Resolves #219
Resolves #210

5 years agoDon't print fail-high or fail-lows in MultiPV mode
Joona Kiiski [Sat, 17 Jan 2015 23:01:10 +0000 (23:01 +0000)]
Don't print fail-high or fail-lows in MultiPV mode

Supposed to give a better user experience when using MultiPV mode

No functional change

Resolves #217

5 years agoFix syzygy warnings with Intel compiler
Marco Costalba [Sat, 17 Jan 2015 09:12:02 +0000 (10:12 +0100)]
Fix syzygy warnings with Intel compiler

Quick hack, a better job would require to
first move all syzygy code up to SF standard.

No functional change.

5 years agoFix some missing rename from previous patch
Marco Costalba [Sat, 17 Jan 2015 21:15:15 +0000 (22:15 +0100)]
Fix some missing rename from previous patch

No functional change.

5 years agoFix a possible overflow in TT resize
Marco Costalba [Sat, 17 Jan 2015 08:04:25 +0000 (09:04 +0100)]
Fix a possible overflow in TT resize

On platforms where size_t is 32 bit, we
can have an overflow in this expression:

(mbSize * 1024 * 1024)

Fix it setting max hash size of 2GB on platforms
where size_t is 32 bit.

A small rename while there: now struct Cluster
is definied inside class TranspositionTable so
we should drop the redundant TT prefix.

No functional change.

5 years agoSimplify and optimize value extractors
mstembera [Fri, 16 Jan 2015 19:03:49 +0000 (19:03 +0000)]
Simplify and optimize value extractors

Speed up results by Joona:

gcc-4.7 (1.5%)
gcc-4.8 (0.5%)
gcc-4.9 (1.0%)

Speed up results by mstembera:

gcc 474
p-value: 0.719

gcc 482
p-value: 1

gcc 492
p-value: 0.859

No functional change

Resolves #211

5 years agoEnable futility pruning for PV nodes in qsearch
lucasart [Wed, 14 Jan 2015 20:18:41 +0000 (20:18 +0000)]
Enable futility pruning for PV nodes in qsearch

STC:

LLR: 4.20 (-2.94,2.94) [-3.00,1.00]
Total: 85573 W: 17195 L: 17125 D: 51253

LTC:

LLR: 2.94 (-2.94,2.94) [-3.00,1.00]
Total: 43385 W: 7298 L: 7214 D: 28873

Bench: 8080602

Resolves #206

5 years agoEnable Futility pruning in PV nodes
Stefan Geschwentner [Wed, 14 Jan 2015 20:11:33 +0000 (20:11 +0000)]
Enable Futility pruning in PV nodes

STC:

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 21553 W: 4342 L: 4221 D: 12990

LTC:

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 7675 W: 1351 L: 1209 D: 5115

Bench: 8668014

Resolves #205

5 years agoUse VALUE_ZERO instead of 0 when comparing with Value
hxim [Tue, 13 Jan 2015 21:07:18 +0000 (21:07 +0000)]
Use VALUE_ZERO instead of 0 when comparing with Value

This is the correct practice.

No functional change

Resolves #208

5 years agoAssorted headers cleanup
Marco Costalba [Fri, 9 Jan 2015 11:35:44 +0000 (12:35 +0100)]
Assorted headers cleanup

Mostly comments fixing and other small things.

No functional change.

5 years agoFix a crash of syzygy on Android
Marco Costalba [Sun, 11 Jan 2015 07:31:21 +0000 (08:31 +0100)]
Fix a crash of syzygy on Android

On Android-ARM current TB code crashes at
random times even in single thread mode.

Reported, debugged, fixed and verified
by Peter Osterlund.

No functional change.

Resolves #201

5 years agoHigher movetime resolution for benchmarks
Stefano80 [Sun, 11 Jan 2015 20:02:41 +0000 (20:02 +0000)]
Higher movetime resolution for benchmarks

Use a millisecond movetime precision for benchmarks

No functional change

Resolves #198

5 years agoFix compile for Android 5
Marco Costalba [Sat, 10 Jan 2015 15:14:37 +0000 (16:14 +0100)]
Fix compile for Android 5

Android 5 can only run position independent executables.

Note that this breaks Android 4.0 and earlier.

See here for more info:
http://stackoverflow.com/questions/24818902/running-a-native-library-on-android-l-error-only-position-independent-executab

Thanks to Peter Osterlund for the support.

No functional change

5 years agoUpdate copyright year
Marco Costalba [Sat, 10 Jan 2015 10:43:28 +0000 (11:43 +0100)]
Update copyright year

No functional change.

5 years agoAssorted formatting and comment tweaks in position.h
Marco Costalba [Wed, 7 Jan 2015 08:09:41 +0000 (09:09 +0100)]
Assorted formatting and comment tweaks in position.h

No functional change.

5 years agoTune null search reduction
lucasart [Mon, 5 Jan 2015 22:09:12 +0000 (22:09 +0000)]
Tune null search reduction

STC

LLR: 2.96 (-2.94,2.94) [-0.50,4.50]
Total: 107289 W: 21851 L: 21325 D: 64113

LTC

LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 83837 W: 14378 L: 13916 D: 55543

Bench: 7604776

Resolves #194

5 years agoRetire one implementation of pop_lsb()
Marco Costalba [Sat, 3 Jan 2015 15:39:17 +0000 (16:39 +0100)]
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.

5 years agoRemove a useless optimization
lucasart [Sat, 3 Jan 2015 11:29:00 +0000 (19:29 +0800)]
Remove a useless optimization

This optimization is aimed at old hardware only (withouth popcount), and even on
non popcount compile (ARCH=x86-64), it provides no mesurable speedup:

stat        test     master     diff
mean   2,341,779  2,354,699  -12,920
stdev     12,910     14,770   18,150

speedup      -0.55%
P(speedup>0)  23.8%

No functional change.

Resolves #187

5 years agoSmoother king safety
Joona Kiiski [Sat, 3 Jan 2015 20:34:20 +0000 (20:34 +0000)]
Smoother king safety

STC:

LLR: 4.03 (-2.94,2.94) [-1.50,4.50]
Total: 35707 W: 7352 L: 7106 D: 21249

LTC:

LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 24563 W: 4330 L: 4095 D: 16138

Bench: 8411409

Resolves #190

5 years agoAssorted work in uci.cpp
Marco Costalba [Sat, 3 Jan 2015 09:51:38 +0000 (10:51 +0100)]
Assorted work in uci.cpp

- Change UCI::value() signature

This function should only return the value,
lowerbound and upperbound info is up to the
caller because it requires external knowledge,
out of the scope of this little helper.

- Retire 'key' command

It is not an UCI command and is absolutely
useless: never used.

- Comments fixing and other trivia

No functional change.

5 years agoFix a silly warning with Intel compiler
Marco Costalba [Sat, 3 Jan 2015 09:16:10 +0000 (10:16 +0100)]
Fix a silly warning with Intel compiler

Intel compiler cries for an explicit cast

warning #2259: non-pointer conversion from "double" to "int"
may lose significant bits

No functional change.

5 years agoFix comments in thread.cpp
Marco Costalba [Thu, 1 Jan 2015 09:46:31 +0000 (10:46 +0100)]
Fix comments in thread.cpp

And reshuffle a bit the functions to place
them in a consistent order.

To be on the safe side, patch has been
validated for no regression/crashes with
a small 8K games test with 3 threads:

ELO: 3.98 +-4.4 (95%) LOS: 96.3%
Total: 8388 W: 1500 L: 1404 D: 5484

No functional change.

5 years agoLet material probing to access per-thread table
Marco Costalba [Tue, 30 Dec 2014 09:31:50 +0000 (10:31 +0100)]
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.

5 years agoDisable the default copy constructor for Position class
Matthew Lai [Fri, 2 Jan 2015 20:18:49 +0000 (20:18 +0000)]
Disable the default copy constructor for Position class

No functional change

Resolved #183

5 years agoBig King Safety tuning
Stefan Geschwentner [Fri, 2 Jan 2015 19:31:33 +0000 (03:31 +0800)]
Big King Safety tuning

All king safety related terms (shelterweakness, stormdanger,
attackunits, ..) was tuned together. Additionally for attack units a
finer granularity (factor 4) is used.

STC
ELO: 9.22 +-3.1 (95%) LOS: 100.0%
Total: 19514 W: 4340 L: 3822 D: 11352

LTC
LLR: 2.96 (-2.94,2.94) [0.00,6.00]
Total: 6399 W: 1192 L: 1056 D: 4151

Bench: 8224782

Resolves #184

5 years agoRetire Material::space_weight()
Marco Costalba [Wed, 31 Dec 2014 09:41:20 +0000 (10:41 +0100)]
Retire Material::space_weight()

Move all in evaluation.

Simplify the code and concentrate in a single place
all the logic behind space evaluation, making it much
more clear.

Verified also at STC it does not regress due to a possible
slow down:

LLR: 3.91 (-2.94,2.94) [-3.00,1.00]
Total: 65744 W: 13285 L: 13194 D: 39265

No functional change.

5 years agoAdditional tidy up in timeman.cpp
Marco Costalba [Sun, 28 Dec 2014 11:34:01 +0000 (12:34 +0100)]
Additional tidy up in timeman.cpp

Fixed some comments and moved/renamed some
variables.

No functional change.

5 years agoUse score and value consistently
Marco Costalba [Sat, 27 Dec 2014 09:47:21 +0000 (10:47 +0100)]
Use score and value consistently

And other assorted small fixing, code style
tweaks and reshuffles in evaluate.cpp

No functional change.

5 years agoRemove some comments in timeman.cpp
Arjun Temurnikar [Wed, 24 Dec 2014 03:50:00 +0000 (11:50 +0800)]
Remove some comments in timeman.cpp

Commenst are obsolete now, an updated description
would be quite obscure, so better let the code
to talk and remove them all together.

No functional change.

5 years agoReformat promotion generation
Marco Costalba [Wed, 24 Dec 2014 10:36:04 +0000 (11:36 +0100)]
Reformat promotion generation

Use the same template of other pawns moves generation,
make the code more uniform, simplify generate_promotions
that has now been renamed.

No functional change (verified also with perft).

5 years agoPrefer names to numbers in storm code
Marco Costalba [Sun, 21 Dec 2014 09:52:34 +0000 (10:52 +0100)]
Prefer names to numbers in storm code

Also replaces some tabs with spaces and
change StormDanger order to reflect
ShelterWeakness one.

No functional change.

5 years agoUse "rm -f" instead of "rm" for gcc profiling hack in Makefile
Joona Kiiski [Sat, 20 Dec 2014 08:51:53 +0000 (08:51 +0000)]
Use "rm -f" instead of "rm" for gcc profiling hack in Makefile

In some UNIX systems "rm" prompts user for confirmation.
However "rm -f" is always a guaranteed forced deletion.

Also move gcc profiling hack under the correct target

No Functional change

Resolves #168

5 years agoBig King Safety tuning
Stefan Geschwentner [Sat, 20 Dec 2014 17:49:56 +0000 (01:49 +0800)]
Big King Safety tuning

ShelterWeakness and Stormdanger array are now indexed additionally by
file pair (a/h,b/g,c/f,d/e). The special case of king blocking a pawn
is incorporated in the StormDanger array.  Finally the 93 parameters
are tuned by SPSA on LTC.

STC
ELO: 3.46 +-2.2 (95%) LOS: 99.9%
Total: 40000 W: 8275 L: 7877 D: 23848

LTC
LLR: 2.96 (-2.94,2.94) [0.00,6.00]
Total: 10311 W: 1876 L: 1721 D: 6714

Bench: 9498821

Resolves #163

5 years agoDon't account for Tempo in specialized endgames
Marco Costalba [Tue, 16 Dec 2014 07:25:54 +0000 (08:25 +0100)]
Don't account for Tempo in specialized endgames

The evaluation is already done by the specialized
function, don't need to add something elese later.

With this patch following positions are evaluated
correctly as draws:

8/6p1/1Pkp1p1p/2nNn2P/2P1K1P1/8/8/3B4 w - - 7
8/1k4p1/1P1p1p1p/3NnK1P/2P3P1/1n6/4B3/8 w - -

Verified it not regress with an STC test:
LLR: 3.15 (-2.94,2.94) [-3.00,1.00]
Total: 49812 W: 10095 L: 10016 D: 29701

Reported by Arjun Temurnikar.

bench: 8289983

5 years agoChange profile-build options to produce 1% to 2% faster executables.
mstembera [Thu, 18 Dec 2014 19:56:00 +0000 (03:56 +0800)]
Change profile-build options to produce 1% to 2% faster executables.

The "@rm ucioption.gc*" line is necessary to avoid a gcc 4.7.x bug.
Confirmed for gcc 4.7.4, 4.8.1, and 4.9.1
Suggested by Kiran Panditrao on fishcooking forum.
https://groups.google.com/forum/?fromgroups=#!topic/fishcooking/AY8gN53nG18

No functional change.

Resolves #160

5 years agoImprove comments in UCI
Marco Costalba [Sun, 14 Dec 2014 08:31:13 +0000 (09:31 +0100)]
Improve comments in UCI

And simplify naming while there.

No functional change.

Resolves #159

5 years agoCoding style in TT code
Marco Costalba [Sat, 13 Dec 2014 08:27:39 +0000 (09:27 +0100)]
Coding style in TT code

In particular seems more natural to return
bool and TTEntry on the same line, actually
we should pass and return them as a pair,
but due to limitations of C++ and not wanting
to use std::pair this can be an acceptable
compromise.

No functional change.

Resolves #157

5 years agoFix compile for some versions of mingw
Gary Linscott [Sun, 14 Dec 2014 19:45:43 +0000 (14:45 -0500)]
Fix compile for some versions of mingw

The bswap intrinsics are specific to the compiler, not the
host platform.

No functional change.

Resolves #155

5 years agoAvoid searching TT twice for the same key/position during probe() and store().
mstembera [Sat, 13 Dec 2014 07:16:35 +0000 (07:16 +0000)]
Avoid searching TT twice for the same key/position during probe() and store().

Just keep the pointer and remove code from tt.cpp

STC
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 13620 W: 2810 L: 2665 D: 8145

LTC
LLR: 2.97 (-2.94,2.94) [0.00,6.00]
Total: 13021 W: 2238 L: 2073 D: 8710STC http://tests.stockfishchess.org/tests/view/548436860ebc59331739b90c

STC 4MB
ELO: 2.41 +-2.2 (95%) LOS: 98.6%
Total: 40000 W: 8175 L: 7897 D: 23928

LTC 16MB
ELO: 1.78 +-2.0 (95%) LOS: 96.1%
Total: 39683 W: 6763 L: 6560 D: 26360

Resolves #151

Bench: 8116521

5 years agoOnly use _ReadWriteBarrier on MSVC
Gary Linscott [Thu, 11 Dec 2014 19:56:24 +0000 (14:56 -0500)]
Only use _ReadWriteBarrier on MSVC

It was causing compile errors when cross-compiling using mingw.

No functional change.

5 years agoHalve StormDanger bonus for blocked pawn on A/H file
joergoster [Thu, 11 Dec 2014 18:06:03 +0000 (13:06 -0500)]
Halve StormDanger bonus for blocked pawn on A/H file

STC
LLR: 2.95 (-2.94,2.94) [-1.50,4.50]
Total: 3410 W: 758 L: 641 D: 2011

LTC
LLR: 2.95 (-2.94,2.94) [0.00,6.00]
Total: 33225 W: 5708 L: 5445 D: 22072

Bench: 8465811

Resolves #153

5 years agoMSVC compiling fixes
Gary Linscott [Thu, 11 Dec 2014 18:03:44 +0000 (13:03 -0500)]
MSVC compiling fixes

No functional change.

Resolves #150

5 years agoFix profile build for syzygy
Joona Kiiski [Sun, 7 Dec 2014 19:54:23 +0000 (19:54 +0000)]
Fix profile build for syzygy

Touch source files under syzygy directory to force recompilation
after collecting profile data.

No functional change

Resolves #149

5 years agoRetire 'os' flag from Makefile
Joona Kiiski [Sun, 7 Dec 2014 09:45:36 +0000 (09:45 +0000)]
Retire 'os' flag from Makefile

Appears to be unused

No functional change

Resolves #147

5 years agoAssorted nitpicking code-style
Marco Costalba [Mon, 8 Dec 2014 07:23:09 +0000 (08:23 +0100)]
Assorted nitpicking code-style

No functional change.

5 years agoClarify when forcing the moves loop
Marco Costalba [Mon, 8 Dec 2014 08:46:21 +0000 (09:46 +0100)]
Clarify when forcing the moves loop

In some cases we want to go direcly to the moves loop
without checking for early return. The patch make this
logic more clear and consistent.

Tested for no regression, passed STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 25282 W: 5136 L: 5022 D: 15124

and LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 72007 W: 12133 L: 12095 D: 47779

bench: 9316798

5 years agoSimpler PRNG and faster magics search
Ernesto Gatti [Mon, 8 Dec 2014 00:10:57 +0000 (08:10 +0800)]
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

5 years agoAdd some tablebase positions to bench
Gary Linscott [Sun, 7 Dec 2014 23:55:53 +0000 (07:55 +0800)]
Add some tablebase positions to bench

This makes it easier to check for regressions in the tablebase code.

Bench: 9489202
5-man bench: 8943906

Resolves #145

5 years agoRename some variables for more clarity.
hxim [Sun, 7 Dec 2014 23:53:33 +0000 (07:53 +0800)]
Rename some variables for more clarity.

No functional change.

Resolves #131

5 years agoExplicitly pass RootMoves to TB probes
Marco Costalba [Sun, 30 Nov 2014 13:59:09 +0000 (14:59 +0100)]
Explicitly pass RootMoves to TB probes

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.

5 years agoMove TB stuff under Tablebases namespace
Marco Costalba [Sun, 30 Nov 2014 11:14:14 +0000 (12:14 +0100)]
Move TB stuff under Tablebases namespace

Simplified also some logic while there.

TBLargest needs renaming too, but itis for
a future patch because touches also syzygy
directory stuff.

No functional change.

5 years agoRefactor syzygy code in search
Marco Costalba [Sun, 30 Nov 2014 07:38:46 +0000 (08:38 +0100)]
Refactor syzygy code in search

Move to SF coding style.

Also skip calculating piece count in search()
when TB are not found (!TBCardinality)

No functional change.

5 years agoRetire support for Haiku installation directory from Makefile
Joona Kiiski [Sun, 30 Nov 2014 21:02:39 +0000 (21:02 +0000)]
Retire support for Haiku installation directory from Makefile

- It is out of the scope of the project.
- It is the responsibility of Haiku package maintainer to
  configure this.

No functional change

Resolves #143

5 years agoRetire hackish support for aCC and HP-UX from Makefile
Joona Kiiski [Sun, 30 Nov 2014 20:50:01 +0000 (20:50 +0000)]
Retire hackish support for aCC and HP-UX from Makefile

- It is out of scope of the project.
- We have no way to verify that it even works anymore

No functional change

Resolves #142

6 years agoRetire total_piece_count()
Marco Costalba [Sun, 30 Nov 2014 20:35:22 +0000 (20:35 +0000)]
Retire total_piece_count()

We really don't need to uglify in this way
our nice count() API with this ad-hoc hack.

So remove the hack and use the already
existing infrastructure.

No functional change.

Resolves #134

6 years agoRemove CONNECTED_KINGS from Syzygy code
hxim [Sat, 29 Nov 2014 09:02:32 +0000 (10:02 +0100)]
Remove CONNECTED_KINGS from Syzygy code

No functional change

Resolves #140

6 years agoCleaning Syzygy profiling data
Rodrigo Exterckötter Tjäder [Thu, 27 Nov 2014 18:30:18 +0000 (16:30 -0200)]
Cleaning Syzygy profiling data

Updating the makefile so that the clean and gcc-profile-clean targets also
remove the profiling data files in the syzygy directory.

No functional change.

Resolves #136

6 years agoRewrite TBScore in uci_pv()
Marco Costalba [Wed, 26 Nov 2014 11:56:08 +0000 (12:56 +0100)]
Rewrite TBScore in uci_pv()

Streamline the code and make
it understandable.

No functional change.

Resolves #135

6 years agoRetire #ifdef SYZYGY macro
Marco Costalba [Sat, 29 Nov 2014 08:22:25 +0000 (09:22 +0100)]
Retire #ifdef SYZYGY macro

It just clutters the code for no
real reason.

No functional change.

Resolves #139

6 years agoBitbase index() from ADD to OR.
mstembera [Tue, 25 Nov 2014 23:56:48 +0000 (07:56 +0800)]
Bitbase index() from ADD to OR.

No functional change.

Resolves #132

6 years agoIntroduce ratio operation
lucasart [Tue, 25 Nov 2014 23:53:40 +0000 (07:53 +0800)]
Introduce ratio operation

Just like in Physics, the ratio of 2 things in the same unit, should be
without unit.

Example use case:
- Ratio of a Depth by a Depth (eg. ONE_PLY) should be an int.
- Ratio of a Value by a Value (eg. PawnValueEg) should be an int.

Remove a bunch of useless const while there.

No functional change.

Resolves #128