1
0
Fork 0
Commit Graph

274 Commits (riscv64-cartesi)

Author SHA1 Message Date
Joost VandeVondele 0cfb653eec Simplify Singular Extension condition
Avoid defining a singly used variable, removes one condition.

passed STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 53489 W: 10814 L: 10752 D: 31923
http://tests.stockfishchess.org/tests/view/5ac08a8d0ebc590e9457cd94

Closes https://github.com/official-stockfish/Stockfish/pull/1530

No functional change.
2018-04-03 00:13:38 +02:00
Stéphane Nicolet 5ce630584c Tweak queen values for midgame and endgame
Queen midgame value: -1%
Queen endgame value: +1%

This patch failed STC, but was exceptionally tested at LTC,
where it passed two independant SPRT tests with bounds [0..4]:

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 20651 W: 3191 L: 2980 D: 14480
http://tests.stockfishchess.org/tests/view/5ab73faa0ebc5902932cbdca

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 89111 W: 13647 L: 13233 D: 62231
http://tests.stockfishchess.org/tests/view/5ab8c0e50ebc5902932cbeae

See https://github.com/official-stockfish/Stockfish/pull/1511
for the discussion of this patch.

How to continue from there?
• there is probably some more Elo gains to get from the tuning
of the queen value.

Bench: 5460229
2018-03-27 17:51:11 +02:00
Ronald de Man 759b3c79cf Mark all compile-time constants as constexpr.
To more clearly distinguish them from "const" local variables, this patch
defines compile-time local constants as constexpr. This is consistent with
the definition of PvNode as constexpr in search() and qsearch(). It also
makes the code more robust, since the compiler will now check that those
constants are indeed compile-time constants.

We can go even one step further and define all the evaluation and search
compile-time constants as constexpr.

In generate_castling() I replaced "K" with "step", since K was incorrectly
capitalised (in the Chess960 case).

In timeman.cpp I had to make the non-local constants MaxRatio and StealRatio
constepxr, since otherwise gcc would complain when calculating TMaxRatio and
TStealRatio. (Strangely, I did not have to make Is64Bit constexpr even though
it is used in ucioption.cpp in the calculation of constexpr MaxHashMB.)

I have renamed PieceCount to pieceCount in material.h, since the values of
the array are not compile-time constants.

Some compile-time constants in tbprobe.cpp were overlooked. Sides and MaxFile
are not compile-time constants, so were renamed to sides and maxFile.

Non-functional change.
2018-03-18 23:48:16 +01:00
Alain SAVARD 1093047e7d Two steps slider threats on queen
Allow a potential slider threat from a square currently occupied
by a harmless attacker, just as the recent "knight on queen" patch.
Also from not completely safe squares, use the mobilityArea instead
of excluding all pawns for both SlidersOnQueen and KnightOnQueen

We now compute the potential sliders threat on queen only if opponent
has one queen.

Run as SPRT [0,4] since it is some kind of simplification but maybe
not clearly one.

STC:
http://tests.stockfishchess.org/tests/view/5aa1ddf10ebc590297cb63d8
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 22997 W: 4817 L: 4570 D: 13610

LTC:
http://tests.stockfishchess.org/tests/view/5aa1fe6b0ebc590297cb63e5
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 11926 W: 1891 L: 1705 D: 8330

After this patch is committed, we may try to:

• re-introduce some "threat by queen" bonus to make Stockfish's queen
  more aggressive (attacking aspect)

• introduce a concept of "queen overload" to force the opponent queen
  into passivity and protecting duties (defensive aspect)

• more generally, re-tune the queen mobility array since patches in the
  last three months have affected a lot the location/activity of queens.

Closes https://github.com/official-stockfish/Stockfish/pull/1473

bench: 5788691
2018-03-09 21:47:44 +01:00
Joost VandeVondele 9afa1d7330 New Year 2018
Adjust copyright headers.

No functional change.
2018-01-01 13:18:10 +01:00
Stéphane Nicolet 54f6ce70fd Avoid warnings by the Clang compiler
Clang gave a couple of warnings for unused parameters after the recnet commit "Use constexpr when makes sense".

No functional change.
2017-12-04 17:53:42 +01:00
syzygy1 822695d4d3 Use a Direction enum for Square deltas
Currently the NORTH/WEST/SOUTH/EAST values are of type Square, but conceptually they are not squares but directions. This patch separates these values into a Direction enum and overloads addition and subtraction to allow adding a Square to a Direction (to get a new Square).

