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

3745 commits

Author SHA1 Message Date
joergoster
3054db989d Use distance<file>() function in endgame.cpp
This one occurance of distance function was most likely overlooked.

No functional change.

Resolves #376
2015-07-12 20:48:50 +01:00
Marco Costalba
b2edac7075 Remove useless razoring condition
STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 20626 W: 3977 L: 3855 D: 12794

LTC:
LLR: 3.10 (-2.94,2.94) [-3.00,1.00]
Total: 87334 W: 13675 L: 13648 D: 60011

Retire also the now unused pawn_on_7th() helper.

bench: 8248166
2015-07-09 08:13:30 +02:00
VoyagerOne
aa0dc16b75 CMH Fix: Exclude captures for TT move refutation penalty
This will make sure we store only quiet moves for TT Penalty.

STC:
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 34748 W: 6617 L: 6420 D: 21711

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 19975 W: 3259 L: 3137 D: 13579

Bench: 8063826

Resolves #373
2015-07-04 14:22:41 +01:00
Marco Costalba
112607bf49 Correctly check for no-makefile compile
Under Windows with MSVC we use the IDE to compile,
in this case we infer some compiler flags usually
set by Makefile.

The condition to check this was wrong, namely when compiling
with mingw under Windows 64 bit we always set IS_64BIT and
USE_BSFQ even if compiled with ARCH=x86-32 (this is how I
found it).

Small code style touches while there.

No functional change.
2015-06-28 10:56:42 +02:00
VoyagerOne
7e9f776fca LMR Tweak: Decrease reduction if cmh>0 && history>0.
STC:
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 9627 W: 1879 L: 1748 D: 6000

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,6.00]
Total: 21543 W: 3433 L: 3234 D: 14876

Bench: 8646407

Resolves #370 #371
2015-06-27 09:45:59 +01:00
Marco Costalba
3f1bc9e013 Fix compile on icc
Error is:

  a value of type "int" cannot be assigned to an entity of type "Value"

Also retire the now unused squares_of_color() function.

No functional change.
2015-06-25 05:29:56 +02:00
joergoster
e8cc5c9968 Small coding style fix for Outpost array
No functional change

Resolves #367
2015-06-17 15:02:57 +01:00
lucasart
00563be5cc Retire -Wno-long-long
long long is part of the C++11 standard.

No functional change.

Resolves #364
2015-06-13 16:59:50 +01:00
lucasart
ad87d707ff Simplify outpost evaluation
STC

LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 114149 W: 21986 L: 22032 D: 70131

LTC

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 52232 W: 8468 L: 8396 D: 35368

Bench: 6716940

No functional change

Resolves #363
2015-06-07 09:49:01 +01:00
Vince Negri
7b8ffe0f5d Remove intermediate re-search in LMR
STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 20149 W: 3830 L: 3707 D: 12612

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 45384 W: 7089 L: 7006 D: 31289

Bench: 8110365

Resolves #361
2015-06-05 21:03:10 +01:00
Marco Costalba
c1d3bd2dba Rename stages
Hopefully more clear.

No functional change.
2015-06-04 15:51:45 +02:00
lucasart
5ebdf2f8c8 Tune pawn shelter/storm
STC
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 31679 W: 6183 L: 5912 D: 19584

LTC
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 43550 W: 6885 L: 6602 D: 30063

Bench: 9219343

Resolves #360
2015-06-02 12:09:19 -07:00
Stéphane Nicolet
4502a1934f Tweak backward pawns definition
Advanced pawns cannot be backward. Also lower the backward penalty in
endgame.

Passed STC:
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 18534 W: 3588 L: 3433 D: 11513

and LTC:
LLR: 2.96 (-2.94,2.94) [0.00,6.00]
Total: 21319 W: 3415 L: 3217 D: 14687

Bench: 7271152

Resolves #359
2015-06-02 12:07:02 -07:00
Marco Costalba
2795aedbc3 Checking for rook color when setting castling
In Chess960 we can have legal positions with
opponent rook in A or H file and with castling
available, for instance:

4k3/pppppppp/8/8/8/8/PPPPPPPP/rR2K3 w Q - 0 1

