]> git.sesse.net Git - stockfish/log
stockfish
14 years agoImplement MaxGain table
Joona Kiiski [Thu, 21 Jan 2010 14:50:23 +0000 (16:50 +0200)]
Implement MaxGain table

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove pointless gcc flag when generating dependencies
Joona Kiiski [Tue, 26 Jan 2010 17:06:38 +0000 (19:06 +0200)]
Remove pointless gcc flag when generating dependencies

When generating dependencies there is absolutely no point
to pass -msse flag to gcc, so remove it.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove InfiniteSearch hack
Joona Kiiski [Tue, 26 Jan 2010 17:05:06 +0000 (19:05 +0200)]
Remove InfiniteSearch hack

With current search control system, I can see absolutely no
reason to classify fixed time search as infinite search.

So remove old dated hack

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove last use of uip.eof()
Joona Kiiski [Tue, 26 Jan 2010 16:55:27 +0000 (18:55 +0200)]
Remove last use of uip.eof()

Value of uip.eof() should not be trusted.
input like "go infinite searchmoves " (note space in the end of line)
causes problems.

Check the return value of (uip >> token) instead

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoReduce lock contention in sp_search_pv()
Marco Costalba [Tue, 26 Jan 2010 11:05:38 +0000 (12:05 +0100)]
Reduce lock contention in sp_search_pv()

In less then 1% of cases value > sp->bestValue, so avoid
an useless lock in the common case. This is the same change
already applied to sp_search().

Also SplitPoint futilityValue is not volatile because
never changes after has been assigned in split()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a possible crash in thread_is_available()
Marco Costalba [Mon, 25 Jan 2010 21:18:12 +0000 (22:18 +0100)]
Fix a possible crash in thread_is_available()

When we have more then 2 threads then we do an array
access with index 'Threads[slave].activeSplitPoints - 1'
This should be >= 0 because we tested the variable just
few statements before, but because is a shared variable
it could be that the 'slave' thread set the value to zero
just after we test it, so that when we use the decremented
variable for array access we crash.

Bug spotted by Bruno Causse.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSmall split() cleanup
Marco Costalba [Mon, 25 Jan 2010 18:48:10 +0000 (19:48 +0100)]
Small split() cleanup

Unify start loop for master and slave threads. Also guarantee
that all the 'stop' flags are set to false before first slave
is started, should be no harm because only master thread can
reset 'stop' flag of slaves to true, so should be no race but
better safe then sorry.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoPrune evasions with negative SEE in qsearch
Marco Costalba [Wed, 20 Jan 2010 10:40:33 +0000 (11:40 +0100)]
Prune evasions with negative SEE in qsearch

Only pure blocking evasions are candidate
for pruning.

After 998 games at 1+0

Mod vs Orig +215 =596 -187  +10 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAvoid copy a Position to get a move's san notation
Marco Costalba [Mon, 25 Jan 2010 15:22:50 +0000 (16:22 +0100)]
Avoid copy a Position to get a move's san notation

In move_to_san() we create by copy a new position just
to detect if move gives check. This could be very costly in
line_to_san() that calls move_to_san() for every move, so
create the position only once and pass a reference to move_to_san()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a race in idle_loop() exiting
Marco Costalba [Mon, 25 Jan 2010 14:01:20 +0000 (15:01 +0100)]
Fix a race in idle_loop() exiting

When pondering threads are put to sleep, but when thinking
the threads are parked in idle_loop in a tight polling loop
checking for workIsWaiting falg.

So before we set the slave's flag workIsWaiting we have to
guarantee that all the slave data is already setup because
slave can start in any moment from there.

Rearrange the last loop to fix this race.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoIn split() release the lock before slow search stack copy
Marco Costalba [Mon, 25 Jan 2010 13:06:35 +0000 (14:06 +0100)]
In split() release the lock before slow search stack copy

Once we have allocated our slave threads and we have removed
master from available threads we can safely remove the lock
so that the lenghty search stack copy operation will not
impact lock contention.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDo not copy master position in split()
Marco Costalba [Mon, 25 Jan 2010 11:44:30 +0000 (12:44 +0100)]
Do not copy master position in split()

