stockfish
11 years agoRetire count_1s_8bit()
Marco Costalba [Tue, 19 May 2009 14:49:54 +0000 (15:49 +0100)]
Retire count_1s_8bit()

Use the plain array lookup in the only place where it
is used. This remove an unecessary indirection and better
clarifies what code does.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSmall code style triviality in evaluation
Marco Costalba [Tue, 19 May 2009 14:41:45 +0000 (15:41 +0100)]
Small code style triviality in evaluation

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRemove hardcode default values of UCI variables from evaluation
Marco Costalba [Tue, 19 May 2009 14:35:12 +0000 (15:35 +0100)]
Remove hardcode default values of UCI variables from evaluation

This is the same change we have already done in search.cpp,
this time for evaluation.cpp

If a variable will be populated reading an UCI option
then do not hard code its default values.

This avoids misleadings when reading the sources.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoCache king shelter info in pawns structure
Marco Costalba [Sat, 16 May 2009 14:15:05 +0000 (16:15 +0200)]
Cache king shelter info in pawns structure

It does not change often and is not so fast
to calculate.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMove beta counter variables to the per-thread data
Marco Costalba [Sat, 16 May 2009 11:22:40 +0000 (12:22 +0100)]
Move beta counter variables to the per-thread data

This should reduce concurrent accessing in SMP case.

Suggestion by Tord Romstad.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoBetter document how history works
Marco Costalba [Fri, 15 May 2009 14:42:30 +0000 (16:42 +0200)]
Better document how history works

Both with added comment and changing the API to
reflect that only destination square and moved piece
is important for history.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix broken multi-pv with aspiration window search
Marco Costalba [Fri, 15 May 2009 07:39:36 +0000 (09:39 +0200)]
Fix broken multi-pv with aspiration window search

Aspiration window search must be disabled for
multi-pv case.

We missed one point where aspiration window should
be disabled in this case.

Patch from Joona, with a little added edit by me.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix a warning un using anonymous structs
Marco Costalba [Tue, 12 May 2009 10:10:40 +0000 (12:10 +0200)]
Fix a warning un using anonymous structs

No functional and no binary change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoUse string instead of std::string
Marco Costalba [Sun, 10 May 2009 16:58:53 +0000 (17:58 +0100)]
Use string instead of std::string

And others small code style touches.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoUse 64 bits for debug counters
Marco Costalba [Sun, 10 May 2009 11:21:45 +0000 (13:21 +0200)]
Use 64 bits for debug counters

Has happened 32 bits were not enough for
some test.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix some Intel compilers warnings
Marco Costalba [Sat, 9 May 2009 10:01:00 +0000 (12:01 +0200)]
Fix some Intel compilers warnings

Also a compile fix due to Makefile missing new
application.cpp file.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMicro optimize generate_pawn_checks()
Marco Costalba [Fri, 8 May 2009 08:53:45 +0000 (10:53 +0200)]
Micro optimize generate_pawn_checks()

Use a better condition to find candidate direct check pawns.
In particular consider only pawns in the front ranks of the
enemy king, this greatly reduces pawns candidates bitboard
that now is empty more then 90% of the time so that we
can early skip further tests.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoConvert also generate_pawn_blocking_evasions() to new API
Marco Costalba [Thu, 7 May 2009 15:08:55 +0000 (17:08 +0200)]
Convert also generate_pawn_blocking_evasions() to new API

New compact parameter passing API.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoBetter dscovery check condition in generate_pawn_checks()
Marco Costalba [Thu, 7 May 2009 15:01:52 +0000 (17:01 +0200)]
Better dscovery check condition in generate_pawn_checks()

Be more strict, is not enough dc bitboard is not empty, but
needs to inclde also at least one pawn.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFurther parametrize generate_pawn_captures
Marco Costalba [Thu, 7 May 2009 13:32:28 +0000 (15:32 +0200)]
Further parametrize generate_pawn_captures

We can parametrize for the capture direction too.

Also use a single template parameter and calculate (at
compile time) remainin parameters directly in the function.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoUpdate copyright year
Marco Costalba [Thu, 7 May 2009 12:54:40 +0000 (14:54 +0200)]
Update copyright year