In those cases we pick up the wrong rook when
setting castling.

Fix it by checking the color of the rook.

Bug reported by Matthew Lai.

No functional change.
2015-05-29 05:38:40 +02:00
lucasart
8e95c39bfa Simplify backward pawn scoring
STC

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 52322 W: 10011 L: 9945 D: 32366

LTC

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 14143 W: 2334 L: 2203 D: 9606

Bench: 7976423

Resolves #354
2015-05-27 20:05:20 +01:00
Joona Kiiski
80a759d544 Resolve build failure for Mac
Remove '-Wl' switch from gcc arguments when compiling for Mac

No functional change

Resolves #353
2015-05-24 13:07:15 +01:00
lucasart
2e0ec4ad6f Fix merge error for Tuned PSQT
Fall-out from 411e704f

Bench: 7907776

Resolves #352
2015-05-21 19:56:01 +01:00
Stefan Geschwentner
e14046517e Remove Gain Stats
Additionally in futility pruning the margin is raised for compensation.

STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 48481 W: 9229 L: 9156 D: 30096

LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 32058 W: 5134 L: 5031 D: 21893

Bench: 8098149

Resolves #350
2015-05-18 13:59:30 -07:00
lucasart
411e704fdf Tuned PSQT
STC:
LLR: 3.11 (-2.94,2.94) [-0.50,4.50]
Total: 58764 W: 11530 L: 11185 D: 36049

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,4.50]
Total: 282710 W: 46339 L: 45209 D: 191162

Bench: 8512947

Resolves #349
2015-05-18 13:54:45 -07:00
Marco Costalba
ee0371f86e Cleanup work in misc.cpp
Also some code style tidy up of latest patches.

Also renamed checkSq -> checkSquares because it
is a bitboard and not a square.

No functional change.
2015-05-10 09:42:26 +02:00
mstembera
eaeb63f1d0 Smart TT save
Don't overwrite more valuable data with less valuable data

STC 2MB
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 21132 W: 4108 L: 3946 D: 13078
http://tests.stockfishchess.org/tests/view/5547d59f0ebc5940ca5d6883

LTC 8MB
LLR: 2.97 (-2.94,2.94) [0.00,6.00]
Total: 13381 W: 2149 L: 1987 D: 9245
http://tests.stockfishchess.org/tests/view/5549b5a80ebc5940ca5d68b9

STC 16MB regression w/ zero effective hash pressure
LLR: 2.96 (-2.94,2.94) [-5.00,0.00]
Total: 18944 W: 3607 L: 3564 D: 11773
http://tests.stockfishchess.org/tests/view/554b0fda0ebc5940ca5d68ea

Bench: 8787152

Resolves #347
2015-05-09 17:43:57 +01:00
lucasart
92dbee7875 Edge distance
Instead of crafting a clever formula to calculate the array offset, simply use a
3 dimensional array. Remove the comment while at it, because now the code is
self-documenting.

No functional change.

Resolves #344
2015-05-09 14:06:19 +01:00
lucasart
2e86d1febc Restore deterministic search state
Introduce helper function Search::reset() which clears all kind of search
memory, in order to restore a deterministic search state.

Generalize TT.clear() into Search::reset() for the following use cases:
- bench: needed to guarantee deterministic bench (ie. if you call bench from
interactive command line twice in a row you get the same value).
- Clear Hash: restore clean search state, which is the purpose of this button.
- ucinewgame: ditto.

No functional change.

Resolves #346
2015-05-07 14:20:32 -07:00
lucasart
946fa47625 Never clear stats
Based on an idea and patch by VoyagerOne.

Small simplification, but was tedted for an ELO gain anyway.

STC:
LLR: 2.95 (-2.94,2.94) [-1.00,4.00]
Total: 5375 W: 1119 L: 977 D: 3279

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 17893 W: 2984 L: 2792 D: 12117

bench 8322847
2015-05-06 19:17:33 +08:00
Marco Costalba
7231b18af1 Halve PSQT row data
Use symmetry along vertical middle axis of the board
to reduce the number of parameters.

For instance psqt value of SQ_A5 == SQ_A4 and value of
SQ_F8 == SQ_F1.

