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

3464 commits

Author SHA1 Message Date
lucasart
8e98bd616e Apply King Safety later in the endgame
Idea is to apply king safety later in the endgame. Previously, we didn't
apply KS in a RR vs. Q ending for example, which causes poor play.
Now we calculate king attacks when the attacking side has a queen or more.

STC with 8moves_v3
LLR: 3.06 (-2.94,2.94) [0.00,4.00]
Total: 38481 W: 6228 L: 5952 D: 26301

LTC with 2moves_v1
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 51053 W: 8670 L: 8353 D: 34030

Bench: 7514010

Resolves #98
2014-11-06 13:01:47 -05:00
mstembera
bc83515c9e Removing some superfluous extern declarations
No functional change.

Resolves #93
2014-11-05 21:17:19 +00:00
Marco Costalba
bcbab19376 Assume UCI 'nodes' is int64_t instead of int
UCI specification is not clear on the size of
integers that are exchanged in the protocol, so
instead of a simple int, assume 'nodes' is a
int64_t because we need a bigger size to store
this value in many real cases, especialy with
very long searches.

No functional change.

Resolves #75
2014-11-05 21:11:05 +00:00
Marco Costalba
d29a68f585 Rearrange check_time()
Remove an ugly workaround for a gcc
warning while there.

No functional change.
2014-11-05 21:09:21 +00:00
Ajith
0608d6aaec Add bonuses for each threat instead of max threat value.
Use SPSA tuned values for all threat bonuses

STC
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 6074 W: 1284 L: 1160 D: 3630

LTC
LLR: 2.97 (-2.94,2.94) [0.00,6.00]
Total: 13563 W: 2402 L: 2232 D: 8929

Bench: 6981908

Resolves #94
2014-11-04 23:50:54 +08:00
mstembera
2fd075d1ea Optimize TranspositionTable::store() and TranspositionTable::probe() for speed.
No functional change.

Resolves #85
2014-11-03 18:40:49 +00:00
lucasart
d12378497c Do not assume that enum are signed
Clang 3.5 issues warning on constructs like: abs(f1 - f2). The thing is that
f1 and f2 are enum types, and the range given (all positive) allows the
compiler to choose an unsigned type (efficiency being one reason to prefer
unsigned arithmetic). If f1 < f2 are unsigned, then f1 - f2 wraps around zero
and the abs() becomes a no-op. It's the reinterpretation of the unsigned
result (large value) as a signed int that happens to give the correct result,
thanks to 2's complement. This is all tricky and dangerous!

In the spirit of the standard, we assume nothing on the signedness of enums,
and simply calculate the rank and file distances as:
- rank_dist(r1, r2) = r1 < r2 ? r2 - r1 : r1 - r2
- file_dist(f1, f2) = f1 < f2 ? f2 - f1 : f1 - f2
this logic can in fact be applied to any enum we may use, so for better
generality and to avoid code duplication, we use a template function diff()
here.

No functional change.

Resolves #95
2014-11-04 00:35:02 +08:00
lucasart
8ab9c2511a Cleanup MAX_PLY
This area has become obscure and tricky over the course of incremental
changes that did not respect the original's consistency and clarity. Now,
it's not clear why we use MAX_PLY = 120, or why we use MAX_PLY+6, among
other things.

This patch does the following:

* ID loop: depth ranges from 1 to MAX_PLY-1, and due to TT constraint (depth
must fit into an int8_t), MAX_PLY should be 128.

* stack[]: plies now range from 0 to MAX_PLY-1, hence stack[MAX_PLY+4],
because of the extra 2+2 padding elements (for ss-2 and ss+2). Document this
better, while we're at it.

* Enforce 0 <= ply < MAX_PLY:
  - stop condition is now ss->ply >= MAX_PLY and not ss->ply > MAX_PLY.
  - assert(ss->ply < MAX_PLY), before using ss+1 and ss+2.
  - as a result, we don't need the artificial MAX_PLY+6 range. Instead we
  can use MAX_PLY+4 and it's clear why (for ss-2 and ss+2).

* fix: extract_pv_from_tt() and insert_pv_in_tt() had no reason to use
MAX_PLY_PLUS_6, because the array is indexed by plies, so the range of
available plies applies (0..MAX_PLY before, and now 0..MAX_PLY-1).

Tested with debug compile, using MAX_PLY=16, and running bench at depth 17,
using 1 and 7 threads. No assert() fired. Feel free to submit to more severe
crash-tests, if you can think of any.

No functional change.
2014-11-03 23:36:24 +08:00
Marco Costalba
fc0733087a Restore std::dec after std::hex
Code is leaking a std::hex, and causes subsequent
sync_cout output to be in hexadecimal.

Spotted by Lucas