I have also slightly trimmed the possible overloadings to improve type safety. For example, it would normally not make sense to add a Color to a Color or a Piece to a Piece, or to multiply or divide them by an integer. It would also normally not make sense to add a Square to a Square.

This is a non-functional change.
2017-12-04 17:52:31 +01:00
Guy Vreuls 28b6a457c2 Use constexpr when makes sense
No functional change.
2017-12-03 12:44:24 +01:00
Stefan Geschwentner a87a1005ad Attack threats
Give bonus for safe attack threats from bishops and rooks on opponent queen

STC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 8629 W: 1599 L: 1438 D: 5592
http://tests.stockfishchess.org/tests/view/5a1ad4490ebc590ccbb8b30d

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 7093 W: 987 L: 846 D: 5260
http://tests.stockfishchess.org/tests/view/5a1aec5d0ebc590ccbb8b317

Bench: 5051254
2017-12-03 10:41:48 +01:00
Marco Costalba 7aa7dfd4df Fix some Clang warnings
Found by Clang in extra verbose mode :-)

No functional change.
2017-08-19 14:32:31 +02:00
Rocky640 b24bd762b2 Rework the "unsupported" penalty into a "supported" bonus
A pawn (according to all the searched positions of a bench run) is not supported 85% of the time,
(in current master it is either isolated, backward or "unsupported").

So it made sense to try moving the S(17, 8) "unsupported" penalty value into the base pawn value hoping for a more representative pawn value, and accordingly
a) adjust backward and isolated so that they stay more or less the same as master
b) increase the mg connected bonus in the supported case by S(17, 0) and let the Connected formula find a suitable eg value according to rank.

Tested as a simplification SPRT(-3, 1)

Passed STC
http://tests.stockfishchess.org/tests/view/5970dbd30ebc5916ff649dd6
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 19613 W: 3663 L: 3540 D: 12410

Passed LTC
http://tests.stockfishchess.org/tests/view/597137780ebc5916ff649de3
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 24721 W: 3306 L: 3191 D: 18224

Bench: 5581946

Closes #1179
2017-08-01 18:37:54 -07:00
Marco Costalba ecd3218b6b History code rewrite (#1122)
Rearrange and rename all history heuristic code. Naming
is now based on chessprogramming.wikispaces.com conventions
and the relations among the various heuristics are now more
clear and consistent.

No functional change.
2017-05-26 08:42:50 +02:00
FauziAkram 6b4959e3e0 Linear Protector bonus by distance
Replacing the old Protector table with a simple linear formula which takes into account a different slope for each different piece type.

The idea of this simplification of Protector is originated by Alain (Rocky)

STC: LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 70382 W: 12859 L: 12823 D: 44700

LTC: LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 61554 W: 8098 L: 8031 D: 45425

Bench: 6107863

Closes #1099
2017-05-07 21:11:51 -07:00
Marco Costalba 25296547d0 Move Pieces[] out of global visibility
It is an helper array used only in position.cpp

Also small code tidy up while there.

No functional change.

Closes #1106
2017-05-07 20:20:02 -07:00
FauziAkram c243cd5f4a Variable tuning
A tuning patch which cover the following changes:

increase the importance of queen and rook mobility in endgame and
decrease it in mg, since if we use the heavy pieces too early in the game
we will just make opponent develop their pieces by threatening ours.

King Psqt:
1)King will be encouraged more to stay in the first ranks in the MG
2)and will be encouraged more to go to the middle of the board/last ranks in the EG

Bishop scale better in EG
Logical changes on various psqt tables
1/6 of the changes of the last tuning session on mobility tables

STC: LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 227879 W: 41240 L: 40313 D: 146326
LTC : LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 167047 W: 21871 L: 21291 D: 123885

Bench: 5695960

