Marco Costalba [Fri, 2 Nov 2012 23:30:46 +0000 (00:30 +0100)]
Fix an off-by-one bug in multi pv print
We send to GUI multi-pv info after each cycle,
not just once at the end of the PV loop. This is
because at high depths a single root search can
be very slow and we want to update the gui as
soon as we have a new PV score.
Idea is good but implementation is broken because
sort() takes as arguments a pointer to the first
element and one past the last element.
So fix the bug and rename sort arguments to better
reflect their meaning.
Another hit by Hongzhi Cheng. Impressive!
No functional change.
Marco Costalba [Fri, 2 Nov 2012 16:04:51 +0000 (17:04 +0100)]
Fix a condition in connected_moves()
When checking if the moving piece p1 in a previous
move m1 defends the destination square of a move m2
we have to use the occupancy with the from square of
m2 removed so to take in account the case in which
f2 will block an x-ray attack from p1.
For instance in this position:
r2k3r/p1pp1pb1/qn3np1/1N2P3/1p3P2/2B5/PPP3QP/R3K2R b KQ - 1 9
The move eXf6 is connected to the previous move Bc3 that
defends the destination square f6.
With this patch we have about 10% more moves detected as
'connected'. Anyhow the absolute number is very low, about
4000 more moves out of 6M nodes searched.
Another issue spotted by Hongzhi "Hawk Eye" Cheng ;-)
new bench:
5757373
Marco Costalba [Thu, 1 Nov 2012 08:30:03 +0000 (09:30 +0100)]
Micro-optimize pop_lsb() for 64bit case
On Intel, perhaps due to 'lea' instruction this way of
zeroing the lsb of *b seems faster than a shift+negate.
On perft (where any speed difference is magnified) I
got a 6% speed up on my Intel i5 64bit.
Suggested by Hongzhi Cheng.
No functional change.
Marco Costalba [Fri, 2 Nov 2012 10:41:49 +0000 (11:41 +0100)]
Fix a warning under MSVC
Compiler complies that 'cnt' is initialized but
unused (in !CheckThreeFold case). Moving the
definition of 'cnt'out of the loop seems to do
the trick.
No functional change.
Marco Costalba [Thu, 1 Nov 2012 13:49:54 +0000 (14:49 +0100)]
Pass InCheck as template parameter of qsearch()
Instead of use a variable so to resolve many conditions
already at compile time. In quiesce is also where we
have most of the InCheck nodes and is one of the most
performance critical code paths.
Speed up of 1.5% with Clang and 1% with gcc
Suggested by Hongzhi Cheng.
No functional change.
Marco Costalba [Tue, 30 Oct 2012 19:21:22 +0000 (20:21 +0100)]
Use correct occupancy in connected_threat()
When checking if a move defends the threatened piece
we correctly remove from the occupancy bitboard the
moved piece. This patch removes from the occupancy also
the threatening piece so to consider the cases of moves
that defend the threatened piece x-raying through the
threat move.
As example in this position:
r3k2r/p1ppqp2/Bn4p1/3p1n2/4P1N1/5Q1P/PPP2P1P/R3K2R w KQkq - 1 10
The threat black move is dxe4. With this patch we include
(and so don't prune) white's Bb7 that would be pruned otherwise.
The number of affected position is very low, around 1% of cases,
so we don't expect ELO changes, neverthless this is the logical
and natural thing to do.
Patch suggested by Hongzhicheng.
new bench:
5323798
Marco Costalba [Tue, 30 Oct 2012 18:56:19 +0000 (19:56 +0100)]
Retire move_attacks_square()
There is only one call site. This patch is a
preparation for the next one that will affect
functionality.
No functional change.
Marco Costalba [Sun, 28 Oct 2012 16:12:40 +0000 (17:12 +0100)]
Get rid of ReducedStateInfo struct
ReducedStateInfo is a redundant struct that is also
prone to errors, indeed must be updated any time is
updated StateInfo. It is a trick to partial copy a
StateInfo object in do_move().
This patch takes advantage of builtin macro offsetof()
to directly calculate the number of quad words to copy.
Note that we still use memcpy to do the actual job of
copying the (48 bytes) of data.
Idea by Richard Vida.
No functional and no performance change.
Marco Costalba [Sun, 28 Oct 2012 10:09:47 +0000 (11:09 +0100)]
Creative formatting in uci.cpp
Have some fun breaking the indentation rules :-)
No functional change.
Gary Linscott [Sun, 28 Oct 2012 02:27:19 +0000 (22:27 -0400)]
Detect drawish KQKP endings
Based off of the rules from the wikipedia page,
here: http://en.wikipedia.org/wiki/Queen_versus_pawn_endgame.
bench does not change:
5312693 but patch is real, has been
tested on specific positions.
Marco Costalba [Sat, 27 Oct 2012 12:25:31 +0000 (14:25 +0200)]
Reformat check_is_dangerous()
And shuffle some code at search.cpp tail.
No functional change.
Marco Costalba [Fri, 26 Oct 2012 16:01:13 +0000 (18:01 +0200)]
Use std::stack instead of fixed size array
Only in not performance critical code like pretty_pv(),
otherwise continue to use the good old C-style arrays
like in extract/insert PV where I have done some code
refactoring anyhow.
No functional change.
Marco Costalba [Fri, 26 Oct 2012 14:04:59 +0000 (16:04 +0200)]
Fix broken uci notation for promotions
Silly typo (introduced in
e304db9d1ecf6a23) completely
messed up move notation in case of promotions causing
"Illegal move" warning in cutechess-cli.
Reported by Jörg Oster.
No functional change.
Marco Costalba [Fri, 26 Oct 2012 10:33:58 +0000 (12:33 +0200)]
Fix asserts due to TT access races
In multi-threads runs with debug on we experience some
asserts due to the fact that TT access is intrinsecally
racy and its contents cannot be always trusted so must
be validated before to be used and this is what the
patch does.
No functional case.
Marco Costalba [Fri, 26 Oct 2012 09:08:06 +0000 (11:08 +0200)]
Extend full 3 fold detection to PvNodes
And restore old behaviour of not returning from a RootNode
without updating RootMoves[].
Also renamed is_draw() template parameters to reflect a
'positive' logic (Check instead of Skip) that is easier
to follow.
New bench:
5312693
Marco Costalba [Fri, 26 Oct 2012 09:01:10 +0000 (02:01 -0700)]
Merge pull request #34 from jromang/repetition
Improve 3 fold repetition detection
Jean-Francois Romang [Thu, 25 Oct 2012 13:57:44 +0000 (15:57 +0200)]
Full three fold repetition detection only at root node
Jean-Francois Romang [Thu, 25 Oct 2012 06:54:05 +0000 (06:54 +0000)]
Enable true 3 fold detection in search
Jean-Francois Romang [Tue, 23 Oct 2012 20:33:45 +0000 (20:33 +0000)]
Allow full repetition detection
Based on sshivaji
6ee19aa5389ce60181907ba53bbb50642f2d5657 commit
Marco Costalba [Wed, 24 Oct 2012 22:07:16 +0000 (00:07 +0200)]
Fix an assert when we stop the search
When signal 'stop' is raised we return bestValue
that could be still set at -VALUE_INFINITE and
this triggers an assert. Fix it by returning
a value we know for sure is not +-VALUE_INFINITE.
Reported by 平岡拓也 Hiraoka.
No functional change.
Marco Costalba [Wed, 24 Oct 2012 12:37:52 +0000 (14:37 +0200)]
Rename RootPosition and shuffle think()
Just slightly code reshuffles, noting interesting here...
No functional change.
Marco Costalba [Wed, 24 Oct 2012 11:14:16 +0000 (13:14 +0200)]
Drop Chess960 and UCIMultiPV globals and rename MultiPV
No functional change.
Marco Costalba [Wed, 24 Oct 2012 10:05:20 +0000 (12:05 +0200)]
Wrap in a class Skill Level code
Note that the actual pickup is done in the class
d'tor so to be sure it is always triggered, even
in case of a sudden exit due to a 'stop' signal.
No functional change.
Marco Costalba [Wed, 24 Oct 2012 08:34:36 +0000 (10:34 +0200)]
Shuffle aspiration window loop
No functional change.
Marco Costalba [Mon, 22 Oct 2012 07:50:00 +0000 (09:50 +0200)]
Retire refine_eval()
Inline its content and better comment what it does through
some renaming.
No functional change.
Marco Costalba [Sun, 21 Oct 2012 22:53:17 +0000 (00:53 +0200)]
Don't copy a full Position object in print()
Function move_to_san() requires the Position to be
passed by referenced because a do/undo move is done
inside the function to detect a possible mate and to
add to the san string the corresponding '#' suffix.
Instead of passing a copy of current position pass
directly the original position object after const
casting it. This has the advantage to avoid a costly
Position copy, on the down side a bench test could
report different searched nodes if print(move) is
used, due to the additionals do_move() calls.
No functional change.
Marco Costalba [Sun, 21 Oct 2012 12:03:44 +0000 (14:03 +0200)]
Don't need to init board[] with NO_PIECE
Now that NO_PIECE == 0 the common memset() will
do the work.
No functional change.
Marco Costalba [Sun, 21 Oct 2012 09:49:05 +0000 (11:49 +0200)]
Change NO_PIECE value and shrink PieceValue[]
This requires changing color_of() definition.
No functional change.
Marco Costalba [Sun, 21 Oct 2012 08:41:23 +0000 (10:41 +0200)]
Use self-describing constants instead of numbers
And remove now useless comments.
No functional change.
Marco Costalba [Sun, 21 Oct 2012 07:12:02 +0000 (09:12 +0200)]
Move RootColor from Eval to Search
No functional change.
Marco Costalba [Sat, 20 Oct 2012 09:02:37 +0000 (11:02 +0200)]
Contempt factor: use DrawValue also in case of stealmates
Spotted by Jörg Oster.
No functional change (when contempt factor is not used).
Marco Costalba [Sat, 20 Oct 2012 08:32:35 +0000 (10:32 +0200)]
Fix compatibility with old Windows 95 and 98
Report and patches by bnemias.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sat, 20 Oct 2012 08:07:27 +0000 (01:07 -0700)]
Merge pull request #33 from daylen/master
Further improve OS X compatibility
Change the minimum supported version from 10.6 to 10.0
No functional change.
Daylen Yang [Tue, 16 Oct 2012 07:13:16 +0000 (00:13 -0700)]
Further improve compatibility when compiling on OS X
Change the minimum supported version from 10.6 to 10.0
Marco Costalba [Sun, 14 Oct 2012 23:13:41 +0000 (01:13 +0200)]
Fix Makefile for PowerPC with prefetch enabled
Existing Makefile is buggy for PowerPC, it has no
SSE, yet it is given it if Prefetch is enabled,
because it isn't ARMv7.
Patch from Matthew Brades.
No functional change.
Marco Costalba [Sun, 14 Oct 2012 10:36:05 +0000 (12:36 +0200)]
Document why is safe ttValue == VALUE_NONE
We can have ttValue == VALUE_NONE when we use a TT
slot to just save a position static evaluation, but
in this case we also save DEPTH_NONE so to avoid
using the ttValue in search. This happens to work,
but due to a number of lucky and tricky cases that
we now documnet through a bunch of asserts and a
little change to value_from_tt() that has no real
effect but clarifing the code.
No functional change.
Marco Costalba [Sun, 14 Oct 2012 07:02:04 +0000 (09:02 +0200)]
Set TT size to 32 MB during 'bench'
On some platforms 128 MB of RAM for TT is too much,
so run 'bench' with the default 32 MB size.
No functional change although of course now 'bench'
reports a different number:
5545018
Marco Costalba [Sat, 13 Oct 2012 12:38:08 +0000 (14:38 +0200)]
Move all Contempt Factor code to search.cpp
Where it is used.
No functional change.
Marco Costalba [Sat, 13 Oct 2012 12:21:27 +0000 (14:21 +0200)]
Retire BitCount8Bit[] table
Use popcount() instead in the only calling place.
It is used only at initialization so there is no
speed regression and anyhow even initialization
itself is not slowed down: magic bitboard setup
stays around 175 msec on my slow 32bit Core Duo.
No functional change.
Marco Costalba [Sat, 13 Oct 2012 11:34:50 +0000 (13:34 +0200)]
Use new 64 bit De Bruijn BitScan
Allows to sync 32 and 64 bits implementations.
Idea by Kim Walisch, reported by Gerd Isenberg:
http://talkchess.com/forum/viewtopic.php?t=45554
No functional change.
Marco Costalba [Sat, 13 Oct 2012 09:32:31 +0000 (11:32 +0200)]
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
Marco Costalba [Sat, 13 Oct 2012 08:40:38 +0000 (10:40 +0200)]
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.
Marco Costalba [Thu, 11 Oct 2012 19:11:11 +0000 (21:11 +0200)]
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.
Jean-Francois Romang [Thu, 11 Oct 2012 14:55:25 +0000 (22:55 +0800)]
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.
Jean-Francois Romang [Wed, 10 Oct 2012 11:34:06 +0000 (19:34 +0800)]
Introduce arm-32 ARCH in Makefile
No functional change.
Marco Costalba [Wed, 10 Oct 2012 06:09:52 +0000 (08:09 +0200)]
Retire is_dangerous() and inline its content
No functional change.
Marco Costalba [Mon, 8 Oct 2012 09:19:50 +0000 (11:19 +0200)]
Rearrange prefetch code
No functional change.
Marco Costalba [Sun, 7 Oct 2012 22:36:08 +0000 (15:36 -0700)]
Merge pull request #29 from RyanTaker/patch-3
Add Contempt Factor to Polyglot.ini
RyanTaker [Sun, 7 Oct 2012 16:49:55 +0000 (09:49 -0700)]
Add Contempt Factor in Polyglot
The contempt factor was previously not included in polyglot.ini
Marco Costalba [Sun, 7 Oct 2012 07:34:04 +0000 (09:34 +0200)]
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.
Daylen Yang [Sun, 7 Oct 2012 00:56:12 +0000 (17:56 -0700)]
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.
Marco Costalba [Sat, 6 Oct 2012 10:53:41 +0000 (12:53 +0200)]
Fix POPCNT support on mingw 64
When using asm 'popcnt' instruction the given
operand registers must be of the same type.
No functional change.
Marco Costalba [Sat, 6 Oct 2012 10:25:13 +0000 (12:25 +0200)]
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>
Marco Costalba [Sat, 6 Oct 2012 08:12:34 +0000 (10:12 +0200)]
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.
Marco Costalba [Sat, 6 Oct 2012 07:09:27 +0000 (09:09 +0200)]
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.
Jean-Francois Romang [Fri, 5 Oct 2012 20:30:22 +0000 (04:30 +0800)]
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.
Marco Costalba [Fri, 5 Oct 2012 13:00:35 +0000 (15:00 +0200)]
Retire futility_move_count()
And remove (bestValue < beta) condition from
moves loop.
No functional change.
Marco Costalba [Wed, 3 Oct 2012 12:11:20 +0000 (14:11 +0200)]
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.
Marco Costalba [Fri, 5 Oct 2012 06:23:56 +0000 (08:23 +0200)]
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.
Marco Costalba [Wed, 3 Oct 2012 08:34:42 +0000 (10:34 +0200)]
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>
Marco Costalba [Wed, 3 Oct 2012 08:08:10 +0000 (10:08 +0200)]
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>
Marco Costalba [Tue, 2 Oct 2012 04:18:21 +0000 (06:18 +0200)]
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
Marco Costalba [Mon, 1 Oct 2012 07:33:13 +0000 (09:33 +0200)]
Further rearrange search()
No functional change.
Marco Costalba [Sun, 30 Sep 2012 09:32:42 +0000 (11:32 +0200)]
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:
https://github.com/ccherng/Stockfish/commit/
47374afd6fdfabd9de183a7a67d645daad45fb21
No functional change.
Marco Costalba [Sun, 30 Sep 2012 04:49:56 +0000 (06:49 +0200)]
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.
Marco Costalba [Sat, 29 Sep 2012 16:26:17 +0000 (18:26 +0200)]
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.
Marco Costalba [Sat, 29 Sep 2012 15:41:53 +0000 (17:41 +0200)]
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.
Marco Costalba [Sat, 22 Sep 2012 09:08:10 +0000 (11:08 +0200)]
Drop a magic in book.cpp
Mask out move's spacial flags without relying
on internal Move representation.
No functional change.
Marco Costalba [Sat, 22 Sep 2012 07:26:25 +0000 (09:26 +0200)]
Tweaks to bitcount functions
Seems even a bit faster now (almost 1% in 32bit case).
No functional change.
Marco Costalba [Fri, 21 Sep 2012 22:37:18 +0000 (00:37 +0200)]
Restore development version
Marco Costalba [Fri, 21 Sep 2012 22:18:00 +0000 (00:18 +0200)]
Stockfish 2.3.1
Stockfish bench signature is:
5423738
Gary Linscott [Sun, 16 Sep 2012 13:59:30 +0000 (09:59 -0400)]
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
Marco Costalba [Thu, 20 Sep 2012 17:25:27 +0000 (19:25 +0200)]
Fix compile on 64 bits
Reported by Quocvuong82.
No functional change.
Marco Costalba [Tue, 18 Sep 2012 08:02:20 +0000 (10:02 +0200)]
Simplify BSFTable initialization
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Sun, 16 Sep 2012 12:06:13 +0000 (14:06 +0200)]
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.
Marco Costalba [Sun, 16 Sep 2012 08:30:32 +0000 (10:30 +0200)]
Rename class Book to PolyglotBook
And move struct BookEntry out of the header where it is
not needed.
No functional change.
Marco Costalba [Sun, 16 Sep 2012 06:52:38 +0000 (08:52 +0200)]
Fix KpsK endgame
Broken by commit
a44c5cf4f77b05a03 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.
Marco Costalba [Sat, 15 Sep 2012 07:34:31 +0000 (09:34 +0200)]
Restore development version
No functional change.
Marco Costalba [Sat, 30 Jun 2012 07:00:48 +0000 (08:00 +0100)]
Stockfish 2.3
Stockfish bench signature is:
5416292
Marco Costalba [Sat, 15 Sep 2012 08:50:23 +0000 (10:50 +0200)]
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.
Marco Costalba [Mon, 10 Sep 2012 16:24:53 +0000 (18:24 +0200)]
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.
Marco Costalba [Fri, 14 Sep 2012 07:42:59 +0000 (09:42 +0200)]
Fix MSVC 2012 64bits warnings
Reported by Rein.
No functional change.
Marco Costalba [Tue, 11 Sep 2012 18:00:58 +0000 (20:00 +0200)]
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.
Marco Costalba [Sun, 9 Sep 2012 12:30:22 +0000 (14:30 +0200)]
Remove redundancy in move generation
Introduce generate_all_moves() and remove a good
bunch of redundant code.
No functional change.
Marco Costalba [Sun, 9 Sep 2012 08:49:25 +0000 (10:49 +0200)]
Simplify generate_castle()
Skipping the calls to std::min(), std::man() we get
even a nice speed-up on perft.
No functional change.
Marco Costalba [Sun, 9 Sep 2012 08:17:31 +0000 (10:17 +0200)]
Rename *last to *end
It is a more correct name because it points past the
last move of the list.
No functional change.
Marco Costalba [Sun, 9 Sep 2012 08:02:11 +0000 (10:02 +0200)]
Enable link time optimization only when optimizing
Because it is quite slow, skip it when 'optimize' flag is 'no'
No functional change.
Marco Costalba [Fri, 7 Sep 2012 13:21:50 +0000 (15:21 +0200)]
Revert "Simplify Option c'tor"
std::to_string() is C++11 material, not c++03.
So revert the patch.
Marco Costalba [Thu, 6 Sep 2012 16:16:37 +0000 (18:16 +0200)]
Simplify Option c'tor
No functional change.
Marco Costalba [Tue, 4 Sep 2012 07:38:51 +0000 (09:38 +0200)]
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.
Marco Costalba [Sun, 2 Sep 2012 14:39:01 +0000 (16:39 +0200)]
Rename current_time() to now()
Follow C++11 naming conventions.
No functional change.
Marco Costalba [Sat, 1 Sep 2012 22:15:27 +0000 (00:15 +0200)]
Greatly speed up SEE
Simply reshuffling the code inverting the condition in next_attacker()
yields a miraculous speed up of more than 3% under gcc!
On my laptop a bench run goes from 320Knps to 330Knps
No functional change.
Marco Costalba [Sat, 1 Sep 2012 09:45:14 +0000 (11:45 +0200)]
Unroll least valuable attacker loop in SEE
This allows to reduce the scanning for new X-ray attacks
according to the capturing piece type.
It seems to be just a very small speed increase in MSVC 64
bit and gcc 32 bit, I guess cache issues value more than some
instruction less to execute (as usual).
No functional change.
Marco Costalba [Sat, 1 Sep 2012 09:45:14 +0000 (11:45 +0200)]
Slightly simplify SEE
Some renaming and small code reshuffle.
No fuctional change.
Marco Costalba [Fri, 31 Aug 2012 13:19:35 +0000 (15:19 +0200)]
Retire Time::restart()
Simplify API.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Fri, 31 Aug 2012 12:21:16 +0000 (14:21 +0200)]
Don't need to memset HashTable
Default c'tor Entry() already initializes
to zero all its POD members.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 29 Aug 2012 14:43:01 +0000 (16:43 +0200)]
Terminate threads before to exit main()
It is very difficult and risky to assure
that a running thread doesn't access a global
variable. This is currently true, but could
change in the future and we don't want to rely
on code that works 'by accident'. The threads
are still running when ThreadPool destructor is
called (after main() returns) and this could
lead to crashes if a thread accesses a global
that has been already freed. The solution is to
use an exit() function and call it while we are
still in main(), ensuring global variables are
still alive at threads termination time.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 29 Aug 2012 11:28:59 +0000 (13:28 +0200)]
Convert to sync_cout and sync_endl
Serialize access to std::cout all over the code.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Wed, 29 Aug 2012 09:25:11 +0000 (11:25 +0200)]
Introduce serialization of accesses to std::cout
When many threds concurrently print you need to serialize
the access to std::cout to avoid output lines are intermixed
with the contents of each thread.
This is not strictly needed at the moment because
only main thread prints out, although some ad-hoc
test could trigger UCI::loop() printing while searching.
Anyhow we want to lift this pretty avoidable constrain
also as a prerequisite for future work.
This patch just introduces the support, next one will enable
the serialization.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Marco Costalba [Mon, 27 Aug 2012 12:39:59 +0000 (14:39 +0200)]
Correctly handle handover of setup states
Before the search we setup the starting position doing all the
moves (sent by GUI) from start position to the position just
before to start searching.
To do this we use a set of StateInfo records used by each
do_move() call. These records shall be kept valid during all
the search because repetition draw detection uses them to back
track all the earlier positions keys. The problem is that, while
searching, the GUI could send another 'position' command, this
calls set_position() that clears the states! Of course a crash
follows shortly.
Before searching all the relevant parameters are copied in
start_searching() just for this reason: to fully detach data
accessed during the search from the UCI protocol handling.
So the natural solution would be to copy also the setup states.
Unfortunatly this approach does not work because StateInfo
contains a pointer to the previous record, so naively copying and
then freeing the original memory leads to a crash.
That's why we use two std::auto_ptr (one belonging to UCI and another
to Search) to safely transfer ownership of the StateInfo records to
the search, after we have setup the root position.
As a nice side-effect all the possible memory leaks are magically
sorted out for us by std::auto_ptr semantic.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>