No functional change.
2014-11-02 08:03:52 +01:00
Marco Costalba
42a20920e5 Retire ScalePawnSpan[]
Obscure, undocmented and misnamed array. Replace with
the direct formula: it is much more clear what the
code does.

No functional change.

Resolves #90
2014-11-01 22:10:25 +00:00
Marco Costalba
79fa72f392 Merge pull request #89 from official-stockfish/pull_no_pretty
Prefer operator<<() to pretty()

No functional change.
2014-11-01 22:24:33 +01:00
Marco Costalba
d3091971b7 Retire PawnsFileSpan
It is useless. Tested as no regression:

STC
LLR: 4.06 (-2.94,2.94) [-3.00,1.00]
Total: 140718 W: 28527 L: 28568 D: 83623

LTC
LLR: 2.94 (-2.94,2.94) [-3.00,1.00]
Total: 60034 W: 10359 L: 10303 D: 39372

bench: 6564212

Resolves #88
2014-11-01 20:50:52 +00:00
lucasart
d9caede324 Correctly describe POPCNT compile
SSE4.2 has nothing to do with POPCNT. We must dispell this myth, because
Stockfish is a reference and many will copy this mistake if they see it in Stockfish:
* SSE is an SIMD instruction set, relative to vectorization (using special 128-bit registers).
* POPCNT/LZCNT work on normal registers (eg. AL, AX, EAX, RAX).

The confusion comes from the fact that, in the Intel product line, it just
so happens that SSE4.2 and POPCNT/LZCNT came out at the same time. But this
is not true for AMD. For example, all AMD Pheniom II have SSE3 but no
POPCNT/LZCNT, and that is why the modern compile uses  -msse3 -popcnt and not -msse4.2.

No functional change.

Resolves #86
2014-11-01 20:43:57 +00:00
lucasart
8a7876d48d Consistent use of anonymous namespace
Objects that are only accessible at file-scope should be put in the anonymous namespace.
This is what the  C++ standard recommends, rather than using static, which is really C-style and results in static linkage.

Stockfish already does this throughout the code. So let's weed out the few exceptions,
because... they have no reason to be exceptional.

No functional change.

Resolves #84
2014-11-01 20:35:10 +00:00
lucasart
2ee1250294 Remove dead code
No functional change.

Closes #87
2014-11-01 20:16:29 +00:00
Marco Costalba
5644e14d0e Prefer operator<<() to pretty()
It is more idiomatic, we didn't used it
in the past because Position::pretty(Move)
had a calling argument, but now we can.

As an added benefit, we avoid a lot of string
copies in the process because now we avoid
std::ostringstream ss.

No functional change.
2014-11-01 19:02:35 +01:00
Marco Costalba
d07a875398 Merge pull request #82 from official-stockfish/clean_up_bishop_code
Code style clean-up

No functional change.
2014-11-01 18:05:03 +01:00
Marco Costalba
460892382a Code style clean-up
This piece of code needs some love.

No functional change.
2014-10-30 12:32:43 +01:00
mstembera
5605cc7684 max_piece_type cleanup, and slight speed increase.
No functional change.

Resolves #81
2014-10-28 22:23:01 +08:00
Joona Kiiski
7d42752158 A small clean up of previous patch suggested by Marco
No functional change
2014-10-27 20:26:12 +00:00
Joona Kiiski
fefb27bab4 Speed up max_piece_type()
Write code in the way that allows compiler to perform loop unrolling.

My measurement (32 cycles each):

Orig:

Time (Mean: 2466.59375, Trimmed mean: 2464.25, Std: 12.6869487803348)
Nodes (Mean: 4294458, Trimmed mean: 4294458, Std: 0)
Speed (Mean: 1741.09247987678, Trimmed mean: 1742.72879715475, Std: 8.93612608292678)

Time (Mean: 2470.15625, Trimmed mean: 2468.75, Std: 12.7484581610433)
Nodes (Mean: 4294458, Trimmed mean: 4294458, Std: 0)
Speed (Mean: 1738.58176151341, Trimmed mean: 1739.54618465403, Std: 8.95585822316946)

Mod:

Time (Mean: 2449.90625, Trimmed mean: 2445.9375, Std: 12.1000116635508)
Nodes (Mean: 4294458, Trimmed mean: 4294458, Std: 0)
Speed (Mean: 1752.94829372932, Trimmed mean: 1755.75934908231, Std: 8.61478453124504)

Time (Mean: 2442.78125, Trimmed mean: 2441.1875, Std: 8.17839157228837)
Nodes (Mean: 4294458, Trimmed mean: 4294458, Std: 0)
Speed (Mean: 1758.03872783803, Trimmed mean: 1759.16825356261, Std: 5.81131316346191)

No functional change
2014-10-27 20:25:57 +00:00
snicolet
7de40076ac Tune PawnsFileSpan
Passed the following SPRT tests:

