Commit graph

2505 commits

Author SHA1 Message Date
Marco Costalba 189b6fc270 Retire can_return_tt() and rewirte TT-hit code
Simplify the code and doing this introduce a couple
of (very small) functional changes:

- Always compare to depth even in "mate value" condition
- TT cut-off in qsearch also in case of PvNode, as in search

Verified against regression with 2500 games at 30"+0.05
on 2 threads: 451 - 444 - 1602

Functional changed: new bench is 5544977
2012-10-13 11:45:14 +02:00
Marco Costalba 6c8663341e Scale contempt factor to zero at endgame
Contempt Factor is more effective at opening/middle game
and seems harmful at endgame phase. See:

http://chessprogramming.wikispaces.com/Contempt+Factor

http://web.archive.org/web/20070707023203/www.brucemo.com/compchess/programming/contempt.htm

Therefore we scale down the contempt factor while going
on with the game so to reach zero at endgame phase.

No functional change.
2012-10-13 10:40:38 +02:00
Marco Costalba aba152ea3a Fix a minor bug in search
As Joona says: "The problem is that when doing full
window search (-VALUE_INFINITE, VALUE_INFINITE), and
pruning all the moves will return fail low which is
mate score, because only clause touching alpha is
"mate distance pruning". So we are returning mate score
although we are just pruning all the moves. In reality
there probably is no mate in sight.

Bug spotted and fixed by Joona.
2012-10-11 21:12:43 +02:00
Jean-Francois Romang 7f9ebf8e86 ARM lsb/msb assembly
Implement lsb/msb using armv7 assembly instructions.
msb is the easiest one, using a gcc intrinsic that generates
code using the ARM's clz instruction. lsb is also using this
clz instruction, but with the help of ARM's 'rbit' (bit
reversing) instruction. This leads to a >2% speed gain.

I also renamed 'arm-32' to the more meaningfull 'armv7' in the Makefile

No functional change.
2012-10-11 21:01:52 +02:00
Jean-Francois Romang 4e7da9be3d Introduce arm-32 ARCH in Makefile
No functional change.
2012-10-11 07:34:48 +02:00
Marco Costalba 46c01b5083 Retire is_dangerous() and inline its content
No functional change.
2012-10-10 08:13:36 +02:00
Marco Costalba dae843d4d6 Rearrange prefetch code
No functional change.
2012-10-08 11:43:47 +02:00
Marco Costalba 78fe0cfb8d Merge pull request #29 from RyanTaker/patch-3
Add Contempt Factor to Polyglot.ini
2012-10-07 15:36:08 -07:00
RyanTaker d77d555c72 Add Contempt Factor in Polyglot
The contempt factor was previously not included in polyglot.ini
2012-10-07 09:49:55 -07:00
Marco Costalba bbaef048cd Sync qsearch with search
Port to qsearch() the same changes we recently
added to search().

Overall this search refactoring series shows
almost 2% speed up on gcc compile.

No functional change.
2012-10-07 13:15:41 +02:00
Daylen Yang 7e2d49368d Improve compatibility with older versions of Mac OS X
Use the -mmacosx-version-min flag to support older versions of Mac OS X
(like version 10.6 and 10.7) when compiled on a machine running version
10.8.
2012-10-06 17:56:12 -07:00
Marco Costalba 954fc950d9 Fix POPCNT support on mingw 64
When using asm 'popcnt' instruction the given
operand registers must be of the same type.

No functional change.
2012-10-06 13:01:44 +02:00
Marco Costalba d777c4d789 Fix mingw compile with ARCH=x86-64
When using the Makefile (as for the mingw case),
IS_64BIT and USE_BSFQ are already set with
ARCH=x86-64 and do not need to be redefined.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-10-06 12:34:09 +02:00
Marco Costalba cedbd3332a Fix Contempt Factor implementation
First disable Contempt Factor during analysis, then
calculate the modified draw score from the point of
view of the player, so from the point of view of
RootPosition color.

Thanks to Ryan Taker for suggesting the fixes.

No functional change.
2012-10-06 10:12:34 +02:00
Marco Costalba ff9ca3e76e Fix fallouts from previous patch
These kind of arch specific code is really nasty
to make it right becuase you need to verify on
all the platforms.

Now should compile properly also on ARM

Reported by Jean-Francois.

No functional change.
2012-10-06 09:09:27 +02:00
Jean-Francois Romang b8948e84b8 Allow prefetching on non-x86 platforms with gcc
In particular on ARM processors. Original patch by
Jean-Francois, sligtly modified by me to preserve
the meaning of NO_PREFETCH flag.

