]> git.sesse.net Git - stockfish/log
stockfish
11 years agoMerge branch 'eval_cache'
Marco Costalba [Tue, 4 Dec 2012 06:57:46 +0000 (07:57 +0100)]
Merge branch 'eval_cache'

Use an eval cache instead of TT to store node
position evaluations.

It is already an improvment and, because it frees
two TT entry slots, paves the way to extend TT to
store both upper and lower bounds.

After 4855 games, single thread, 15"+0.05
Mod vs Orig 1165 -920 - 2770 ELO +18

bench: 5149248

11 years agoIncrease MAX_THREADS to 64
Marco Costalba [Mon, 3 Dec 2012 13:13:16 +0000 (14:13 +0100)]
Increase MAX_THREADS to 64

And document why this is an hard limit. It
seems for some (lucky) people 32 threads
are not enough.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoReintroduce eval optimizaion from null search
Marco Costalba [Sat, 1 Dec 2012 17:06:29 +0000 (18:06 +0100)]
Reintroduce eval optimizaion from null search

Now that conversion to eval cache is finished
we can reintroduce this optimization.

bench: 5149248

11 years agoDon't save eval score in TT
Marco Costalba [Sat, 1 Dec 2012 14:18:08 +0000 (15:18 +0100)]
Don't save eval score in TT

This patch completes the removal of eval info
in TT table.

No functional change.

11 years agoDon't use TT just to save a node evaluation
Marco Costalba [Sat, 1 Dec 2012 14:12:18 +0000 (15:12 +0100)]
Don't use TT just to save a node evaluation

In search(), after we evalute the position, in case there
isn't any TT entry we create one with just the evaluation
score.

This patches removes that code. The reason becuase the patch
deserves a single commit it is becuase introduces a (very small)
functional change due to the fact that the total number of
TT stores is less now and this slightly alters the TT hits
of our benchmark.

bench: 4983262

11 years agoDon't read eval from TT anymore
Marco Costalba [Sat, 1 Dec 2012 13:51:49 +0000 (14:51 +0100)]
Don't read eval from TT anymore

Rely fully on eval cache. Note that we still save eval
info to TT, this is not needed at this moment and will be
removed in future patches. We keep it so to have a "non
functional change" patch.

No functional change.

11 years agoRetire eval optimization from null search
Marco Costalba [Sat, 1 Dec 2012 13:48:13 +0000 (14:48 +0100)]
Retire eval optimization from null search

Simplify things preparing for further changes.

bench: 4983282

11 years agoAdd eval cache infrastructure
Marco Costalba [Sat, 1 Dec 2012 12:51:14 +0000 (13:51 +0100)]
Add eval cache infrastructure

With this patch series we want to introduce a per-thread
evaluation cache to store node evaluation and do not
rely anymore on the TT table for this.

This patch just introduces the infrastructure.

No functional change.

11 years agoDon't double check for move legality
Marco Costalba [Tue, 27 Nov 2012 19:05:03 +0000 (20:05 +0100)]
Don't double check for move legality

In case of a RootNode or a SpNode move has
been already checked for legality so we can
skip a redundant check.

Spotted by Frank Genot.

No functional change.

11 years agoUpdate bestValue when futility pruning
Marco Costalba [Mon, 26 Nov 2012 15:13:36 +0000 (16:13 +0100)]
Update bestValue when futility pruning

In qsearch we should update the bestValue as we do
in case of futilityValue < beta, also when pruning
moves with non-positive see.

Spotted by Lucas Braesch

Bench: 5695710

11 years agoAvoid spamming the GUI in multipv search
Marco Costalba [Sun, 18 Nov 2012 10:33:14 +0000 (11:33 +0100)]
Avoid spamming the GUI in multipv search

Send the PV lines to GUI only once at the end of the
PV search loop or just in case of long searches.

We need to sync also sending of "currmove" info to
avoid sending info on current move without first
informing the GUI on the PV line we are searching on.

No functional change.

11 years agoTriviality in move_gives_check()
Marco Costalba [Sat, 17 Nov 2012 11:57:58 +0000 (12:57 +0100)]
Triviality in move_gives_check()

It seems even a bit faster, although handling of the special
cases is not the hot path.

No functional change.

11 years agoBetter document fail-high condition
Marco Costalba [Sat, 17 Nov 2012 11:44:19 +0000 (12:44 +0100)]
Better document fail-high condition

At this point we have already verified (value > alpha)
and this implies, in case of a non-PV node, where search
window size is zero, that value >= beta.

This is not so self-evident, so document the code with
an assert condition.

No functional change.

11 years agoDon't access std::cout from Position::print()
Marco Costalba [Sun, 11 Nov 2012 12:18:10 +0000 (13:18 +0100)]
Don't access std::cout from Position::print()