STC:
LLR: 2.96 (-2.94,2.94) [-1.50,4.50]
Total: 24428 W: 5056 L: 4880 D: 14492

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 26590 W: 4715 L: 4472 D: 17403

Bench: 6615949

Resolves #78
2014-10-27 11:48:44 +00:00
Pascal Romaret
f1359845de Improve compatibility with Shredder Classic GUI
This commit fixes two issues:

1) Don't print PVs after the search has been interrupted

    This solves the "mate 0 upperbound" scores that sometimes
    creep up when a multi-PV analysis gets interrupted with
    the `stop` command.

2) Print multipv before score

    Shredder Classic fails to identify the main PV
    (the one with multipv 1) if `score` comes first.
    This leads to an eval graph that doesn't reflect
    the scores actually reported by Stockfish when
    doing a multiPV analysis.

No functional change

Closes #76
2014-10-27 11:07:35 +00:00
Marco Costalba
5ab55827b8 Fix an obscure gcc warning
warning: narrowing conversion from ‘int’ to ‘char’ inside { }
is ill-formed in C++11 [-Wnarrowing]

When pedantic meets esoteric!

No functional change.
2014-10-26 19:40:20 +00:00
Marco Costalba
9ba391c5cb Retire notation.cpp
Now we can finally retire notation.cpp
and move UCI helpers under uci.cpp

No functional change.
2014-10-26 19:40:13 +00:00
Marco Costalba
2469daebb1 Final UCI helpers renaming
To reflect new changes, specifically that
now are all under UCI namespace.

No functional change.
2014-10-26 19:40:04 +00:00
Marco Costalba
aa60c80ade Retire notation.h
And move the few remaining content
under UCI namespace where they belong.

No functional change.
2014-10-26 19:39:56 +00:00
Marco Costalba
5cbcff55cc Rename ucioption.h to uci.h
We are going to add all UCI related
functions here, so first rename it
to a more proper name.

No functional change.
2014-10-26 19:39:46 +00:00
Marco Costalba
428962a2e8 Retire to_char() helpers
Remove some useless wrappers and make
the conversion explicit and starightforward.

No functional change.
2014-10-26 19:39:37 +00:00
Marco Costalba
4f6b1bf3be Reformat max_threat()
Helper function should just know how to find the
biggest piece type in a bitboard. All the threat
logic and data shoud be in evaluate_threats().

This nicely separates the scope of the two functions
in a more consistent way and simplifies the code.

No functional change.
2014-10-26 09:12:56 +00:00
snicolet
8d62ece945 Calculate maximum threat for hanging pieces
Use the max_threat() helper function to estimate more precisely the
best hanging piece threat.  Also retunes the Threat array using SPSA.

STC
LLR: 2.95 (-2.94,2.94) [-1.50,4.50]
Total: 7598 W: 1596 L: 1468 D: 4534

LTC
LLR: 2.97 (-2.94,2.94) [0.00,6.00]
Total: 7896 W: 1495 L: 1350 D: 5051

Bench: 6816504

Resolves #73
2014-10-24 01:10:11 +08:00
Marco Costalba
480682b670 Document why initing eval tables
Instead of hard-code the weights in a big table,
we prefer to calculate them out of few parameters
at startup. This allows to keep low the number of
independent parameters and hence is good for tuning
and for a better insight in the meaning of the numbers.

No functional change.
2014-10-15 19:36:22 +01:00
Marco Costalba
89d9db2979 Rename Tracing methods
Easier to understand and more in line with
standard Trace classes naming like:

http://msdn.microsoft.com/en-us/library/system.diagnostics.trace.aspx

No functional change.
2014-10-12 20:35:19 +01:00
Marco Costalba
907f912463 Account for Tempo in do_evaluate()
This is more correct because we let evaluate()
to be a pure dispatcher and also now evaluate
and tracing outputs are consistent.

No functional change.
2014-10-12 20:35:07 +01:00
Marco Costalba
c97b702f4d Fix some warnings with Intel C++ compiler
No functional change.
2014-10-12 20:34:54 +01:00
lucasart
91de6b0f37 Further streamline connected pawn evaluation
Make even more clear what are the terms that
contribute to evaluate connected pawns, and
completely separate them from the weights
that are now fully looked up in a table.

For future tuning makes sense to init the table with
a formula instead of hard-code it. This allows to
reduce problem space cardinality and makes tuning
easier.

And fix a MSVC warning while there:
warning C4804: '>>' : unsafe use of type 'bool' in operation

No functional change.
2014-10-12 20:03:49 +01:00
lucasart
069073ea68 Merge Connected and Candidate
These two notions are very correlated. Since connected has the most
generality, it makes sense to generalize it to encompass what is
covered by candidate.

STC:
LLR: 4.03 (-2.94,2.94) [-3.00,1.00]
Total: 11970 W: 2577 L: 2379 D: 7014

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 13194 W: 2389 L: 2255 D: 8550