Closes #1008
2017-02-19 14:00:44 -08:00
Stéphane Nicolet d2971f3fca Check for overflow in Score * int multiplication (#969)
Add asserts to check for overflow in Score * int multiplication.

There is no overflow in current master, but it would be easy to
create one as the scale of the current eval does not leave many
spare bits. For instance, adding the following unused variables
in master at the end of evaluate() (line 882 of evaluate.cpp)
overflows:

Score s1 = score * 4;  // no overflow
Score s2 = score * 5;  // overflow

Assertion failed: (eg_value(result) == (i * eg_value(s))),
function operator*, file ./types.h, line 336.

Same md5 checksum as current master for non debug compiles.

No functional change.
2017-01-11 18:11:17 +01:00
Joost VandeVondele d8f683760c Adjust copyright headers to 2017 (#965)
No functional change.
2017-01-11 08:46:29 +01:00
Joost VandeVondele 8ceb1ff53b Fix undefined behavior
This fixes #892. Undefined behavior as seen with
clang -fsanitize=undefined.

No functional change.
2016-11-26 16:49:59 +01:00
Joost Vandevondele 40b1b27178 Fix a series of undefined behaviours
Avoid shifting negative signed integers and use typed
enum to avoids decrementing a variable beyond its defined
range, like:
       for (Rank r = RANK_8; r >= RANK_1; --r)

Changes were tested individually and passed SPRT[-3, 1].

With this patch gcc --sanitize builds cleanly.

No functional change.
2016-10-27 06:44:41 +02:00
Stéphane Nicolet 7ae3c05795 Rename shift_bb() to shift()
Rename shift_bb() to shift(), and DELTA_S to SOUTH, etc.
to improve code readability, especially in evaluate.cpp
when they are used together:

    old b = shift_bb<DELTA_S>(pos.pieces(PAWN))
    new b = shift<SOUTH>(pos.pieces(PAWN))

While there fix some small code style issues.

No functional change.
2016-09-25 10:45:10 +02:00
Stéphane Nicolet ea41f18e6e Swap mg and eg in internal representation of Score
Instrumentation shows that in make_score(mg, eg) calls, the mg value is
zero in 25,9% of the calls while the eg value is zero in 36,8% of the
calls.

Swapping the internal fields of mg and eg in the internal
representation of Score allows the compiler to optimize away the shift
in (eg << 16) + mg in more cases, thus resulting in a 0.3% speed-up
overall.

No functional change
2016-09-17 09:56:36 +02:00
Marco Costalba 057d710fc2 Fix indentation in struct FromToStats
And other little trivial stuff.

No functional change.
2016-09-17 09:51:20 +02:00
Marco Costalba e340ce221c Syntactic sugar to loop across pieces
Also add some comments to the new operator~(Piece).

No functional change.
2016-09-04 15:33:17 +02:00
syzygy ca6c9f85a5 Change from [Color][PieceType] to [Piece]
Speed up of almost 1% in both normal and
pgo builds.

No functional change.
2016-09-04 09:22:09 +02:00
Stefano80 7f2eb10e93 Retire linear imbalance
Retire linear imbalance and compensate
in piece values enumeration.

STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 43596 W: 8105 L: 8023 D: 27468

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 24482 W: 3352 L: 3237 D: 17893

Bench: 7777707
2016-09-02 08:25:17 +02:00
Marco Costalba 4c5cbb1b14 Make engine ONE_PLY value independent
This non-functional change patch is a deep work to allow SF to be independent
from the actual value of ONE_PLY (currently set to 1). I have verified SF is
now independent for ONE_PLY values 1, 2, 4, 8, 16, 32 and 256.

This patch gives consistency to search code and enables future work, opening
the door to safely tweaking the ONE_PLY value for any reason.

Verified for no speed regression at STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 95643 W: 17728 L: 17737 D: 60178

No functional change.
2016-08-27 09:12:25 +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
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
Marco Costalba db4b0d8b7d Rewrite bsfq management
Use compiler intrinsics when possible to
avoid writing platform specific asm code.

Tested on Windows 7 with MSVC 2013 and mingw 4.8.3 (32 and 64 bit)
and on Linux Mint with g++ 4.8.4 and clang 3.4 (32 and 64 bit).

No functional change

Resolves #609
2016-03-28 15:46:55 +01:00
mbootsector 8788612828 Raise endgame passed pawn and material values
STC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 136149 W: 25213 L: 24588 D: 86348

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 54637 W: 7533 L: 7238 D: 39866

Bench: 8546808

Resolves #608
2016-03-27 20:22:48 +01:00
Marco Costalba 647402ff79 Assorted cleanup of latest commits
No functional change.

Resolves #601
2016-03-14 20:42:44 -07:00
ppigazzini d4af15f682 Update AUTHORS and copyright notice
No functional change

Resolves #555
2016-01-02 09:43:51 +00:00
Marco Costalba 9742fb10fd Update Copyright year
No functional change.

Resolves #554
2016-01-01 10:17:36 +00: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
lucasart 2e0ec4ad6f Fix merge error for Tuned PSQT
Fall-out from 411e704f

Bench: 7907776

Resolves #352
2015-05-21 19:56:01 +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
Marco Costalba a590d1d52d Re-enable spinlocks
For branch C++11, that doe snot run on fishtest,
there is no need of this kludge, let only master
have it.

No functional change.
2015-03-07 08:38:26 +01:00
Marco Costalba 6645115377 Allow to disable spinlocks
And use mutex instead. You may never want to do this.
It is a workaround to run c++11 on fishtest where many
machiens have HTenabled and this can be a problem when
number of cores set is higher than number of physical cores.

To disable spinlocks, just compile with -DNO_SPINLOCK flag

No functional change.
2015-03-01 17:16:05 +01:00
Marco Costalba 3184852bdc Small tweaks in do_move and friends
Also remove useless StateCopySize64 optimization:
compiler uses SSE movups instruction anyhow and
does not need this trick (verified with fishbench).

No functional change.
2015-02-08 13:09:29 +01:00
Marco Costalba 6390a3da94 Document how to enable PEXT with MSVC
When not using Makefile, e.g. with MSVC, if hardware
supports BMI2 instructions, then USE_PEXT should be
added in project configuration to enable pext support.

No functional change.
2015-01-21 19:54:15 +01:00
Marco Costalba f54c44e6be 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.
2015-01-20 22:17:22 +01:00
Marco Costalba f53aea45e3 Add syzygy support
bench: 8080602
2015-01-18 08:27:46 +01:00
Marco Costalba 3c07603dac Import C++11 branch
Import C++11 branch from:

https://github.com/mcostalba/Stockfish/tree/c++11

The version imported is teh last one as of today:
6670e93e50

Branch is fully equivalent with master but syzygy
tablebases that are missing (but will be added with
next commit).

bench: 8080602
2015-01-18 08:00:50 +01:00
mstembera 58fdb84b0d 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
2015-01-16 19:03:49 +00:00
Marco Costalba 4eb2d8ce09 Assorted headers cleanup
Mostly comments fixing and other small things.

No functional change.
2015-01-11 22:56:35 +01:00
Marco Costalba 42b48b08e8 Update copyright year
No functional change.
2015-01-10 11:46:28 +01:00
lucasart 2c52147dbf 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
2014-11-26 07:55:57 +08:00
Ronald de Man 7caa6cd338 Syzygy tablebases
Adds support for Syzygy tablebases to Stockfish.  See
the Readme for information on using the tablebases.

Tablebase support can be enabled/disabled at the Makefile
level as well, by setting syzygy=yes or syzygy=no.

Big/little endian are both supported.

No functional change (if Tablebases are not used).

Resolves #6
2014-11-26 07:49:58 +08:00
Marco Costalba 4840643fed Use DEPTH_MAX instead of MAX_PLY
When comparing to a Depth it is more
consistent to use DEPTH_MAX instead
of a int.

This is a subtle difference because we use
ply and depth almost interchangably in SF,
but they are different. FOr counting plies
makes ense to continue using ints, while
for Depth we have our specific enum.

This cleanly fixes a new Clang 3.5 warning:

No functional change.
2014-11-15 05:36:49 +01:00
Marco Costalba 57fdfdedcf Assorted code-style triviality
No functional change.
2014-11-09 20:17:29 +01: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
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 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 880e3cd7c8 Move to_char() and to_string() to notation
Where they better belong.

Also, this removes '#include <string>' from types.h, which reduces the amount of code to compile (every
translation unit includes types.h).

No functional change.
2014-08-09 13:25:05 +08:00
Ron Britvich ccd823a4ff Pack 3 TT entries in 32 bytes cluster
Idea from Ron Britvich

Code reworked by Marco Costalba and Joona Kiiski

Bench: 8095369

Resolves #3
Resolves #10
2014-06-28 14:06:32 -04:00
Marco Costalba 69ac45d903 Revert "Score extractors"
Are broken for big-endian case and
I have verified with MSVC 2013 Premium
bench is correct and there is no
miscompilation, so the main reason
to change the original code drops.

No functional change.
2014-06-05 23:55:18 +02:00
Marco Costalba 323a006666 Fix a warning with MSVC Premium 2013
Reported by Ron Britvich.

No functional change.
2014-06-05 23:46:58 +02:00
Marco Costalba f4dcec0b94 Retire Polyglot Book management
Book handling belongs to GUI, we kept this code
for historical reasons, but nowdays there is
really no need of this old, (mostly) unused
and especially incorrect designed functionality.

It is up to the GUI to choose the book (far easier for
the user) and to select the book parameters. In no
place, including fishtest, TCEC, rating lists, etc.
the "own book" is used, moreover currently SF is
released without any book and even if in the future we
bundle a book in the release package, it will be the GUI
that will take care of it.

This corrects a wrong design decision that Galurung
and later Stockfish inherited from what was common
practice many yeas ago.

No functional change.
2014-06-01 15:29:34 +02:00
Marco Costalba 495a0fa699 Fix a warning with Intel compiler
warning #2259: non-pointer conversion from
"int" to "int16_t={short}" may lose significant
bits.

No functional change.
2014-05-25 00:21:46 +02:00
Ron Britvich 8f6a494ad7 Rewrite Score extractors
Less tricky and even a bit faster. With this
version Visual Studio Ultimate 2013 Update 2 RC
runs fine even in O2 optimization.

No functional change.
2014-05-05 09:05:29 +02:00
Marco Costalba 43973f43c6 Use only standard conforming eg_value()
Remove the optimization for Intel, is not
standard and can break at any time, moreover
our release build is not done with Intel C++
anymore so we don't need to sqeeze the extra
speed out from this compiler.

No functional change.
2014-05-01 23:08:07 +02:00
Marco Costalba c9e396b542 We can add an integer to a Value
We have defined corresponding operators,
so rely on them to streamline the code
and increase readibility.

No functional change.
2014-04-27 11:25:42 +02:00
Marco Costalba 057c3d60cd Move game phase constants to enum Value
No functional change.
2014-04-27 09:23:45 +02:00
Jean-Francois Romang 226bbc1e63 Add ARCH x86-64-bmi2 support
Intel Haswell and newer CPUs can calculate sliders
attacks using special PEXT asm instructions instead
of magic bitboards. This gives a +3% speed up.

To enable it just compile with ARCH=x86-64-bmi2

No functional change.
2014-04-12 09:15:14 +02: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 64d29a6330 Sync some common names
No functional change.
2014-04-06 11:26:12 +02:00
Marco Costalba 9350d0dce5 Raise VALUE_INFINITE
In some legal positions like this one:
R6R/3Q4/1Q4Q1/4Q3/2Q4Q/Q4Q2/Np1Q4/kB1N1KB1  b -- 0 1

We can have a very high score, in this case 30177 and 29267
for midgame and endgame respectively, and because
VALUE_INFINITE = 30001 we have an assert in interpolate()

Midgame and endgame scores are stored in 16 bit signed integers
so we can rise VALUE_INFINITE a little bit. This does not fix
the possibility of overflow in general case, just makes the
condition more difficult to trigger and anyhow better uses all
the score width.

Raising VALUE_INFINITE to 32000 seems to fix the problem for this
particular case.

No functional change.
2014-03-29 11:13:42 +01:00
Marco Costalba f12449d492 Rename score to value in ExtMove
We use 'score' for the value mid-endgame pair.

No functional change.
2014-03-23 08:54:10 +01:00
Marco Costalba 5f12069cbf Retire operator|(File f, Rank r)
Use make_square() instead. Less fancy but
more clear.

No functional change.
2014-03-22 23:54:18 +01:00
Marco Costalba 1d1b7df7c6 Rename castling flag to castling right
This is a more conventional naming as
reported also in:

http://chessprogramming.wikispaces.com/Castling+rights

No functional change.
2014-03-08 15:08:55 +01:00
Marco Costalba 708cb311a0 Pass CastlingFlag argument only
Instead of Color and CastlingSide. Change functions API
accordingly.

No functional change.
2014-03-02 13:21:19 +01:00
Marco Costalba 3d8c0f16c2 Rename xxx_to_char() -> to_char()
No functional change.
2014-03-01 22:07:41 +01:00
Marco Costalba 52ebf87238 Increase MAX_PLY from 100 to 120
Under some very rare case 100 plies of search
could be not enough. Increasing more could lead
to crashes due to reached stack size limit on
some platforms.

Strongly requested by Uri.

bench: 8430785
2014-02-16 12:20:37 +01:00
Marco Costalba e4695f15bc Additional renaming from DON
Assorted renaming and triviality.

No functional change.
2014-02-14 09:42:50 +01:00
Uri Blass 93f95cc936 Reduce VALUE_KNOWN_WIN to 10000
With some positions like

8/8/8/2p2K2/1pp5/br1p1b2/2p2r2/qqkqq3 w - -

The eval score is higher than VALUE_INFINITE because
is the sum of VALUE_KNOWN_WIN plus a big material
advantage. This leads to an assert. Here are the
steps to reproduce:

Compile SF with debug=yes then do

./stockfish
position fen 8/8/8/2p2K2/1pp5/br1p1b2/2p2r2/qqkqq3 w - -
go depth 1

This patch fixes the issue in this case, but do exsist
other positions for which the patch is not enough and
we will need to limit the eval score to be sure not
overflow the limit.

Note that is not possible to increase the value of
VALUE_INFINITE because should remain within int16_t
type to be stored in a TT entry.

bench: 7356053
2014-01-27 20:09:51 +01:00
shane31 153309e287 Scale eval when down to only one pawn
Passed both short TC
LLR: 2.97 (-2.94,2.94) [-1.50,4.50]
Total: 11921 W: 2346 L: 2208 D: 7367

And long TC
LLR: 2.97 (-2.94,2.94) [0.00,6.00]
Total: 21002 W: 3395 L: 3197 D: 14410

bench: 7602383
2014-01-02 12:44:46 +01:00
Marco Costalba c9dcda6ac4 Update copyright year
No functional change.
2014-01-02 01:49:18 +01:00
Arjun Temurnikar 431c3ac485 Even more spelling fixes
No functional change.
2013-12-06 09:03:24 +01:00
Jerry Donald c7e7d9217b Re-fix a comment
No functional change.
2013-12-03 08:50:12 +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 f99cb3dc27 Rename CASTLE to CASTLING
It is call 'castling move', not 'castle move'

Noticed while reading DiscoCheck sources.

No functional change.
2013-12-01 11:16:47 +01:00
Joona Kiiski 3ede7daab3 Generate Qsearch checks only at depth 0
An old idea retested at SPRT(0, 3) with 60+0.05 TC:
LLR: 2.95 (-2.94,2.94) [0.00,3.00]
Total: 98872 W: 15549 L: 15123 D: 68200

This is a very small elo increase patch so it really
stresses the limits of fishtest.

bench: 8596156
2013-11-24 10:26:49 +01:00
Marco Costalba 48f38f3092 Retire mirror()
Inline the only caller site.

No functional change.
2013-10-24 20:40:26 +02:00
Marco Costalba 549b5c478f Remove unuseful optimization in RKISS
Don't need a struct here. Speed test shows
result is teh same. Moreover RKISS is used
mainly at startup to compute magics, so
prefer to keep it simple...RKISS ;-)

Also some assorted triviality while there.

No functional change.
2013-10-13 03:35:17 -07:00
Marco Costalba b742a3f29a Increase MAX_MOVES to 256
This should be enough for any legal position, even
the handcrafted ones, like the one presented by Reuven:

1Q5R/4Q1K1/B1Q5/B4Q2/N2Q4/pQ4Q1/pn2Q3/krQ4R w - -

Where currently we crash. This reverts the patch
0049d3f337 of 8/4/2012 where stack
was shrinked due to crashes while in deep analysys.

No functional change.
2013-09-27 08:59:03 +02:00
Reuven Peleg d3947b2f3e Nicer operator declerations
No functional change.
2013-09-15 21:45:18 +02:00
Marco Costalba 7a1ff6d8ff Fix operator++ definition
ENABLE_OPERATORS_ON has incorrect definitions of
post-increment and post-decrement operators.

In particularly the returned value is the variable
already incremented/decremented, while instead they
should return the variable _before_ inc/dec.

This has no real effect because are only used in loops
and where the returned value is never used, neverthless
it is wrong. The fix would be to copy the variable to a
dummy, then inc/dec the variable, then return the dummy.

So instead, rename to pre-increment that can be implemented
without the dummy, actually the current implementation
it is already the correct pre-increment, with the only change
to return a reference (an l-value) and not a copy, so
to properly mimic the pre-increment on native integers.

Spotted by Kojirion.

No functional change.
2013-09-15 09:09:06 +02:00
Uri Blass 0915f85895 Union of 2 changes that failed with good score
This is a union of 2 changes:

A tweak of recaptures limit from Joona Kiiski
http://tests.stockfishchess.org/tests/view/52166d7c0ebc59319a242400

and a tweak of move count pruning from Leonid Pechenik
http://tests.stockfishchess.org/tests/view/5217c7e60ebc59319a242456

The set passed both short TC at 30+0.05
LLR: 2.96 (-2.94,2.94)
Total: 18936 W: 3723 L: 3566 D: 11647

And the usual long TC at 60+0.05
LLR: 2.95 (-2.94,2.94)
Total: 48962 W: 8837 L: 8487 D: 31638

bench: 3453945
2013-09-01 08:07:21 -07:00
Tom Vijlbrief f45eee318b Fix crash when reaching max ply
Bug introduced in 1b7223a53c that
updated the ss base stack without increasing
the dimension.

No functional change.
2013-08-19 16:53:46 +02:00
Eelco de Groot 5ee16a180a Increase pruning if evaluation is not improving
Add an additional set of margins to movecount pruning
to be used when static evaluation is getting worse
than previous move.

Here are the margins table with changing
depth (fm0 not improving, fm1 improving):

    d: 0, fm0: 3, fm1: 3
    d: 1, fm0: 4, fm1: 4
    d: 2, fm0: 6, fm1: 6
    d: 3, fm0: 7, fm1: 10
    d: 4, fm0: 11, fm1: 15
    d: 5, fm0: 15, fm1: 21
    d: 6, fm0: 21, fm1: 29
    d: 7, fm0: 27, fm1: 37
    d: 8, fm0: 35, fm1: 47
    d: 9, fm0: 42, fm1: 57
    d: 10, fm0: 51, fm1: 68
    d: 11, fm0: 60, fm1: 81
    d: 12, fm0: 70, fm1: 94
    d: 13, fm0: 81, fm1: 108
    d: 14, fm0: 92, fm1: 123
    d: 15, fm0: 104, fm1: 139

Good at both short TC

LLR: 2.97 (-2.94,2.94)
Total: 11502 W: 2503 L: 2361 D: 6638

And long TC

LLR: 2.98 (-2.94,2.94)
Total: 7189 W: 1421 L: 1277 D: 4491

bench: 4364793
2013-07-29 01:21:21 +02:00
homoSapiensSapiens 002062ae93 Use #ifndef instead of #if !defined
And #ifdef instead of #if defined

This is more standard form (see for example iostream file).

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2013-07-24 19:49:17 +02:00
Marco Costalba 99e547f4cb Rename MoveStack to ExtMove
Stack has no meaning here, while ExtMove (extended move),
better clarifies that we have a move + a score.

No functional change.
2013-07-19 10:27:58 +02:00
Marco Costalba 46fdb14b2f Don't use __builtin_expect
Partially revert previous patch and use
unlikey() just as code annotation.

Actually it is better to rely on a profiler for branch prediction:

http://blog.man7.org/2012/10/how-much-do-builtinexpect-likely-and.html

"In fact, even when only one in ten thousand values is nonzero,
we're still at only roughly the break-even point"

No functional change,
2013-07-15 21:09:06 +02:00
Marco Costalba cbb1a8ed31 Better annotate unlikely conditions
And in case of gcc we win also a small
speed optimization due to better branch
prediction.

No functional change.
2013-07-15 21:01:02 +02:00
Marco Costalba 8cff4862a6 Move SquareDistance[] to bitboard.cpp
No functional change.
2013-06-23 13:13:13 +02:00
Marco Costalba 908d98820b Don't explicitize enum values when not needed
Compiler will chose the correct values in sequential
order for you.

Also move file and rank bitboards definitions to
bitboard.h

No functional change.
2013-06-23 11:30:40 +02:00