Verified with gcc, clang and icc that prefetch instruction
is correctly created.

No functional change.
2012-10-06 00:43:16 +02:00
Marco Costalba 1ac417edb8 Retire futility_move_count()
And remove (bestValue < beta) condition from
moves loop.

No functional change.
2012-10-05 18:24:38 +02:00
Marco Costalba d471c49700 Rewrite search best value update
A simplification and also a small speed-up of
about 1% mainly due to reducing calls to
thisThread->cutoff_occurred().

Worst case split point recovering time after a
cut-off occurred is limited to 3 msec on my slow
PC, and usually is below 1 msec, so it seems safe
to remove the cutoff_occurred() check.

No functional change.
2012-10-05 13:53:05 +02:00
Marco Costalba c9f9262a49 Add experimental contempt factor
This is very crude and very basic: simply in case
of a draw for repetition or 50 moves rule return
a negative score instead of zero according to the
contempt factor (in centipawns). If contempt is
positive engine will try to avoid draws (to use
with weaker opponents), if negative engine will
try to draw. If zero (default) there are no changes.

No functional change.
2012-10-05 08:28:23 +02:00
Marco Costalba bd7a0d4ce4 Retire EasyMoveMargin
Use a value related to PawnValue instead.

This is a different patch from previous one because
could affect game play and skill levels, although
in a mostly unmeasurable way. Indeed thresold has
been raised so easy move is a bit harder to trigger
and skill level is a bit more prone to blunders.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-10-03 18:59:24 +02:00
Marco Costalba 561eb34aea Don't hide thresolds values
Show the real value in the code, not hide it
behind a variable name, especially when there
is only once occurence.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-10-03 18:56:36 +02:00
Marco Costalba 4c91dbc28e Further push singular extension
Extend for an extra half-ply in case the node is (probably)
going to fail high. In this case the added overhead is limited.

A novelity is the way this patch has been tested: Always in
self-play but with a much longer TC to allow the singular
extension to fully kick in and also (my impression) to have
less noisy results.

Ater 1015 games on my QUAD at 60"+0.05
Mod vs Orig 173 - 150 - 692 ELO +8
2012-10-02 06:39:27 +02:00
Marco Costalba 1b6b711c44 Further rearrange search()
No functional change.
2012-10-01 10:44:04 +02:00
Marco Costalba faaa1f1116 Don't push on the stack 200KB in one go
This could be a limit on some platforms (as it seems
to be in Native Client). Patch from a SF fork on github:

47374afd6f

No functional change.
2012-09-30 11:35:14 +02:00
Marco Costalba ed0fb0b05f Add support for node limited search
Handle also the SMP case. This has been quite tricky, not
trivial to enforce the node limit in SMP case becuase
with "helpful master" concept we can have recursive split
points and we cannot lock them all at once so there is the
risk of counting the same nodes more than once.

Anyhow this patch should be race free and counted nodes are
correct.

No functional change.
2012-09-30 10:19:22 +02:00
Marco Costalba e5463eb3ae Skip some useless initializations in search()
And rearrange a bit the initialization code. Still
some polishing to do, but it is a first step.

No functional change.
2012-09-29 23:12:39 +02:00
Marco Costalba d53c928261 Don't need to early check PV moves for legality
As long as isPvMove (renamed to pvMove) is set after
legality check, we can postpone legality even in PV case.

Patch aligns the PV case with the common non-pv one.

No functional change.
2012-09-29 18:05:49 +02:00
Marco Costalba bc8f5fe0bf Drop a magic in book.cpp
Mask out move's spacial flags without relying
on internal Move representation.

No functional change.
2012-09-22 11:19:10 +02:00
Marco Costalba 9204a60dbb Tweaks to bitcount functions
Seems even a bit faster now (almost 1% in 32bit case).

No functional change.
2012-09-22 10:59:33 +02:00
Marco Costalba 1cb2722c95 Restore development version 2012-09-22 00:37:18 +02:00
Marco Costalba 3caeabf73b Stockfish 2.3.1
Stockfish bench signature is: 5423738
2012-09-22 00:20:44 +02:00
Gary Linscott fdbe8006e0 Bonus for rook/queen attacking pawns on same rank
Patch and tuning by Gary Linscott from an idea of Ryan Taker.

Double tested by Gary:

Wins: 3390 Losses: 2972 Draws: 11323
LOS: 99.999992%
ELO: 8.213465 +- 99%: 6.746506 95%: 5.124415
Win%: 51.181792 +- 99%: 0.969791 95%: 0.736740