bench 7328585
2014-10-07 07:42:17 +01:00
joergoster
15e2191111 Remove the now redundant TT prefetch call from Position::do_move.
Tested for no regression and passed both
STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 48250 W: 9757 L: 9686 D: 28807

LTC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 51412 W: 8887 L: 8816 D: 33709

No functional change.

Resolves #66
2014-10-06 23:59:56 +08:00
Luca Brivio
8a9b9ec96a Simplify futility move count array formula
No functional change
2014-10-05 12:49:18 +01:00
Marco Costalba
74829342ef Reformat and rename hash_after_move()
Align to standard coding style and properly use
enum types. Rename while there.

No functional change.
2014-10-04 10:36:29 +01:00
Ajith
4b926f227d Extend King Threats to all pieces (other than pawns).
STC
LLR: 2.99 (-2.94,2.94) [-1.50,4.50]
Total: 20559 W: 4261 L: 4095 D: 12203

LTC
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 75232 W: 13097 L: 12696 D: 49439

Bench: 7543790

Resolves #63
2014-10-04 03:54:12 +08:00
joergoster
82d065b011 Speculative prefetch
Idea by Peter Oesterlund.
Implemented and tested by Joerg Oester

STC 3 threads
ELO: 3.19 +-2.1 (95%) LOS: 99.9%
Total: 40000 W: 7576 L: 7209 D: 25215

LTC
LLR: 2.96 (-2.94,2.94) [0.00,6.00]
Total: 22026 W: 3829 L: 3619 D: 14578

STC
LLR: 2.95 (-2.94,2.94) [-1.50,4.50]
Total: 7291 W: 1531 L: 1404 D: 4356

No functional change

Resolves #61
2014-10-02 22:19:14 +01:00
lucasart
e60cdca9b0 Convert TT depth to int8_t
Now that half plies have been removed from the engine, we can encode
TT depth into an int8_t.

Range is -128 to +127, so it goes still further than the previous
limit of 121 plies (with ONE_PLY == 2 where depth - DEPTH_NONE was
encoded as an uint8_t).

No functional change.

Resolved #60
2014-10-01 20:51:32 +01:00
Marco Costalba
a1b62d68ec Trivial code style fixes
Mainly to sync mine and official repo.

No functional change.
2014-09-30 09:05:20 +02:00
Marco Costalba
222f59b9c1 Move ONE_PLY to be 1 instead of 2: search()
Now that half-plies are no more used we can simplify
the code assuming that ONE_PLY is 1 and no more 2.

Verified with a SMP test:
LLR: 2.95 (-2.94,2.94) [-4.50,0.00]
Total: 8926 W: 1712 L: 1607 D: 5607

No functional change.
2014-09-29 15:17:12 +02:00
lucasart
27a1877299 Clean up VALUE_KNOWN_WIN conditions
A patch (+ some extra changes) passed with:

STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 14575 W: 3101 L: 2967 D: 8507

LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 42579 W: 7580 L: 7496 D: 27503

Bench: 6545733

Resolves #52
2014-09-28 17:45:49 +01:00
Uri Blass
ea9c424bba Remove use of half-ply reductions from LMR, Null-move, IID and
Singular extensions.

STC:
ELO: 3.80 +-3.1 (95%) LOS: 99.2%
Total: 19727 W: 4190 L: 3974 D: 11563

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 7647 W: 1356 L: 1214 D: 5077

Bench: 6545733

Resolves #55
2014-09-28 04:33:28 +08:00
Joona Kiiski
7ed15af371 Cap evaluation based null move extra reduction to three plies
It's a zero elo patch, and a reasonable safeguard against uncontrolled extreme reductions.

STC:
ELO: -0.08 +-2.0 (95%) LOS: 46.9%
Total: 40000 W: 6728 L: 6737 D: 26535

LTC:
ELO: -0.14 +-1.8 (95%) LOS: 44.0%
Total: 40000 W: 5557 L: 5573 D: 28870

Bench: 7201830
2014-09-25 20:42:25 +01:00
Uri Blass
d6613b7589 Change history reduction in LMR to be a full ply.
STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 9829 W: 2142 L: 1998 D: 5689

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 27162 W: 4802 L: 4692 D: 17668

Bench: 7284120

Resolves #53
2014-09-26 02:22:39 +08:00
uriblass
fed3e752ae Evaluate king safety when no queen is present.
LLR: 2.97 (-2.94,2.94) [-1.50,4.50]
Total: 16657 W: 3547 L: 3391 D: 9719

LLR: 2.95 (-2.94,2.94) [0.00,6.00]
Total: 31258 W: 5664 L: 5403 D: 20191

Bench: 8331165

Resolves #51
2014-09-22 01:32:47 +08:00