We are well in 2009 already.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRewrite the way application exits
Marco Costalba [Thu, 7 May 2009 10:45:46 +0000 (12:45 +0200)]
Rewrite the way application exits

Centralize in a single object all the global resources
management and avoid a bunch of sparse exit() calls.

This is more reliable and clean and more stick to C++ coding
practices.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoBe sure book file is closed before we leave
Marco Costalba [Thu, 7 May 2009 07:27:38 +0000 (09:27 +0200)]
Be sure book file is closed before we leave

Move closing of file in Book destructor. This
guarantees us against leaving the file open under
any case and simplifies also Book use.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRewrite Book implementation
Marco Costalba [Wed, 6 May 2009 12:52:12 +0000 (14:52 +0200)]
Rewrite Book implementation

Let Book be derived directly from std::ifstream
and rewrite the functions accordingly.

Also simplify file reading by use of operator>>()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSpace inflate book.cpp
Marco Costalba [Wed, 6 May 2009 08:28:17 +0000 (10:28 +0200)]
Space inflate book.cpp

Also document most interesting parts.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix a couple of MSVC warnings
Marco Costalba [Tue, 5 May 2009 18:42:16 +0000 (19:42 +0100)]
Fix a couple of MSVC warnings

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMicro optimize move_is_ep() and move_is_castle()
Marco Costalba [Tue, 5 May 2009 13:09:09 +0000 (15:09 +0200)]
Micro optimize move_is_ep() and move_is_castle()

Avoid a shift operation moving it at compile time.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFaster Position::move_is_capture() condition
Marco Costalba [Tue, 5 May 2009 12:55:48 +0000 (14:55 +0200)]
Faster Position::move_is_capture() condition

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix missing pawn color check in move_is_legal()
Marco Costalba [Tue, 5 May 2009 11:10:29 +0000 (13:10 +0200)]
Fix missing pawn color check in move_is_legal()

In case we have a correct white pawn move but pawn
is black (or the contrary) we fail to detect the
move as illegal.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoUpdate makefile to use PGO with Intel C++ v11.0
Marco Costalba [Mon, 4 May 2009 09:38:08 +0000 (11:38 +0200)]
Update makefile to use PGO with Intel C++ v11.0

Update profiler guided optimization instructions in
Makefile to the latest Intel C++ compiler.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMicro optimize SEE
Marco Costalba [Mon, 4 May 2009 09:18:24 +0000 (11:18 +0200)]
Micro optimize SEE

Use pieces_of_type() instead of pieces_of_color_and_type()
in an hot loop and cut of almost 10% SEE execution time.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoAvoid an usless check in pl_move_is_legal
Marco Costalba [Sat, 2 May 2009 15:47:06 +0000 (16:47 +0100)]
Avoid an usless check in pl_move_is_legal

Although very cheap this is a very hot path,
so avoid it.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoChange TT interface to ask directly for a position key
Marco Costalba [Sat, 2 May 2009 12:57:52 +0000 (14:57 +0200)]
Change TT interface to ask directly for a position key

Instead of a position because the key is all that we
need.

Interface is more clear and also very very little bit faster.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSetup to use Callgrind profiler
Marco Costalba [Sat, 2 May 2009 12:39:23 +0000 (14:39 +0200)]
Setup to use Callgrind profiler

Disabled by default.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRestore development versioning and LSN filtering
Marco Costalba [Sat, 2 May 2009 12:38:26 +0000 (14:38 +0200)]
Restore development versioning and LSN filtering

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoStockfish 1.3.1
Marco Costalba [Sun, 3 May 2009 06:49:34 +0000 (07:49 +0100)]
Stockfish 1.3.1

Mainteinance version to fix broken Glaurung 2
book reading.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRevert Glaurung 1 book compatibility patch
Marco Costalba [Sun, 3 May 2009 06:28:37 +0000 (07:28 +0100)]
Revert Glaurung 1 book compatibility patch

It breaks also Glaurung 2 book parsing.