This is always true, at least until now nobody came in
with an asymmetric psqt table that worked.

Original patch by Lucas.

No functional change.
2015-05-03 20:07:52 +02:00
Marco Costalba
578b21bbee Split PSQT init from Position init
Easier for tuning psq tables:

TUNE(myParameters, PSQT::init);

Also move PSQT code in a new *.cpp file, and retire the
old and hacky psqtab.h that required to be included only
once to work correctly, this is not idiomatic for a header
file.

Give wide visibility to psq tables (previously visible only
in position.cpp), this will easy the use of psq tables outside
Position, for instance in move ordering.

Finally trivial code style fixes of the latest patches.

Original patch of Lucas Braesch.

No functional change.
2015-05-03 20:07:15 +02:00
Stefano80
59f64fda4f Improve ordering of good captures using rank term
Rank based term improved approximation of pos.see() for scoring good
captures.

STC
LLR: 2.95 (-2.94,2.94) [-1.50,4.50]
Total: 4632 W: 945 L: 827 D: 2860

LTC
LLR: 2.95 (-2.94,2.94) [0.00,6.00]
Total: 25770 W: 4184 L: 3964 D: 17622

Bench: 7593704

Resolves #342
2015-05-03 10:19:34 -07:00
Stefano80
cc54a91ca5 Replace MVV/LVA by MVV for good captures
Passed STC

LLR: 3.71 (-2.94,2.94) [-3.00,1.00]
Total: 64363 W: 12299 L: 12214 D: 39850

and LTC

LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 69976 W: 11056 L: 11011 D: 47909

Bench: 8012532

Resolves #340
2015-04-28 22:07:48 +01:00
VoyagerOne
b7063ef65b Change extra ply LMR condition to: cmh <= 0 && hist < 0
Extra ply LMR condition is now cmh <= 0 && h < 0
Instead of cmh + h < 0

STC:
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 55210 W: 10812 L: 10557 D: 33841

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 13212 W: 2239 L: 2045 D: 8928

Bench: 8420865

Resolves #339
2015-04-26 20:12:25 +01:00
Alain SAVARD
078625e333 Exclude queen from Rook Contact Check computation
In ei.attackedBy, Queen does not x-ray through Rook, but the Rook does
X-ray through the Queen.

So most of the rook contact checks supported by queen are, in fact,
Queen Contact Checks and they are already scored separately.

Bench: 7762189

Resolves #338
2015-04-18 22:17:46 +01:00
lucasart
6c040c821a Retire FORCE_INLINE
No speed regression on my machine (i7-3770k, gcc 4.9.1, linux 3.16):

        stat        test     master   diff
        mean   2,482,415  2,474,987  7,906
        stdev      4,603      5,644  2,497

        speedup        0.32%
        P(speedup>0)  100.0%

Fishtest 9+0.03:

ELO: 0.26 +-1.8 (95%) LOS: 61.2%
Total: 60000 W: 12437 L: 12392 D: 35171

No functional change.

Resolves #334
2015-04-15 21:21:45 +01:00
VoyagerOne
20e92895af Removed extra condition (history < 0) in LMR to help sync up with move ordering.
LMR condition is now cmh+history<0
Instead of history<0 OR cmh+history<0

STC:
LLR: 2.96 (-2.94,2.94) [-3.00, 1.00]
Total: 26446 W: 5092 L: 4980 D: 16374

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00, 1.00]
Total: 14129 W: 2340 L: 2209 D: 9580

Bench: 7815183

Resolves #331
2015-04-12 20:05:59 +01:00
Marco Costalba
fb03188fc7 Assorted cleanup of last patches
No functional change.
2015-04-11 23:24:43 +02:00
Marco Costalba
a66c73deef Allow Position::init() to be called more than once
Currently Zobrist::castling[] are not properly zeroed
and rely on the compiler to do this at startup, but this
makes Position::init() to set different values every time
it is called!

This is a bit odd, and although not impacting normal usage,
can yield to subtle misbehaviour, very difficult to track
down, in case we happen to call it more than once for some
reason. I found this while developing tuning support and
it took me a while to track it down.

So properly init Zobrist::castling[]