Let the caller to decide where to redirect (cout or cerr) the
ASCII representation of the position. Rename the function to
reflect this.

Renamed also from_fen() and to_fen() to set() and fen() respectively.

No functional change.

11 years agoRestore old BOUND_EXACT logic in qsearch
Marco Costalba [Sun, 11 Nov 2012 10:49:02 +0000 (11:49 +0100)]
Restore old BOUND_EXACT logic in qsearch

In case a PvNode node has a static evaluation above alpha but
no available moves we want to flag the node as BOUND_EXACT,
not as BOUND_UPPER as is currently.

The behaviour was recently introduced with patch d471c49700fbe8281
of 3/10/2012

Spotted by Hongzhi Cheng.

bench: 5558464

11 years agoRevert "Don't prune discovered checks"
Marco Costalba [Sun, 11 Nov 2012 10:04:58 +0000 (11:04 +0100)]
Revert "Don't prune discovered checks"

Both Lucas re-test and Jean-Francois confirrm it
is a regression.

Here Jean-Francois's results after 3600 games :
Score of 96d3b1c92b8 vs 3b87314: 690 - 729 - 2181 [0.495] 3600
ELO: -3.86 +- 99%: 14.94 95%: 11.35
LOS: 15.03%
Wins: 690 Losses: 729 Draws: 2181 Total: 3600

Bench: 5404066

11 years agoDon't prune discovered checks
Marco Costalba [Wed, 7 Nov 2012 17:20:39 +0000 (18:20 +0100)]
Don't prune discovered checks

Don't prune and eventually extend check moves of type
DISCO_CHECK (pun intended, Lucas will understand :-) ).

Patch from Lucas Braesch that has also tested it:

Result: 879-661-2137, score=52.96%, LOS=100.00% (time 10"+0.1")

I have started a verification test right now.

bench: 6004966

11 years agoPrevious patch test results
Marco Costalba [Wed, 7 Nov 2012 17:05:45 +0000 (18:05 +0100)]
Previous patch test results

From Jean-Francois's

Final result after 5000 games :
Score of c581b7e vs a878312: 1163 - 970 - 2867 [0.519] 5000
ELO: 13.35 +- 99%: 12.71 95%: 9.65
LOS: 100.00%
Wins: 1163 Losses: 970 Draws: 2867 Total: 5000

From me

After 3266 games at 20"+0,05
Score of c581b7e vs a878312: 612 - 607 - 2047

So no regression at longer TC and perhaps a little gain at
fast TC.

11 years agoAnother attempt at evaluation shortcut
Marco Costalba [Mon, 5 Nov 2012 09:13:48 +0000 (10:13 +0100)]
Another attempt at evaluation shortcut

In this case we try a rather drastic
approach: we simply don't futility prune
in qsearch when arriving from a null move.

So we save evaluating and also save to mess
with eval margins at all because margin is used
only in futility.

Also accuracy should not be affected, actually it
improves because we don't prune anything anymore.

bench: 5404066

11 years agoTemporary revert previous patch
Marco Costalba [Mon, 5 Nov 2012 06:28:42 +0000 (07:28 +0100)]
Temporary revert previous patch

Performs well at very short TC of 40/4+0.05 (courtesy of Jean-Francois):
Wins: 2503 Losses: 2146 Draws: 5581 Total: 10230 +12 ELO

But is poor at longer TC of 20"+0.05
Wins: 321 Losses: 373 Draws: 1141 Total: 1808 -10 ELO

The patch was clearly a tradoff between speed and accuracy and
the most interesting part of it are test results that can be
commented as follows:

- A short TC is very sensible to any speed increase
- A longer TC is more sensible to accuracy and less to speed

So a patch that does not change speed is suitable to be tested at
short TC, while a speed/accuracy compromise patch is IMO better to
be tested at longer TC to verify loss of accuracy can be tolerated.

In this case the revert is only temporary. We will come back again
once we will be able to preserve the evaluation margin.

bench: 5809010

11 years agoSkip evaluate() call after a null move
Marco Costalba [Sun, 4 Nov 2012 09:21:40 +0000 (10:21 +0100)]
Skip evaluate() call after a null move

Reuse the evaluation of the parent with inverted sign and
set margin to zero (this is an hack!).

This is done only in qsearch where almost 15% of calls are
from a null move. In normal search the number of nodes where

(ss-1)->currentMove == MOVE_NULL

is almost zero and so there is no need of using this trick.

The big advantage of this patch is a speed-up due to skipped
evaluate() calls, that are very costly.

Functionality is of course affected and we will need to proper
test it later. For now we just register a 3-4% speed up.

Suggested by Hongzhi Cheng.