We really need to work on book.cpp, but for now just
leave compatibility just for Glaurung 2 books.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoStockfish 1.3
Marco Costalba [Sat, 2 May 2009 09:09:53 +0000 (10:09 +0100)]
Stockfish 1.3

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix a very old UCI option parsing bug
Marco Costalba [Sat, 2 May 2009 10:14:45 +0000 (11:14 +0100)]
Fix a very old UCI option parsing bug

We currently fail on an option with a sapece in the name,
as example

setoption name Clear Hash

returns error message "Option Clear not found". This
patch fixes this off-by-one type bug.

Thanks to Joona for spotting this.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoNicely simplify MovePicker::pick_move_from_list
Marco Costalba [Fri, 1 May 2009 09:27:03 +0000 (11:27 +0200)]
Nicely simplify MovePicker::pick_move_from_list

It is a positive fall back from previous patch.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSort moves just after scoring
Marco Costalba [Fri, 1 May 2009 08:17:34 +0000 (10:17 +0200)]
Sort moves just after scoring

Instead of a delayed selection sort so that the highest
score move is picked up from the list when needed, sort all
the moves up front just after score them.

Selection sort is O(n*n) while std::sort is O(n*log n), it
is true that delayed selection allows us to just pick the move
until a cut off occurs or up to a given limit (12), but with
an average of 30 non capture-moves delayed pick become slower
just after 5-6 moves and we now pick up to 12.

Profiling seem to prove this idea and movepick.cpp is now 10%
faster.

Also tests seem to confirm this:

After 700 games at 1+0: Mod vs Orig +178 -160 =362 +9 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoUpdate polyglot.ini
Marco Costalba [Thu, 30 Apr 2009 14:16:35 +0000 (15:16 +0100)]
Update polyglot.ini

Upadte to new parameters and parameters values.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoStockfish 1.3 rc1
Marco Costalba [Thu, 30 Apr 2009 07:18:20 +0000 (09:18 +0200)]
Stockfish 1.3 rc1

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoDo not razor after a null move
Marco Costalba [Thu, 30 Apr 2009 06:55:38 +0000 (08:55 +0200)]
Do not razor after a null move

We don't want to return unproven null move fails high, so
that if a position is so good that null move fails high we
want to check this with real do_move() / undo_move() test,
not just razoring the position because, from the opponent
point of view, is very bad.

These are tests results at 1+0

Mod vs Orig +252 -264 =483  49.40%
Mod vs Toga II 1.4.1SE  +365 -325 =309  52.00%

So it seems a very slightly regression regarding orig version (but
withing error bar) and a nice increase against Toga that is what we
are interested most. Orig version scores 49.75% against Toga, so
we welcome this change ;-)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix assignment of pv[0] when creating root move list
Marco Costalba [Wed, 29 Apr 2009 13:53:37 +0000 (15:53 +0200)]
Fix assignment of pv[0] when creating root move list

It is bogusly assigned from moves[i].move instead of mlist[i].move
or equivalently to moves[count].move that it seem more clear to me.

Bug is hidden while all the moves are included, in this default case
moves[i].move and mlist[i].move are the same variable.

Also a bit of cleanup while there.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMerge Joona's razoring tweaks
Marco Costalba [Tue, 28 Apr 2009 06:51:11 +0000 (08:51 +0200)]
Merge Joona's razoring tweaks
After proof testing on 3 different engines these
are the results:

Stockfish - Toga II 1.4.1SE +130 -132 =132 49.75%
Stockfish - Deep Sieng 3.0  +145 -110 =150 54.45%
Stockfish - HIARCS 12 MP    +94  -149 =150 43.00%

So it seems no regressions occurs, although also no
improvment. But anyhow this patch increases Stockfish
strenght against itself, so merge it.

Note that this patch not only adds back razoring at depth
one, but also increases razor depth limit from 3 to 4
because hard coded depth 4 limit is no more overwritten
by UCI parameter that otherwise defaults to 3.

11 years agoHardcode depth limit for selective search
Marco Costalba [Tue, 28 Apr 2009 06:47:26 +0000 (08:47 +0200)]
Hardcode depth limit for selective search

Because futility margins array has a fixed size we cannot
arbitrarly choose or change the SelectiveDepth parameter,
otherwise we have a crash for values bigger then array size.