No functional change.

Resolves #329
2015-04-10 20:39:15 +01:00
Stefan Geschwentner
27efc5ac99 Update stats at pv nodes
If a quiet best move is found at a pv node then always update stats.

STC:
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 41485 W: 8047 L: 7830 D: 25608

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,6.00]
Total: 14351 W: 2420 L: 2250 D: 9681

Bench: 6985247

Resolves #330
2015-04-10 20:34:55 +01:00
mstembera
36f2133df3 New formula for quiet move scoring: 3 * cmh + 1 * hist
STC

LLR: 2.97 (-2.94,2.94) [-1.50,4.50]
Total: 45363 W: 8759 L: 8532 D: 28072

LTC

LLR: 3.51 (-2.94,2.94) [0.00,4.00]
Total: 125092 W: 20032 L: 19468 D: 85592

Bench: 7058819

Resolves #328
2015-04-10 20:14:11 +01:00
Stefan Geschwentner
ef4d89c9bd update stats also in check
Update stats also if in check (drop condition).

STC:
LLR: 3.22 (-2.94,2.94) [-3.00,1.00]
Total: 87472 W: 16929 L: 16913 D: 53630

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 39971 W: 6436 L: 6345 D: 27190

Bench: 7086031

Resolves #327
2015-04-09 20:41:08 +01:00
lucasart
aaf17326e2 Prune evasions when we can castle
A minor simplification.

STC:

LLR: 2.95 (-2.94,2.94) [-3.50,0.50]
Total: 67877 W: 12882 L: 12904 D: 42091

STC:

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 20677 W: 4023 L: 3901 D: 12753

LTC:

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 12221 W: 2022 L: 1888 D: 8311

Bench: 7911336

Resolves #326
2015-04-09 20:34:06 +01:00
Stéphane Nicolet
2ca142a5b4 Use minimumSplitDepth = 5
Using minimumSplitDepth = 5 seems to be the best compromise in the
current SMP implementation

STC, 11 threads:

ELO: 14.87 +-4.1 (95%) LOS: 100.0%
Total: 8509 W: 1497 L: 1133 D: 5879

STC, 4 threads:

ELO: 0.30 +-2.8 (95%) LOS: 58.2%
Total: 20000 W: 3365 L: 3348 D: 13287

STC, 2 threads:

ELO: -1.02 +-2.0 (95%) LOS: 16.4%
Total: 40000 W: 7087 L: 7204 D: 25709

Resolves #324
2015-04-09 20:32:36 +01:00
Marco Costalba
ffbaa1c5a8 Fix MSVC warning from previous patch
No functional change.
2015-04-03 19:29:29 +02:00
Marco Costalba
57dfe41ddb Fix elapsed()
Messed up during merge.

No functional change.
2015-04-03 04:53:53 +02:00
Marco Costalba
926f215061 Add support for playing in 'nodes as time' mode
When running more games in parallel, or simply when running a game
with a background process, due to how OS scheduling works, there is no
guarantee that the CPU resources allocated evenly between the two
players. This introduces noise in the result that leads to unreliable
result and in the worst cases can even invalidate the result. For
instance in SF test framework we avoid running from clouds virtual
machines because are a known source of very unstable CPU speed.

To overcome this issue, without requiring changes to the GUI, the idea
is to use searched nodes instead of time, and to convert time to
available nodes upfront, at the beginning of the game.

When nodestime UCI option is set at a given nodes per milliseconds
(npmsec), at the beginning of the game (and only once), the engine
reads the available time to think, sent by the GUI with 'go wtime x'
UCI command. Then it translates time in available nodes (nodes =
npmsec * x), then feeds available nodes instead of time to the time
management logic and starts the search. During the search the engine
checks the searched nodes against the available ones in such a way
that all the time management logic still fully applies, and the game
mimics a real one played on real time. When the search finishes,
before returning best move, the total available nodes are updated,
subtracting the real searched nodes. After the first move, the time
information sent by the GUI is ignored, and the engine fully relies on
the updated total available nodes to feed time management.