bench: 5051328

11 years agoCorrectly fix "break from split" patch
Marco Costalba [Sat, 3 Nov 2012 16:06:49 +0000 (17:06 +0100)]
Correctly fix "break from split" patch

In case split cut-offs we return with still
some moves to go but we really want to break
out from the loop now.

No functional change.

11 years agoRelax constrain in prevents_threat()
Marco Costalba [Sat, 3 Nov 2012 14:48:34 +0000 (15:48 +0100)]
Relax constrain in prevents_threat()

When testing if a move blocks the threat path there is no
reason to require the threat to be a slider. Indeed threat
can be a double pawn push like in this example:

r1bq1rk1/ppp1np1p/4n1p1/3p4/3P2Q1/2P1B3/PPBN2PP/R4RK1 w - - 0 16

Where white's move Rf6 blocks the threat f5.

As a nice side effect we can retire the now useless helper
piece_is_slider().

This patch kicks in only very rare cases, indeed the bench is
still the same!

bench: 5809010

11 years agoSync connected_threat() and yields_to_threat()
Marco Costalba [Sat, 3 Nov 2012 14:33:46 +0000 (15:33 +0100)]
Sync connected_threat() and yields_to_threat()

Rename stuff so to sync as much as posisble the
two related functions.

No functional change.

11 years agoDon't 'break' upon returning from split()
Marco Costalba [Sat, 3 Nov 2012 13:37:10 +0000 (14:37 +0100)]
Don't 'break' upon returning from split()

There is no guarantee that split() consumes all the node's
moves. Indeed split() can return without performing any job
for instance because MAX_SPLITPOINTS_PER_THREAD is reached
or becuase no available threads are found (this latter case
is much more common).

So search must continue in those cases and we cannot force
exiting from move's loop.

Bug introduced by 1ac417edb845 of 5/10/2012

Spotted by Frank Genot.

No functional change.

11 years agoRemove a redundant condition in connected_moves()
Marco Costalba [Sat, 3 Nov 2012 12:45:10 +0000 (13:45 +0100)]
Remove a redundant condition in connected_moves()

If a previous move attacks the king (with the piece
of the threat move removed) then must be a discovered
check, otherwise it means that first move gave check
and we were not able to do a null move.

Also renamed stuff to better document the function's
context.

No functional change.

11 years agoRelax constrain in connected_moves()
Marco Costalba [Sat, 3 Nov 2012 12:25:23 +0000 (13:25 +0100)]
Relax constrain in connected_moves()

When testing if a piece is moving through the squares
vacated by a previous move there is no reason to require
the piece to be a slider, indeed we can have a double
pawn push like in this example:

r1q2rk1/2p1bppp/2Pp4/pN5b/Q1P1p3/4B2P/PP1R1PP1/1K5R w - - 3 18

Where black's move f5 is connected to previous move Be7 that
frees the path.

Or we can have a castle move:

r1bqkb1r/pppp1ppp/2n1pn2/1B6/4P3/2N2N2/PPPP1PPP/R1BQK2R b KQkq - 5 1

Where a previous move Bb5 allows the white to castle king side.

This time patch is mine ;-)

new bench: 5809010

11 years agoReformat connected_moves()
Marco Costalba [Sat, 3 Nov 2012 11:57:07 +0000 (12:57 +0100)]
Reformat connected_moves()

Prepare code for the next patch that
will affect functionality.

No functional change.

11 years agoFix an off-by-one bug in multi pv print
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.

11 years agoFix a condition in connected_moves()
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

11 years agoMicro-optimize pop_lsb() for 64bit case
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.

11 years agoFix a warning under MSVC
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.

11 years agoPass InCheck as template parameter of qsearch()
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.

11 years agoUse correct occupancy in connected_threat()
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

11 years agoRetire move_attacks_square()
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.

11 years agoGet rid of ReducedStateInfo struct
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.

11 years agoCreative formatting in uci.cpp
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.

11 years agoDetect drawish KQKP endings
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.

11 years agoReformat check_is_dangerous()
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.

11 years agoUse std::stack instead of fixed size array
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.

11 years agoFix broken uci notation for promotions
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.

11 years agoFix asserts due to TT access races
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.

11 years agoExtend full 3 fold detection to PvNodes
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

11 years agoMerge pull request #34 from jromang/repetition
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

11 years agoFull three fold repetition detection only at root node
Jean-Francois Romang [Thu, 25 Oct 2012 13:57:44 +0000 (15:57 +0200)]
Full three fold repetition detection only at root node

11 years agoEnable true 3 fold detection in search
Jean-Francois Romang [Thu, 25 Oct 2012 06:54:05 +0000 (06:54 +0000)]
Enable true 3 fold detection in search