On the other hand tweaking of this parameter requires some
modification to the hardcoded margins, so makes sense to hard
code also this very bounded one.

Who wants to experiment is of course free to change the sources.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix a warning under MSVC
Marco Costalba [Mon, 27 Apr 2009 17:00:45 +0000 (18:00 +0100)]
Fix a warning under MSVC

Somehow silly warning C4800:
'int' :forcing value to bool 'true' or 'false'(performance warning)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMicro optimize Position::move_is_check()
Marco Costalba [Mon, 27 Apr 2009 15:39:59 +0000 (17:39 +0200)]
Micro optimize Position::move_is_check()

More then optimization it is worth a bit of better
code self documenting.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoInline Position::move_is_capture()
Marco Costalba [Mon, 27 Apr 2009 14:35:31 +0000 (16:35 +0200)]
Inline Position::move_is_capture()

This is a very hot path function, profiling on Intel compiler
shows that inlining cuts in half the overhead.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRetire timeoday.cpp
Marco Costalba [Mon, 27 Apr 2009 12:48:14 +0000 (13:48 +0100)]
Retire timeoday.cpp

Move the only function gettimeofday in misc.cpp
where is used.

This avoids polluting the global namespace.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSmall cleanup in misc.cpp
Marco Costalba [Mon, 27 Apr 2009 12:38:47 +0000 (13:38 +0100)]
Small cleanup in misc.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoCode style cleanup in transposition table code
Marco Costalba [Mon, 27 Apr 2009 12:21:49 +0000 (13:21 +0100)]
Code style cleanup in transposition table code

Assorted fixes but no functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix a bogus assert in tt.cpp
Marco Costalba [Mon, 27 Apr 2009 09:29:33 +0000 (10:29 +0100)]
Fix a bogus assert in tt.cpp

Max hash size is 4096 MB, not 1024 MB, see the corresponding
"Hash" UCI parameter in ucioption.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoConvert piece.cpp to C++
Marco Costalba [Mon, 27 Apr 2009 09:12:34 +0000 (10:12 +0100)]
Convert piece.cpp to C++

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRemove an useless comparison in futility pruning
Marco Costalba [Mon, 27 Apr 2009 08:45:15 +0000 (09:45 +0100)]
Remove an useless comparison in futility pruning

Currently futility is allowed when depth < SelectiveDepth
and SelectiveDepth is 7*OnePly, so the comprison is
always true.

Patch could introduce a functional change only if
we choose to increase SelectiveDepth.

Currently no functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSmall code tidy up and test results
Marco Costalba [Sun, 19 Apr 2009 16:23:30 +0000 (17:23 +0100)]
Small code tidy up and test results

When testing at 1'+0" time control results are still
reasonably good. We have made two sessions on two
different PC.

After 840 games Mod - Orig: +221 -194 =425 +10 ELO (two CPU)

After 935 games Mod - Orig: +246 -222 =467  +9 ELO (single CPU)

So it seems that with fast CPU and/or longer time controls
benefits of the patch are a bit reduced. This could be due
to the fact that only 3% of nodes are pruned by razoring at
depth one and these nodes are very swallow ones, mostly get
pruned anyway with only a slightly additional cost, even
without performing any do_move() call.

Another reason is that sometime (0,3%% of cases) a possible
good move is missed typically in positions when moving side
gives check, as example in the following one

3r2k1/pbpp1nbp/1p6/3P3q/6RP/1P4P1/P4Pb1/3Q2K1 w - -

The winning move Rxg7+ is missed.

Bottom line is that patch seems good for blitz times, perhaps
also for longer times. We should test against a third engine
(Toga ?) to have a final answer regarding this new setup.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRazor again at depth one
Joona Kiiski [Thu, 9 Apr 2009 04:29:13 +0000 (07:29 +0300)]
Razor again at depth one
Some time ago it was found by Marco Costalba that it's better
to disable razoring at depth one, because given the very low
evaluation of the node, futility pruning would already do
the job at very low cost and avoiding missing important moves.