To avoid time losses, the speed of the engine (npms) must be set to a
value lower than real speed so that if the real TC is for instance 30
secs, and npms is half of the real speed, the game will last on
average 15 secs, so much less than the TC limit, providing for a
safety 'time buffer'.

There are 2 main limitations with this mode.

1. Engine speed should be the same for both players, and this limits
the approach to mainly parameter tuning patches.

2. Because npms is fixed while, in real engines, the speed increases
toward endgame, this introduces an artifact that is equivalent to an
altered time management. Namely it is like the time management gives
less available time than what should be in standard case.

May be the second limitation could be mitigated in a future with a
smarter 'dynamic npms' approach.

Tests shows that the standard deviation of the results with 'nodestime'
is lower than in standard TC, as is expected because now all the introduced
noise due the random speed variability of the engines during the game is
fully removed.

Original NIT idea by Michael Hoffman that shows how to play in NIT mode
without requiring changes to the GUI. This implementation goes a bit
further, the key difference is that we read TC from GUI only once upfront
instead of re-reading after every move as in Michael's implementation.

No functional change.
2015-04-03 04:40:55 +02:00
Marco Costalba
df722521ba Rename of TimeMgr and friends
More natural naming IMO.

No functional change.
2015-04-03 04:19:29 +02:00
Marco Costalba
5d1b92e8f9 Introduce elapsed_time()
And reformat a bit time manager code.

Note that now we set starting search time in think() and
no more in ThreadPool::start_thinking(), the added delay
is less than 1 msec, so below timer resolution (5msec) and
should not affect time lossses ratio.

No functional change.
2015-04-03 04:19:26 +02:00
mstembera
6661a31541 Simplification to use only one counter move.
STC http://tests.stockfishchess.org/tests/view/5518dca30ebc5902160ec5d0
LLR: 2.95 (-2.94,2.94) [-3.50,0.50]
Total: 18868 W: 3638 L: 3530 D: 11700

LTC http://tests.stockfishchess.org/tests/view/5518f7ed0ebc5902160ec5d4
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 69767 W: 11019 L: 10973 D: 47775

Extracted from http://tests.stockfishchess.org/tests/view/5511028a0ebc5902160ec40b

Original patch by hxim.  All credit goes to him.

Bench: 7664249

Resolves #320
2015-04-03 01:16:15 +08:00
Marco Costalba
6c42575208 Assorted code style of latest commits
No functional chnage.
2015-03-29 10:16:10 +02:00
Joona Kiiski
61a6e46664 Fix indentations for hanging pawns code
No functional change
2015-03-29 08:54:25 +01:00
lucasart
60beb18efc Remove some difficult to understand C++11 constructs
Code like this is more a case of showing off one's C++ knowledge, rather than
using it adequately, IMHO.

**First loop (std::generate)**

Iterators are inadequate here, because they lose the key information which is
idx. As a result, we need to carry a redundant idx variable, and increment it
along the way. Very clumsy.
Usage of std::generate and a lambda function only obfuscate the code, which is
merely a simple and stupid loop over the elements of a vector.

**Second loop (std::accumulate)**

This code is thoroughlly incomprehensible. Restore the original, which was much
simpler to understand.

**Third loop (range based loop)**

Again, a range based loop is inadequate, because we lose idx! To resolve this
artificially created problem, the data model was made redundant (idx is a data
member of db[] elements!?), which is ugly and unjustified. A simple and stupid
for loop with idx does the job much better.

No functional change.

Resolves #313
2015-03-29 08:40:24 +01:00
Alain SAVARD
8463fa479e PSV3_1
Small speed-up in pawn.cpp
Results for 10 tests for each version:

Base      Test      Diff
Mean    1435636   1445238   -9602
StDev   22576     23189     1848

p-value: 1
speedup: 0.007

No functional change

Resolves #295
2015-03-29 07:30:46 +08:00
Ajith
63500274db Give a reduced bonus for threats by hanging pawns
Passed STC:
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 105539 W: 20389 L: 20001 D: 65149

and LTC:
LLR: 2.95 (-2.94,2.94) [0.00,6.00]
Total: 9629 W: 1577 L: 1432 D: 6620

Bench: 7658627

Resolves #317
2015-03-29 07:28:47 +08:00