And by me:

After 5612 games 1255  1085  3271 +11 ELO
2012-09-21 23:25:13 +02:00
Marco Costalba 09acdac56b Fix compile on 64 bits
Reported by Quocvuong82.

No functional change.
2012-09-20 19:25:27 +02:00
Marco Costalba e4a0482e43 Simplify BSFTable initialization
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2012-09-19 20:47:53 +02:00
Marco Costalba 22a5f91aa7 Fix crash under Chess 960
We have a crash with this position:

rkqbnnbr/pppppppp/8/8/8/8/PPPPPPPP/RKQBNNBR w HAha -

What happens is that even if we are castling QUEEN_SIDE,
in this case we have kfrom (B8) < kto (C8) so the loop
that checks for attackers runs forever leading to a crash.

The fix is to check for (kto > kfrom) instead of
Side == KING_SIDE, but this is slower in the normal case of
ortodhox chess, so rewrite generate_castle() to handle the
chess960 case as a template parameter and allow the compiler
to optimize out the comparison in case of normal chess.

Reported by Ray Banks.
2012-09-16 14:14:55 +02:00
Marco Costalba 9ce7469846 Rename class Book to PolyglotBook
And move struct BookEntry out of the header where it is
not needed.

No functional change.
2012-09-16 10:32:57 +02:00
Marco Costalba 4b7dbb3922 Fix KpsK endgame
Broken by commit a44c5cf4f7 of 3 /12 / 2011 that
was labeled "No functional change" because our 'bench'
test didn't triggered that particular endgame. Indeed
we need to run a specific bench on a set of endgames
position when touching endgame.cpp because normal bench
does not cover endgames properly.

Found by MSVC 2012 code analyzer.
2012-09-16 08:57:26 +02:00
Marco Costalba e0035e9ca9 Restore development version
No functional change.
2012-09-15 11:02:08 +02:00
Marco Costalba 0a18adb02a Stockfish 2.3
Stockfish bench signature is: 5416292
2012-09-15 10:56:17 +02:00
Marco Costalba 630b3b2482 Fix compile with Intel 13.0
It seems Intel is unable to properly workout templates with 'static'
storage specifier.

Workaround using an anonymous namespace instead.

No functional change.
2012-09-15 10:55:39 +02:00
Marco Costalba 6008f6538e Don't exit earlier from aspiration window loop
Currently we exit the loop when

abs(bestValue) >= VALUE_KNOWN_WIN

but there is no logical reason for this. It seems more
natural to re-search again with full open window.

This has practically no impact in most cases, we have a
'no functional change' running 'bench' command.
2012-09-14 10:05:46 +02:00
Marco Costalba afcee1e8a4 Fix MSVC 2012 64bits warnings
Reported by Rein.

No functional change.
2012-09-14 09:57:13 +02:00
Marco Costalba e0bd0f250b Speed-up generate<LEGAL>
The trick here is to check for legality only in the
(rare) cases we have pinned pieces or a king move
or an en-passant.

This trick is able to increase the speed of perft
of more then 20%!

No functional change.
2012-09-11 20:24:31 +02:00
Marco Costalba 1598a3edf8 Remove redundancy in move generation
Introduce generate_all_moves() and remove a good
bunch of redundant code.

No functional change.
2012-09-09 17:05:02 +02:00
Marco Costalba 0dacab65eb Simplify generate_castle()
Skipping the calls to std::min(), std::man() we get
even a nice speed-up on perft.

No functional change.
2012-09-09 11:50:28 +02:00
Marco Costalba 834bd9edd7 Rename *last to *end
It is a more correct name because it points past the
last move of the list.

No functional change.
2012-09-09 10:24:40 +02:00
Marco Costalba 6e840f8033 Enable link time optimization only when optimizing
Because it is quite slow, skip it when 'optimize' flag is 'no'

No functional change.
2012-09-09 10:02:11 +02:00
Marco Costalba 2379312028 Revert "Simplify Option c'tor"
std::to_string() is C++11 material, not c++03.

So revert the patch.
2012-09-07 15:21:50 +02:00
Marco Costalba 37db62b2ea Simplify Option c'tor
No functional change.
2012-09-06 18:18:13 +02:00
Marco Costalba b50ce5ebfb Get rid of struct Time
We just need the milliseconds of current system
time for our needs. This allows to simplify the
API.

No functional change.
2012-09-04 09:38:51 +02:00