Now enable razoring there again, but only when our quickly evaluated
material advantage is more than a rook. The idea is to try razoring
only when it's extremely likely that it will succeed.

Extreme lightning speed test show promising result:
Orig - Mod: +1285 =1495 -1348

This needs to be tested with longer time controls though.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMake futility and razor margins more tunable
Joona Kiiski [Wed, 8 Apr 2009 14:35:36 +0000 (17:35 +0300)]
Make futility and razor margins more tunable

Restructure RazorMargins and FutilityMargins arrays so that their
values can be more easily tuned.

Add RazorApprMargins array which replaces razorAtDepthOne concept,
because setting RazorApprMargin very high value at ply one is
same as not razoring there at all.

Comment out setting razoring and futility margins through uci to
avoid errors while tuning.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoDo not hardcode default values of UCI variables
Marco Costalba [Sat, 25 Apr 2009 14:26:06 +0000 (15:26 +0100)]
Do not hardcode default values of UCI variables

If a variable will be populated reading an UCI option
then do not hard code its default values.

This avoids misleadings when reading the sources.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoGreatly speedup has_mate_threat()
Marco Costalba [Mon, 20 Apr 2009 07:10:27 +0000 (09:10 +0200)]
Greatly speedup has_mate_threat()

Instead of loop across all legal moves to find a mate
loop across possible check moves only.

This reduces more then 10 times the number of moves to
check for a possible mate.

Also rename generate_checks() in generate_non_capture_checks()
so to better clarify what the function does.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMicro optimize generate_piece_checks() take 2
Marco Costalba [Sun, 19 Apr 2009 19:09:53 +0000 (21:09 +0200)]
Micro optimize generate_piece_checks() take 2

Add some missing bits of this patch.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoAdd missing header file to make stockfish compile with latest Inter C++ Compiler...
Joona Kiiski [Sun, 19 Apr 2009 16:46:07 +0000 (19:46 +0300)]
Add missing header file to make stockfish compile with latest Inter C++ Compiler under Linux (memcpy needs cstring)

Correct some references glaurung -> stockfish in Makefile

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSimplify Position::is_mate()
Marco Costalba [Sun, 19 Apr 2009 15:44:12 +0000 (16:44 +0100)]
Simplify Position::is_mate()

Should be a bit faster too.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMicro optimize generate_piece_checks()
Marco Costalba [Sat, 18 Apr 2009 15:21:44 +0000 (16:21 +0100)]
Micro optimize generate_piece_checks()

Avoid calculating piece attacks if there aren't
available check sqaures for the given piece.

About 15% of cases. Not a biggie but still something
especially in the middle game where king is well covered
inside his castle.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMovePicker: retire per square MVV/LVA ordering
Marco Costalba [Sat, 18 Apr 2009 13:19:19 +0000 (14:19 +0100)]
MovePicker: retire per square MVV/LVA ordering

Is not used anyway and in case we need it again we
can resurrect from git archives.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoIn qsearch store the cut move in TT
Marco Costalba [Sat, 18 Apr 2009 13:03:33 +0000 (14:03 +0100)]
In qsearch store the cut move in TT

And upon reentering the same position try it as first.

Normally qsearch moves order is already very good, first move
is the cut off in almost 90% of cases. With this patch, we get
a cut off on TT move of 98%.

Another good side effect is that we don't generate captures
and/or checks when we already have a TT move.

Unfortunatly we found a TT move only in 1% of cases. So real
impact of this patch is relatively low.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMerge Joona's new aspiration window search
Marco Costalba [Thu, 16 Apr 2009 06:35:26 +0000 (08:35 +0200)]
Merge Joona's new aspiration window search
It seems very positive.

After 999 games at 1'+0" result is: +249 -216 =534 +11 ELO

And after another 456 games we still have: +122 -113 =221

11 years agoIntroduce move_pawns() helper in movegen.cpp
Marco Costalba [Tue, 14 Apr 2009 10:36:34 +0000 (12:36 +0200)]
Introduce move_pawns() helper in movegen.cpp

This let us to have more readable code keeping the
same speed.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRemove failHigh/Low bits from IterationInfoType
Marco Costalba [Thu, 16 Apr 2009 08:02:01 +0000 (10:02 +0200)]
Remove failHigh/Low bits from IterationInfoType