A pointer is enough because after a split point has been
setup master and slaves thread end up calling sp_search() or
sp_search_pv() and here a full copy of split point position is
done again, note that even master does another copy (of itself)
and this is done before any do_move() call so that master Position
is never updated between split() and sp_search().

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUse fast_copy() instead of full copy in sp_search
Marco Costalba [Mon, 25 Jan 2010 11:07:59 +0000 (12:07 +0100)]
Use fast_copy() instead of full copy in sp_search

And detach splitPoint Position from the master one.

So we duplicate StateInfo only once in split() instead
of one for each thread in sp_search

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoBetter document how Position c'tor works
Marco Costalba [Mon, 25 Jan 2010 11:04:00 +0000 (12:04 +0100)]
Better document how Position c'tor works

Renamed a bit the functions to be more clear what
we actually are doing when we craete a Position object
and explained how StateInfo works.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a couple of MSVC casting warnings
Marco Costalba [Mon, 25 Jan 2010 10:18:35 +0000 (11:18 +0100)]
Fix a couple of MSVC casting warnings

Also removed some trailing whitespaces and aligned
indentation to current standard.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoCopy only the search stack tail in split()
Marco Costalba [Mon, 25 Jan 2010 10:07:30 +0000 (11:07 +0100)]
Copy only the search stack tail in split()

Only the previous, the current and the next ply SearchStack
are copied.

This reduces split overhead especially at low depth (high ply)
and with many threads.

Possibly no functional change (it is not easy to prove in SMP)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoMerge branch 'master' of ssh://free2.projectlocker.com/sf
Tord Romstad [Sun, 24 Jan 2010 15:09:54 +0000 (16:09 +0100)]
Merge branch 'master' of ssh://free2.projectlocker.com/sf

14 years agoFixes a Chess960 bug when playing with more than one search thread.
Tord Romstad [Sun, 24 Jan 2010 15:09:32 +0000 (16:09 +0100)]
Fixes a Chess960 bug when playing with more than one search thread.

The init_eval() function corrupted the static array castleRightsMask[]
in the Position class, resulting in instant crashes in most Chess960
games. Fixed by repairing the damage directly after the function is
called. Also modified the Position::to_fen() function to display
castle rights correctly for Chess960 positions, and added sanity checks
for uncastled rook files in Position::is_ok().

14 years agoCheck for thread creation successful completion
Marco Costalba [Sun, 24 Jan 2010 11:24:01 +0000 (12:24 +0100)]
Check for thread creation successful completion

It is a good programming practice to verify a system
call has indeed succeed.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix some races in SMP code
Marco Costalba [Sun, 24 Jan 2010 12:46:27 +0000 (13:46 +0100)]
Fix some races in SMP code

When a search fails high then sp->alpha is increased and
slave threads are requested to stop.

So we have to check for a stop request before to start a search
otherwise we could end up with sp->alpha >= sp->beta
leading to an assert in debug run in search_pv().

This patch fixes the assert and get rid of some of possible races.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoMake sure we make a move at the end of the search when reaching
Tord Romstad [Fri, 22 Jan 2010 12:42:33 +0000 (13:42 +0100)]
Make sure we make a move at the end of the search when reaching
maximum depth during a "go movetime ..." search. This prevents
Stockfish from hanging forever after finding a mate in two or
three while running a test suite at a level of a few seconds
per move.

No functional change when playing games at normal time controls.

14 years agoIf near beta generate checks at -OnePly
Marco Costalba [Tue, 19 Jan 2010 14:24:26 +0000 (15:24 +0100)]
If near beta generate checks at -OnePly

In qsearch() try to get a cutoff with the help of an
extra check if we are already very near.

Small increase in actual games but a good result in tactical
test sets where this patch makes SF more tactical.

Mod vs Orig +197 =620 -181 +6 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRetire LMRPVMoves and LMRNonPVMoves
Marco Costalba [Wed, 20 Jan 2010 17:43:29 +0000 (18:43 +0100)]
Retire LMRPVMoves and LMRNonPVMoves

Are no used anymore.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix enum Value issue with gcc 4.4
Marco Costalba [Tue, 19 Jan 2010 22:30:23 +0000 (23:30 +0100)]
Fix enum Value issue with gcc 4.4

Louis Zulli reports a miscompile with g++-4.4 from MacPorts.