11 years agoAllow full repetition detection
Jean-Francois Romang [Tue, 23 Oct 2012 20:33:45 +0000 (20:33 +0000)]
Allow full repetition detection

Based on sshivaji 6ee19aa5389ce60181907ba53bbb50642f2d5657 commit

11 years agoFix an assert when we stop the search
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.

11 years agoRename RootPosition and shuffle think()
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.

11 years agoDrop Chess960 and UCIMultiPV globals and rename MultiPV
Marco Costalba [Wed, 24 Oct 2012 11:14:16 +0000 (13:14 +0200)]
Drop Chess960 and UCIMultiPV globals and rename MultiPV

No functional change.

11 years agoWrap in a class Skill Level code
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.

11 years agoShuffle aspiration window loop
Marco Costalba [Wed, 24 Oct 2012 08:34:36 +0000 (10:34 +0200)]
Shuffle aspiration window loop

No functional change.

11 years agoRetire refine_eval()
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.

11 years agoDon't copy a full Position object in print()
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.

11 years agoDon't need to init board[] with NO_PIECE
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.

11 years agoChange NO_PIECE value and shrink PieceValue[]
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.

11 years agoUse self-describing constants instead of numbers
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.

11 years agoMove RootColor from Eval to Search
Marco Costalba [Sun, 21 Oct 2012 07:12:02 +0000 (09:12 +0200)]
Move RootColor from Eval to Search

No functional change.

11 years agoContempt factor: use DrawValue also in case of stealmates
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).

11 years agoFix compatibility with old Windows 95 and 98
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>
11 years agoMerge pull request #33 from daylen/master
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.

11 years agoFurther improve compatibility when compiling on OS X
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

11 years agoFix Makefile for PowerPC with prefetch enabled
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.

11 years agoDocument why is safe ttValue == VALUE_NONE
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.

11 years agoSet TT size to 32 MB during 'bench'
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

11 years agoMove all Contempt Factor code to search.cpp
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.

11 years agoRetire BitCount8Bit[] table
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.

11 years agoUse new 64 bit De Bruijn BitScan
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.

11 years agoRetire can_return_tt() and rewirte TT-hit code
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

11 years agoScale contempt factor to zero at endgame
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.

11 years agoFix a minor bug in search
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.

11 years agoARM lsb/msb assembly
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.

11 years agoIntroduce arm-32 ARCH in Makefile
Jean-Francois Romang [Wed, 10 Oct 2012 11:34:06 +0000 (19:34 +0800)]
Introduce arm-32 ARCH in Makefile

No functional change.

11 years agoRetire is_dangerous() and inline its content
Marco Costalba [Wed, 10 Oct 2012 06:09:52 +0000 (08:09 +0200)]
Retire is_dangerous() and inline its content

No functional change.

11 years agoRearrange prefetch code
Marco Costalba [Mon, 8 Oct 2012 09:19:50 +0000 (11:19 +0200)]
Rearrange prefetch code

No functional change.

11 years agoMerge pull request #29 from RyanTaker/patch-3
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

11 years agoAdd Contempt Factor in Polyglot
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

11 years agoSync qsearch with search
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.

11 years agoImprove compatibility with older versions of Mac OS X
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.

11 years agoFix POPCNT support on mingw 64
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.

11 years agoFix mingw compile with ARCH=x86-64
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>
11 years agoFix Contempt Factor implementation
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.

11 years agoFix fallouts from previous patch
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.

11 years agoAllow prefetching on non-x86 platforms with gcc
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.

11 years agoRetire futility_move_count()
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.

11 years agoRewrite search best value update
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.

11 years agoAdd experimental contempt factor
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.

11 years agoRetire EasyMoveMargin
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>
11 years agoDon't hide thresolds values
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>
11 years agoFurther push singular extension
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

11 years agoFurther rearrange search()
Marco Costalba [Mon, 1 Oct 2012 07:33:13 +0000 (09:33 +0200)]
Further rearrange search()

No functional change.

11 years agoDon't push on the stack 200KB in one go
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.

11 years agoAdd support for node limited search
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.

11 years agoSkip some useless initializations in search()
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.

11 years agoDon't need to early check PV moves for legality
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.

11 years agoDrop a magic in book.cpp
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.

11 years agoTweaks to bitcount functions
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.

11 years agoRestore development version
Marco Costalba [Fri, 21 Sep 2012 22:37:18 +0000 (00:37 +0200)]
Restore development version

11 years agoStockfish 2.3.1
Marco Costalba [Fri, 21 Sep 2012 22:18:00 +0000 (00:18 +0200)]
Stockfish 2.3.1

Stockfish bench signature is: 5423738

11 years agoBonus for rook/queen attacking pawns on same rank
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