We don't use that info anyway.

Also document a little more new aspiration window code.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRestore calling insert_pv after search is aborted + small clean-up
Joona Kiiski [Wed, 15 Apr 2009 15:14:06 +0000 (18:14 +0300)]
Restore calling insert_pv after search is aborted + small clean-up

Restore old behaviour that after search is aborted we call insert_pv,
before breaking out from the iterative deepening loop.

Remove one useless FIXME and document other better.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoLittle code style tweaks
Marco Costalba [Wed, 15 Apr 2009 10:44:55 +0000 (12:44 +0200)]
Little code style tweaks

Let the code be more conformant to current style.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRevert previous patch as per Joona request
Marco Costalba [Wed, 15 Apr 2009 08:20:35 +0000 (10:20 +0200)]
Revert previous patch as per Joona request
Joona says patch gives bad results after testing,
so revert for now.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoImprove handling of fail-highs in assumed PV
Joona Kiiski [Sun, 12 Apr 2009 21:27:07 +0000 (00:27 +0300)]
Improve handling of fail-highs in assumed PV

Check all fail highs in assumed PV with greater care (fruit/Toga already does this).
Add a flag when aspiration search fails high at ply 1 to prevent search to
be terminated prematurely.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRevert "Implement a fallback system when aspiration search fails low and we are out...
Joona Kiiski [Sun, 12 Apr 2009 20:30:40 +0000 (23:30 +0300)]
Revert "Implement a fallback system when aspiration search fails low and we are out of time."

This reverts commit 55dd98f7c717b94a659931cd20e088334b1cf7a6.

Revert fallback-system for root_search

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoImplement a fallback system when aspiration search fails low and we are out of time.
Joona Kiiski [Sun, 12 Apr 2009 20:25:05 +0000 (23:25 +0300)]
Implement a fallback system when aspiration search fails low and we are out of time.

However also this patch is immediately reverted. For three reasons:
1) the case it affects is very rare (and then we are likely to lose anyway),
   so we can well live without this.

2) Because the case is so rare it's hard to test this change properly.

3) To perform fallback search, we must reset so many global variables that this
   patch is very likely both buggy and extremely bad style.

Consider including this again if we clean-up global variables one day...

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRevert "Implement bestValue in root_search."
Joona Kiiski [Sun, 12 Apr 2009 16:49:09 +0000 (19:49 +0300)]
Revert "Implement bestValue in root_search."

This reverts commit 9a39f93f35254787b7b57980019dde276a89c48c.

Revert bestValue in root_search

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoImplement bestValue in root_search.
Joona Kiiski [Sun, 12 Apr 2009 16:42:47 +0000 (19:42 +0300)]
Implement bestValue in root_search.

However just after finished writing this patch I realized that this
is not the way to go. So this will be immediately reverted.

(Just save this here in git in case I change my mind later :) )

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoDynamic aspiration search without research.
Joona Kiiski [Sat, 11 Apr 2009 13:46:35 +0000 (16:46 +0300)]
Dynamic aspiration search without research.

Implement system where aspiration search window is calculated using
values from previous iterations.

And then some crazy experimental stuff: If search fails low at the root,
don't widen window, but continue and hope we will find a better move
with given window. If search fails high at the root, cut immediately,
add some more time and start new iteration.

Note: this patch is not complete implementation, but a first test
for this idea. There are many FIXMEs left around. Most importantly
how to deal with the situation when we don't have any move!

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRe-fix square.h warning to avoid a compile error under MSVC
Marco Costalba [Sun, 12 Apr 2009 15:45:33 +0000 (16:45 +0100)]
Re-fix square.h warning to avoid a compile error under MSVC