Namely enum Value is compiled as unsigned instead of signed integer
and this yields an issue in score_string() where float(v) is incorrectly
casted when Value v is negative.

This patch ensure that compiler choses a signed variable to store a Value.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSmall lnArray[] cleanup
Marco Costalba [Tue, 19 Jan 2010 10:48:22 +0000 (11:48 +0100)]
Small lnArray[] cleanup

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSilence some silly MSVC warnings
Marco Costalba [Mon, 18 Jan 2010 18:50:45 +0000 (19:50 +0100)]
Silence some silly MSVC warnings

Value is never used un-initialized, but MSVC is not
smart enough to detect itself :-(

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoOrder check moves used in qsearch
Marco Costalba [Sun, 17 Jan 2010 13:55:53 +0000 (14:55 +0100)]
Order check moves used in qsearch

Use the same scoring system used for evasions. Small if any
increase, but should be in at least for completeness.

After 999 games at 1+0
Mod vs Orig +208 =601 -190 +6 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAvoid an useless evaluate() call
Marco Costalba [Mon, 18 Jan 2010 14:47:43 +0000 (15:47 +0100)]
Avoid an useless evaluate() call

Now that we have position static score we don't
need to call evaluate() a second time.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAllow SearchStack to link an EvalInfo object
Marco Costalba [Mon, 18 Jan 2010 09:01:49 +0000 (10:01 +0100)]
Allow SearchStack to link an EvalInfo object

This will allow to have wider access to attack
information, for instance from MovePicker.

Note that 'eval' field become obsolete, it is kept
just becasue when we get a position score from TT
we update 'eval' even without an EvalInfo object.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoMake reduction search code SMP-friendly
Joona Kiiski [Sun, 17 Jan 2010 17:14:23 +0000 (19:14 +0200)]
Make reduction search code SMP-friendly

In sp_search_pv() we do a LMR search using sp->alpha, at the end
we detect a fail high with condition (value > sp->alpha), but if
another thread has increased sp->alpha during our LMR search we
could miss to detect a fail high event becasue value will be equal
to old alpha and so smaller then new one.

This patch fixes this SMP-bug and changes also the non SMP versions
of the search to keep code style in sync.

Bug spotted by Bruno Causse.

No functional change (for single CPU case)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSmall cleanup of unused code in sp_search
Joona Kiiski [Sun, 17 Jan 2010 13:05:28 +0000 (15:05 +0200)]
Small cleanup of unused code in sp_search

futilityValue is now calculated immediately after
staticValue, so remove small bunch of unused code

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix silly MSVC warning
Marco Costalba [Sun, 17 Jan 2010 12:54:52 +0000 (13:54 +0100)]
Fix silly MSVC warning

MSVC raises an "use of partially uninitialized variable" for futilityValue
and staticValue but this is not rue becasue when !isCheck variables
are never used, anyhow silence the warning.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoInitialize futilityMargin in EvalInfo c'tor
Marco Costalba [Sun, 17 Jan 2010 12:22:09 +0000 (13:22 +0100)]
Initialize futilityMargin in EvalInfo c'tor

This is less prone to bugs because now it's up to the
compiler don't forget this important initialization.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRetire quick_evaluate()
Joona Kiiski [Sun, 17 Jan 2010 11:55:10 +0000 (13:55 +0200)]
Retire quick_evaluate()

No change in functionality signature

The only functional change is that when we reach PLY_MAX,
we now return VALUE_DRAW instead of evaluating position.

But we reach PLY_MAX only when position is dead drawn and
transposition table is filled with draw scores, so this
shouldn't matter at all.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRazor at depth one, but do razoring only when not in check
Joona Kiiski [Thu, 14 Jan 2010 20:58:38 +0000 (22:58 +0200)]
Razor at depth one, but do razoring only when not in check

This way razoring is always based on exact evaluation and
follows simple formula.

Joona's test results are positive:

32-bit 1CPU:

Mod - Orig: 1073 - 993

64-bit 4CPU:

Mod - Orig: 759 - 721

Functionality Signature: 11448962

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAllow negative history values
Marco Costalba [Tue, 12 Jan 2010 17:21:15 +0000 (18:21 +0100)]
Allow negative history values

Don't clamp to zero if a move continues to fail.

After 946 games at 1+0
Mod vs Orig +208 =562 -176 +12 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoStore node evaluation in SearchStack
Marco Costalba [Sun, 10 Jan 2010 16:19:49 +0000 (17:19 +0100)]
Store node evaluation in SearchStack

This info will be used by future patches.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDecrease NullMoveMargin and adjust razoring
Marco Costalba [Sun, 10 Jan 2010 00:12:15 +0000 (01:12 +0100)]
Decrease NullMoveMargin and adjust razoring

Also retire razoring margins vector and use
a simpler formula instead.

Now that we use a more accurate static evaluation
try to avoid useless null searches when we are well
below beta. And for teh same reason increase a bit
the razoring.

After 972 games at 1+0
Mod vs Orig +224 =558 -190 +12 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDo not wait when AbortSearch is set
Marco Costalba [Mon, 11 Jan 2010 10:15:23 +0000 (11:15 +0100)]
Do not wait when AbortSearch is set

It means we have already received "stop" or "quit" commands.

This fixes an hang in tactical test in Fritz GUI. Bug
introduced by previous bug fix :-(

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix sending of best move during an infinite search
Marco Costalba [Sun, 10 Jan 2010 11:38:59 +0000 (12:38 +0100)]
Fix sending of best move during an infinite search

According to UCI standard once engine receives 'go infinite'
command it should search until the "stop" command and do not exit
the search without being told so, even if PLY_MAX has been reached.

Patch is quite invasive because it cleanups some hacks used
by fixed depth and fixed nodes modes, mainly during benchmarks.

Bug found by Pascal Georges.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix threads count setting
Marco Costalba [Sat, 9 Jan 2010 15:45:31 +0000 (16:45 +0100)]
Fix threads count setting

Was broken after "Optimal tune for 8 cores" patch.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoOptimal tune for 8 cores
Marco Costalba [Fri, 8 Jan 2010 11:51:11 +0000 (12:51 +0100)]
Optimal tune for 8 cores

After deep tests Louis Zulli found on his OCTAL machine that
best setup for an 8 core CPU is as following

"Threads" = 8
"Minimum Split Depth" = 6 or 7 (mSD)
"Maximum Number of Threads per Split Point" = not important (MNTpSP)

Here are testing results:

mSD7 (8 threads) vs mSD4 (8 threads): 291 - 120 - 589
mSD6 vs mSD7: 168 - 188 - 644
mSD6-MNTpSP5 vs mSD6-MNTpSP6: 172 - 172 - 656
SF-7threads vs SF-8threads: 179 - 204 - 617

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSync qsearch with search
Marco Costalba [Fri, 8 Jan 2010 10:45:46 +0000 (11:45 +0100)]
Sync qsearch with search

So to have the same layout and be as much similar as
possible. The only functional change is that now we
try ttMove as first also in PV nodes and at the end
we save the ttMove, as it happens in search. This
should have almost zero impact on ELO but it seems
the correct thing to do.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUse full evaluation in null search
Marco Costalba [Tue, 5 Jan 2010 08:57:48 +0000 (09:57 +0100)]
Use full evaluation in null search

This is an important design change because we know
compute evaluation in each node.

This is a 2.0 type change!

After 977 games at 1+0

Mod vs Orig +236 =538 -202 51.74%  +12 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSlow down reductions
Joona Kiiski [Mon, 4 Jan 2010 16:41:24 +0000 (18:41 +0200)]
Slow down reductions

After testing on Joona QUAD the whole LMR series:

Orig - Mod: 335 - 405 (+33 elo)

Functionality Signature: 12581900

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUse logarithmic LMR also at root
Joona Kiiski [Mon, 4 Jan 2010 06:46:33 +0000 (08:46 +0200)]
Use logarithmic LMR also at root

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoLogarithmic LMR
Joona Kiiski [Sun, 3 Jan 2010 19:58:50 +0000 (21:58 +0200)]
Logarithmic LMR

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix 'position ..... moves ' parsing bug
Marco Costalba [Thu, 7 Jan 2010 10:59:32 +0000 (11:59 +0100)]
Fix 'position ..... moves ' parsing bug

If after 'moves' there is a space then we crash.

The problem is that operator>>() trims whitespaces so that
after 'moves' has been extract we are still not at eof()
but remaining string contains only spaces. So that the next
extarction operation uip >> token ends up with unchanged token
value that remains 'moves', this garbage value is then feeded
to RootPosition.do_move() through move_from_string() that does
not detect the invalid move value leading to a crash.

This bug is triggered by Shredder 12 interface under Mac that
puts a space after 'moves' without any actual move list.

Bug fixed by Justin Blanchard

After reviewing UCI parsing code I spotted other possible weak
points due to the fact that we don't test if the last extract
operation has been succesful. So I have extended Justing patch
to fix the remaining possible holes in uci.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix en-passant parsing from fen string
Marco Costalba [Wed, 6 Jan 2010 08:58:41 +0000 (09:58 +0100)]
Fix en-passant parsing from fen string

According to standard en-passant is recorded in fen string regardless
of whether there is a pawn in position to make an en passant capture.

Instead internally we set ep square only if the pawn can be captured.
So teach from_fen() to correctly handle this difference.

Bug reported and fixed by Justin Blanchard.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoIntroduce refine_eval()
Marco Costalba [Fri, 1 Jan 2010 13:28:09 +0000 (14:28 +0100)]
Introduce refine_eval()

Try to get a position evaluation better then
the quick one with the help of the TT table.

This allows the null search conditions and
chosen reductions to be more accurate.

After 908 games at 1+0
Mod vs Orig +209 =526 -173 +14 ELO

Functionality Signature: 16627355

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoIncrease null reduction at high depths
Marco Costalba [Thu, 31 Dec 2009 10:54:26 +0000 (11:54 +0100)]
Increase null reduction at high depths

Linear rule, less aggressive then Dann's one.

It seems it scales well with depth. We will need to
verify against weaker engine if it keeps the score.

After 999 games at 1+0 on my Dual Core
Mod vs Orig +232 =534 -207  +9 ELO

After 1000 games by Martin Thoresen on his QUAD at 1+0
Mod vs Orig 521/479 52.10%

Functionality Signature: 17655312

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a compile error under gcc
Marco Costalba [Mon, 4 Jan 2010 16:17:40 +0000 (17:17 +0100)]
Fix a compile error under gcc

And some warnings on the picky icc.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoLast round of search.cpp cleanup
Marco Costalba [Mon, 4 Jan 2010 11:39:13 +0000 (12:39 +0100)]
Last round of search.cpp cleanup

The most interesting thing is a bit of rewrite
and semplification in connected_moves()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSpace inflate bottom part of search.cpp
Marco Costalba [Sun, 3 Jan 2010 20:30:46 +0000 (21:30 +0100)]
Space inflate bottom part of search.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRename MaxActiveSplitPoints
Marco Costalba [Sun, 3 Jan 2010 14:35:12 +0000 (15:35 +0100)]
Rename MaxActiveSplitPoints

And move in thread.h togheter with THREAD_MAX

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRetire 'finished' from MovePicker
Marco Costalba [Sun, 3 Jan 2010 12:27:31 +0000 (13:27 +0100)]
Retire 'finished' from MovePicker

It is not useful becasue it is safe to call
get_next_move() multiple times when phase == PH_STOP

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRename SingleReplyExtension in SingleEvasionExtension
Marco Costalba [Sun, 3 Jan 2010 09:19:43 +0000 (10:19 +0100)]
Rename SingleReplyExtension in SingleEvasionExtension

Because that's the correct meaning. Note that also the
corresponding UCI option has been renamed.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSmall cleanup in search.cpp
Marco Costalba [Sun, 3 Jan 2010 09:00:29 +0000 (10:00 +0100)]
Small cleanup in search.cpp

Also clarify some comments.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRetire approximateEval field from SplitPoint
Marco Costalba [Sat, 2 Jan 2010 09:27:36 +0000 (10:27 +0100)]
Retire approximateEval field from SplitPoint

It is not used anymore after the futility pruning
rewrite in a66f31f12.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDouble HistoryMax and reduce aging
Marco Costalba [Thu, 31 Dec 2009 11:44:10 +0000 (12:44 +0100)]
Double HistoryMax and reduce aging

After history accounting rewrite in 1.6, a small
tweak of history parameters seems positive.

Note that these are not to be considered the optimal
values, just a wild guess that proved good.

Finding the optimal values would require a much longer
testing time.

After 967 games at 1+0

Mod vs Orig 240 529 198 +15 ELO

Functionality Signature: 21222553

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a little warning under gcc compiler
Marco Costalba [Wed, 30 Dec 2009 10:09:27 +0000 (11:09 +0100)]
Fix a little warning under gcc compiler

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoOptimized bitScanReverse32()
Marco Costalba [Tue, 29 Dec 2009 13:43:15 +0000 (14:43 +0100)]
Optimized bitScanReverse32()

Should be a bit faster then previous one.
Hacked by Pascal Georges.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRestore development version
Marco Costalba [Tue, 29 Dec 2009 11:20:16 +0000 (12:20 +0100)]
Restore development version

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoStockfish 1.6.2
Marco Costalba [Mon, 28 Dec 2009 17:10:24 +0000 (18:10 +0100)]
Stockfish 1.6.2

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoBetter fix for gcc optimization issue
Marco Costalba [Mon, 28 Dec 2009 06:13:12 +0000 (07:13 +0100)]
Better fix for gcc optimization issue

According to the standard, compiler is free to choose
the enum type as long as can keep its data.
Also cast to short and right shift are implementation
defined in case of a signed integer.

Normally all the compilers implement this stuff in
the "usual" way, but gcc with -O3 and -O2 pushes
aggressively the language to its limits to squeeze
even the last bit of speed. And this broke our
not 100% standard conforming code.

The fix is to rewrite the Score enum and the 16 bits
word extracting functions in a way that is 100% standard
compliant and with no speed regression on gcc and also on
the other compilers.

Verified it works on all compilers and with equivalent
functionality.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoScore enum should be at least 32 bits
Marco Costalba [Sun, 27 Dec 2009 18:45:19 +0000 (19:45 +0100)]
Score enum should be at least 32 bits

The compiler is allowed to chose the size of an enum variable
based on the values it is expected to store. So force the compiler
to use at least a 32 bit integer type for the Score.

MSVC and Intel do not change, while gcc under -O3 is affected
by this change.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRevert small pop_1st_bit() optimization
Marco Costalba [Sun, 27 Dec 2009 13:05:15 +0000 (14:05 +0100)]
Revert small pop_1st_bit() optimization

We cannot cast a pointer type to an unrelated pointer type.
This is a violation of the strict aliasing rules.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove a bogus assert
Marco Costalba [Sun, 27 Dec 2009 12:54:46 +0000 (13:54 +0100)]
Remove a bogus assert

It is not clear why is not true, even in single thread
case, but as a matter of fact it is not!

So remove it.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUse THREAD_MAX instead of hardcoded 8
Marco Costalba [Sun, 27 Dec 2009 12:52:29 +0000 (13:52 +0100)]
Use THREAD_MAX instead of hardcoded 8

This will allow to change THREAD_MAX value in the future.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRestore development version
Marco Costalba [Sun, 27 Dec 2009 07:35:44 +0000 (08:35 +0100)]
Restore development version

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSet maximum hash table size to 2GB
Marco Costalba [Sat, 26 Dec 2009 23:44:08 +0000 (00:44 +0100)]
Set maximum hash table size to 2GB

We cannot allocate more then 2 GB, so let the limit
reflect this.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoStockfish 1.6.1
Marco Costalba [Sat, 26 Dec 2009 18:28:03 +0000 (19:28 +0100)]
Stockfish 1.6.1

Workaround a gcc optimization bug.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoWorkaround optimization bug in gcc
Marco Costalba [Sat, 26 Dec 2009 18:24:42 +0000 (19:24 +0100)]
Workaround optimization bug in gcc

Unfortunatly we need to slow down to -O1 to be sure
it works always.

Note that sometime it works also with -O2 or even -O3,
but user has to try himself.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix description of Score enum
Marco Costalba [Sat, 26 Dec 2009 17:16:38 +0000 (18:16 +0100)]
Fix description of Score enum

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a typo in ReducedStateInfo
Marco Costalba [Sat, 26 Dec 2009 17:12:59 +0000 (18:12 +0100)]
Fix a typo in ReducedStateInfo

It happened to work by accident because Score and
Value are both integer.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoStockfish 1.6
Marco Costalba [Tue, 22 Dec 2009 21:11:10 +0000 (22:11 +0100)]
Stockfish 1.6

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoScore definition gives a compile error under gcc
Marco Costalba [Mon, 21 Dec 2009 06:15:53 +0000 (07:15 +0100)]
Score definition gives a compile error under gcc

For enum definitions a parenthesis is required.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSetup Release Candidate 1
Marco Costalba [Sat, 19 Dec 2009 16:00:33 +0000 (17:00 +0100)]
Setup Release Candidate 1

To be used by Jim for testing different compiles settings.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a comment in HistoryMax description
Marco Costalba [Sat, 19 Dec 2009 09:43:12 +0000 (10:43 +0100)]
Fix a comment in HistoryMax description

Was obsoleted out some time ago.

Spotted by Justin Blanchard

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix book name is hard coded as book.bin
Marco Costalba [Fri, 18 Dec 2009 09:11:50 +0000 (10:11 +0100)]
Fix book name is hard coded as book.bin

Instead should be read by the corresponding UCI
option "Book File".

Bug reported and fixed by Justin Blanchard (Arch Linux)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoIn non-PV IID don't call evaluate when in check
Marco Costalba [Tue, 15 Dec 2009 11:07:23 +0000 (12:07 +0100)]
In non-PV IID don't call evaluate when in check

Was a long standing hidden bug from Glaurung times,
triggered only now that we enable IID at non PV nodes.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix a compile error in debug mode
Marco Costalba [Tue, 15 Dec 2009 10:26:45 +0000 (11:26 +0100)]
Fix a compile error in debug mode

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoEnable IID at non-PV nodes
Marco Costalba [Sat, 12 Dec 2009 18:36:40 +0000 (19:36 +0100)]
Enable IID at non-PV nodes

We want to increrase the opportunities
of doing an exclusion search.

After 999 games at 1+0
Mod vs Orig +216 =574 -209 50.35%  503.0/999  +2 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSynchronize pruning rules in search and sp_search
Joona Kiiski [Thu, 10 Dec 2009 15:24:18 +0000 (17:24 +0200)]
Synchronize pruning rules in search and sp_search

Regression test passed:

Mod - Orig: 365 - 351

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRemove history counters
Marco Costalba [Wed, 9 Dec 2009 13:40:38 +0000 (14:40 +0100)]
Remove history counters

Instead decrement history value on failure.

After 999 games at 1+0

Mod vs Orig  +236 =558 -204 51.60% +11 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix overflow risk in split point
Joona Kiiski [Thu, 10 Dec 2009 14:21:06 +0000 (16:21 +0200)]
Fix overflow risk in split point

Sizeof of search stack should be PLY_MAX+2 instead of PLY_MAX.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRe-enable TT.insert_pv()
Joona Kiiski [Tue, 8 Dec 2009 17:19:13 +0000 (19:19 +0200)]
Re-enable TT.insert_pv()

This time make sure that valuable TTentries are not overwritten.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDisable insert_pv
Joona Kiiski [Tue, 8 Dec 2009 17:06:38 +0000 (19:06 +0200)]
Disable insert_pv

This way we avoid overwriting valuable TT entries which
are needed to calculate exclusion search extension for pv.

Mod - Orig: 483 - 410 (+28 elo!)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoSet IncrementalFutilityMargin to 8
Marco Costalba [Tue, 8 Dec 2009 10:16:14 +0000 (11:16 +0100)]
Set IncrementalFutilityMargin to 8

After 999 games we are almost equal (+2 ELO),
but we have a good result against Rybka

Rybka 2.3.2a mp 32-bit vs Mod  254.5 - 242.5 +152/-140/=205 51.21%
Rybka 2.3.2a mp 32-bit vs Orig 259.5 - 236.5 +151/-128/=217 52.32%

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoReplace 100 with PLY_MAX in ok_to_use_TT
Joona Kiiski [Wed, 2 Dec 2009 20:08:58 +0000 (22:08 +0200)]
Replace 100 with PLY_MAX in ok_to_use_TT

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoAdjust SingleReplyMargin 0x64 -> 0x20
Joona Kiiski [Wed, 2 Dec 2009 18:34:55 +0000 (20:34 +0200)]
Adjust SingleReplyMargin 0x64 -> 0x20

Mod - Orig: 920 - 890 (+6 elo)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDon't clear hash at the beginning of a new game
Marco Costalba [Tue, 1 Dec 2009 10:56:48 +0000 (11:56 +0100)]
Don't clear hash at the beginning of a new game

After 900 games at 1+0
Mod vs Orig +217 =480 -196 +8 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoTry to prune also when approximateEval < beta
Marco Costalba [Tue, 1 Dec 2009 10:48:28 +0000 (11:48 +0100)]
Try to prune also when approximateEval < beta

Now we always try to filter out moves, we will have
more wasted evaluation calls, but also more pruned
nodes.

After 786 games

Mod vs Orig +196 =413 -177 +8 ELO

Verified also against Rybka it increases score to 50-51%

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDo not crash if we are asked to search mate or stalemate position.
Joona Kiiski [Sat, 28 Nov 2009 18:49:36 +0000 (20:49 +0200)]
Do not crash if we are asked to search mate or stalemate position.

We might be asked to ponder mate or stalemate position.
This being the case, simply wait for stop or ponderhit.
Currently we crash.

UCI specs aren't clear on the issue, but it cost nothing to
add little check.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoFix get_option_value() for strings with spaces
Marco Costalba [Sat, 28 Nov 2009 16:31:56 +0000 (17:31 +0100)]
Fix get_option_value() for strings with spaces

Problem is that

istream& operator>> (istream& is, char* str );

according to C++ documentation "Ends extraction when the
next character is either a valid whitespace or a null character,
or if the End-Of-File is reached."

So if the parameter value is a string with spaces the currently
used instruction 'ss >> ret;' copies the chars only up to the first
white space and not the whole string.

Use a specialization of get_option_value() to fix this corner case.

Bug reported by xiaozhi

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoRetire FutilityMargins[] array
Marco Costalba [Sat, 28 Nov 2009 10:52:13 +0000 (11:52 +0100)]
Retire FutilityMargins[] array

Now we use a formula to calculate margins on the fly.

Node count has changed because we fixed a leftover when
we still where using FutilityMargins to calculate futilityValue
in the case that we had the evaluation score in TT.

Also small indentation fix.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoIncrementalFutilityMargin to 4 and increased pruning
Marco Costalba [Thu, 26 Nov 2009 10:37:21 +0000 (11:37 +0100)]
IncrementalFutilityMargin to 4 and increased pruning

Increase pruning at low depths while tone downa bit at
higher depths (linearize a bit the logaritmic behaviour)

This goes togheter with IncrementalFutilityMargin decreased
to 4 compensate the bigger pruning effect.

Total pruned nodes are more or less the same. We go from 36%
of nodes after prune to 37% with this patch.

After 999 games at 1+0
Mod vs Orig +250 =526 -223 +9 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoDrop OnlyMoveExt PV-condition from 8 plies to 6 plies
Joona Kiiski [Fri, 27 Nov 2009 10:06:55 +0000 (12:06 +0200)]
Drop OnlyMoveExt PV-condition from 8 plies to 6 plies

Orig - Mod: 731 - 750

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoUse move not ttMove in exclude search
Marco Costalba [Fri, 27 Nov 2009 14:35:34 +0000 (15:35 +0100)]
Use move not ttMove in exclude search

If we arrive until the exclusion search call then
we know that move == ttMove == tte->move()

But using ttMove in search call while, during excluded search
conditions we have used tte->Move()could be a little bit suboptimal.
On the other side using tte->move() also in search call is a bit ugly
so opt for the third choice that is the most clean becasue from the
conditions the reader easily understands that we are talking of ttMove
and that we ant to exclude the move we are evaluating in that moment.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
14 years agoBetter document previous patch
Marco Costalba [Fri, 27 Nov 2009 10:54:07 +0000 (11:54 +0100)]
Better document previous patch

If tte->move() != MOVE_NONE then tte->move() == ttMove

What could happen is that we have a ttMove without a tte, or,
we have a tte but tte->move() == MOVE_NONE

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>