This fix adds ugliness to an already ugly previous fix...hopefully
it is the last one :-(

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix a gcc warning due to order of initialization in Option
Marco Costalba [Sun, 12 Apr 2009 16:05:09 +0000 (18:05 +0200)]
Fix a gcc warning due to order of initialization in Option

Move idx declaration before minValue and maxValue and silence
this last warning.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix a compile error with Intel icc
Marco Costalba [Sun, 12 Apr 2009 16:01:06 +0000 (18:01 +0200)]
Fix a compile error with Intel icc

To make std::sort() work operator<() should be
declared const.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix a warning under Intel compiler in square.h
Marco Costalba [Sun, 12 Apr 2009 15:58:30 +0000 (17:58 +0200)]
Fix a warning under Intel compiler in square.h

We need to cast to char the whole expression...

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix a very nasty conversion bug in Option c'tor
Marco Costalba [Sun, 12 Apr 2009 00:09:03 +0000 (01:09 +0100)]
Fix a very nasty conversion bug in Option c'tor

Sometimes C++ can be really bad!

In this case an hard coded c string selects Option c'tor
with int argument instead of the std::string one becuase
it is considered a better matching by the compiler.

Fix the bug changing the argument type from std::string to
const char* so to be a better match then the int one.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoStore UCI options of type CHECK according to C++ convention
Marco Costalba [Sat, 11 Apr 2009 12:04:33 +0000 (14:04 +0200)]
Store UCI options of type CHECK according to C++ convention

Store boolean values as "1" and "0" instead of "true" and "false"
and convert back to UCI protocol convention when needed.

This is simpler then the other way around.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRestore original UCI option printing order
Marco Costalba [Sat, 11 Apr 2009 11:28:51 +0000 (13:28 +0200)]
Restore original UCI option printing order

For each option store its index so to be printed
according to insertion order.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoUse a map instead of a vector to store UCI options
Marco Costalba [Sat, 11 Apr 2009 10:46:47 +0000 (12:46 +0200)]
Use a map instead of a vector to store UCI options

Apart from the teoretical speed increase, the main reason
of this patch is a good amount of code cleanup.

Note that now UCI options are printed in alphabetical
order and not in insertion order as before. Next patch
will take care of restoring old behaviour.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRemove unused currentMoveCaptureValue from search stack
Marco Costalba [Tue, 7 Apr 2009 07:54:32 +0000 (09:54 +0200)]
Remove unused currentMoveCaptureValue from search stack

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoLess aggressive null move dynamic reduction
Marco Costalba [Fri, 10 Apr 2009 08:49:29 +0000 (09:49 +0100)]
Less aggressive null move dynamic reduction

In null move search do not jump directly in
qsearch() from depth(4*OnePly), but only
from depth(3*OnePly).

After 999 games at 1+0: +248 -224 =527 +8ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRevert dynamic LMR
Marco Costalba [Fri, 3 Apr 2009 19:34:22 +0000 (20:34 +0100)]
Revert dynamic LMR

It doesn't seem to work against Toga. After more then 400 games
we are at -13 ELO while, without it we are at + 5 ELO after 1000
games.

So revert for now to keep code simple.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix compile in the debug mode
Marco Costalba [Mon, 30 Mar 2009 10:12:52 +0000 (12:12 +0200)]
Fix compile in the debug mode

Due to previous patches we end up with a compile
error in debug mode.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSilence idiotic warning on two's complement of an unsigned
Marco Costalba [Mon, 30 Mar 2009 10:07:45 +0000 (12:07 +0200)]
Silence idiotic warning on two's complement of an unsigned

MSVC gives:

warning C4146: unary minus operator applied to unsigned type,
               result still unsigned

When finds -b where b is an unsigned integer. So rewrite the two's
complement in a way to avoid the warning. Theoretically the new
version is slower, but in practice changes nothing.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSilence a bunch of warnings under MSVC /W4
Marco Costalba [Mon, 30 Mar 2009 09:55:13 +0000 (11:55 +0200)]
Silence a bunch of warnings under MSVC /W4

Still some remain, but are really the silly ones.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRevert setting a flag when TT value equals static evaluation
Marco Costalba [Tue, 31 Mar 2009 12:57:44 +0000 (14:57 +0200)]
Revert setting a flag when TT value equals static evaluation
Strangely enough it seems that optimization doesn't work.

After 760 games at 1+0: +155 -184 =421 -13 ELO

Probably the overhead, although small, for setting the flag
is not compensated by the saved evaluation call.

This could be due to the fact that after a TT value is stored,
if and when we hit the position again the stored TT value is
actually used as a cut-off so that we don't need to go on
with another search and evaluation is avoided in any case.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoAn VALUE_TYPE_EVAL score cannot overwrite an entry
Marco Costalba [Mon, 30 Mar 2009 08:09:27 +0000 (09:09 +0100)]
An VALUE_TYPE_EVAL score cannot overwrite an entry

If we want to store a value of type VALUE_TYPE_EVAL for
a given position and we found an already exsisting entry
for the same position then we skip.

We don't want to overwrite a more valuable score with a
lesser one. Note that also in case the exsisting entry is
of VALUE_TYPE_EVAL type the overwrite is unuseful because
we would store the same score again.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRemember when TT value equals static evaluation value
Marco Costalba [Mon, 30 Mar 2009 07:54:09 +0000 (08:54 +0100)]
Remember when TT value equals static evaluation value

When the stored TT value equals the static value set a
proper flag so to not call evaluation() if we hit the
same position again but use the stored TT value instead.

This is another trick to avoid calling costly evaluation()
in qsearch.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoDocument TTEntry and move layouts
Marco Costalba [Mon, 30 Mar 2009 07:29:02 +0000 (08:29 +0100)]
Document TTEntry and move layouts

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoA move needs 17 bits not 19
Marco Costalba [Sun, 29 Mar 2009 16:22:10 +0000 (17:22 +0100)]
A move needs 17 bits not 19

Fix a bug in the way a move is stored and read in a TT entry.
We use a mask of 19 bits insteaad of 17 so that the last
two bits in the TT entry end up to be random data.

This bug will bite us when we will use these two until now
unused bits.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRemove some obsolete code in movepick.cpp
Marco Costalba [Fri, 27 Mar 2009 18:18:21 +0000 (19:18 +0100)]
Remove some obsolete code in movepick.cpp

This fixes some warning under Intel compiler.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRevert storing of TT when returning from "stand pat"
Marco Costalba [Fri, 27 Mar 2009 14:30:45 +0000 (15:30 +0100)]
Revert storing of TT when returning from "stand pat"

After testing it seems patch is bad:

After 999 games 1+0: +242 -271 =486 -10 ELO

So restore saving of TT at the end but using new Joona
idea of storing as VALUE_TYPE_UPPER/VALUE_TYPE_LOWER instead
of VALUE_TYPE_EXACT.

Some optimization is still possible but better test new ideas
one by one.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoCache evaluation score in qsearch
Marco Costalba [Tue, 24 Mar 2009 14:48:14 +0000 (15:48 +0100)]
Cache evaluation score in qsearch

Instead of just drop evaluation score after stand pat
logic save it in TT so to be reused if the same position
occurs again.

Note that we NEVER use the cached value apart to avoid an
evaluation call, in particulary we never return to caller
after a succesful tt hit.

To accomodate this a new value type VALUE_TYPE_EVAL has been
introduced so that ok_to_use_TT() always returns false.

With this patch we cut about 15% of total evaluation calls.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoLet to toggle dynamic LMR
Marco Costalba [Tue, 24 Mar 2009 13:34:46 +0000 (14:34 +0100)]
Let to toggle dynamic LMR

It is now disabled by default due to bad results
against a pool of engines...more testing is needed tough.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoIn qsearch update TT only if returning from stand pat
Marco Costalba [Tue, 24 Mar 2009 10:26:43 +0000 (11:26 +0100)]
In qsearch update TT only if returning from stand pat

This is the only "correct" exact value we can store.

Otherwise there could be spurious failed high/low nodes.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoWhen asked for position key print it as an hex value
Marco Costalba [Tue, 24 Mar 2009 09:50:13 +0000 (10:50 +0100)]
When asked for position key print it as an hex value

Merged from Glaurung current development snapshot.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoWait at least until iteration 3 before to stop the search
Marco Costalba [Tue, 24 Mar 2009 09:49:02 +0000 (10:49 +0100)]
Wait at least until iteration 3 before to stop the search

It was 2 before.

Merged from Glaurung current development snapshot.

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