stockfish
11 years agoOnly on Windows do wait for input at the end of benchmark
Marco Costalba [Sat, 20 Jun 2009 06:58:05 +0000 (07:58 +0100)]
Only on Windows do wait for input at the end of benchmark

Under MS Visual C++ debug window always unconditionally closes
when program exits, this is bad because we want to read results before.

So limit this kludge on Windows only.

Original patch by Heinz van Saanen.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSkip castle rights update when not needed
Marco Costalba [Thu, 18 Jun 2009 13:22:39 +0000 (15:22 +0200)]
Skip castle rights update when not needed

Micro optimization in do_move(), a quick check
avoid us to update castle rights in almost 90%
of cases.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoDisable use of aspiration window in known win positions
Joona Kiiski [Wed, 17 Jun 2009 10:16:51 +0000 (13:16 +0300)]
Disable use of aspiration window in known win positions

When we are hunting for mate, transposition table is filled in
with mate scores. Current implemenatation of aspiration search
can't cope with this very well.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoBugfix: KRK was not classified as KNOWN_WIN
Joona Kiiski [Wed, 17 Jun 2009 08:07:16 +0000 (11:07 +0300)]
Bugfix: KRK was not classified as KNOWN_WIN

Problem is that npMaterial is compared to _endgame_ value
of rook, although npMaterial is always (also in endgame!)
calculated using _middlegame_ values.

Bug was hidden as long as Rook middlegame
and endgame values were same.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoGive proper credit to Joona
Marco Costalba [Wed, 17 Jun 2009 06:59:09 +0000 (08:59 +0200)]
Give proper credit to Joona

Stockfish would not be as where is now without his
contributions.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoJoona tweaks of mobility and outposts bonus
Marco Costalba [Tue, 16 Jun 2009 13:06:26 +0000 (15:06 +0200)]
Joona tweaks of mobility and outposts bonus

These are the tuned values of mobility and outposts
after 100.000 games on Joona QUAD.

After 999 games at 1+0
Mod vs Orig +248 =537 -214 51.70% +12 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix king value in SEE
Marco Costalba [Tue, 16 Jun 2009 18:20:53 +0000 (19:20 +0100)]
Fix king value in SEE

When SEE piece values changed in aaad48464b
of 9/12/2008 we forgot to update the value assigned in
case of captured king.

In that patch we changed the SEE piece values but without
proper testing. Probably it is a good idea to make some
tests with the old Glaurung values.

Bug spotted by Joona.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoReduce SMP contention on TT
Marco Costalba [Sat, 13 Jun 2009 10:13:09 +0000 (11:13 +0100)]
Reduce SMP contention on TT

Move TT object away from heavy write accessed NodesSincePoll
and also, inside TT isolate the heavy accessed writes variable.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoBetter clarify why recent generate_pawn_checks() works
Marco Costalba [Fri, 12 Jun 2009 10:05:48 +0000 (12:05 +0200)]
Better clarify why recent generate_pawn_checks() works

We can have false positives, but these are filtered out
anyhow by following conditions so they are harmless.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoCode style triviality in search.cpp
Marco Costalba [Thu, 11 Jun 2009 13:57:42 +0000 (15:57 +0200)]
Code style triviality in search.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRemove global variables from search.h
Marco Costalba [Thu, 11 Jun 2009 13:11:08 +0000 (15:11 +0200)]
Remove global variables from search.h

Globals are not really needed, so redefine as locals.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMovePicker doesn't need to know if called from a pv node
Marco Costalba [Thu, 11 Jun 2009 09:04:05 +0000 (11:04 +0200)]
MovePicker doesn't need to know if called from a pv node

This was needed by an old optimization in sorting of
non-captures that is now obsoleted by new std::sort()
approach.

Remove also the unused depth member data. Interestingly
this has always been unused since the Glaurung days.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoJoona tweaks of piece-square tables
Marco Costalba [Tue, 9 Jun 2009 10:21:35 +0000 (11:21 +0100)]
Joona tweaks of piece-square tables

These are the tuned psqt values after 100.000 games
on Joona QUAD. Results seem very good.

On PC 1 after 999 games
Mod vs Orig  +261 =511 -227 51.70 %  +12 ELO

On PC 2 after 913 games
Mod vs Orig  +254 =448 -211 52.35 %  +16 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMove initialization of PawnInfo in its c'tor
Marco Costalba [Mon, 8 Jun 2009 11:52:52 +0000 (12:52 +0100)]
Move initialization of PawnInfo in its c'tor

Where it belongs.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMove initialization of MaterialInfo in its c'tor
Marco Costalba [Mon, 8 Jun 2009 10:27:50 +0000 (11:27 +0100)]
Move initialization of MaterialInfo in its c'tor

Where it belongs.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMicro optimize pretty_pv
Marco Costalba [Mon, 8 Jun 2009 09:52:03 +0000 (10:52 +0100)]
Micro optimize pretty_pv

Creating an History object requires clearing the History tables,
although fast is an useless job in san.cpp where History is used
just as a dummy argument for MovePicker c'tor.

So use a file scoped constant instead of creating a new History()
object each time MovePicker c'tor is called as in move_ambiguity()

This optimizes pretty_pv() through the following calling chain:
pretty_pv() -> line_to_san() -> move_to_san() -> move_ambiguity()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoGive credit to Joona for optimized parameters
Marco Costalba [Fri, 5 Jun 2009 12:27:37 +0000 (14:27 +0200)]
Give credit to Joona for optimized parameters

This also allow us to better track what is already
optimized and what still needs optimization.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoUse a specialized function for king evaluation
Marco Costalba [Fri, 5 Jun 2009 10:58:03 +0000 (12:58 +0200)]
Use a specialized function for king evaluation

King evaluation is special in any case and as an added
benefit we can use the HasPopCnt optimization also for king.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSplit evaluate_outposts from evaluate_common
Marco Costalba [Sat, 9 May 2009 21:21:26 +0000 (22:21 +0100)]
Split evaluate_outposts from evaluate_common

This is an old patch, was part of a series, but is
good also alone as a cleanup.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoDocument variables with heavy SMP read access
Marco Costalba [Wed, 3 Jun 2009 08:19:29 +0000 (10:19 +0200)]
Document variables with heavy SMP read access

Also move NodesSincePoll away from the same cache line
of other heavy read accessed only variables.

Fortunatly we don't have anymore write access contention,
but still read access contention in some cases.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRetire UseQSearchFutilityPruning and UseFutilityPruning
Marco Costalba [Wed, 3 Jun 2009 08:00:05 +0000 (10:00 +0200)]
Retire UseQSearchFutilityPruning and UseFutilityPruning

They are always true anyway and are heavy used file scope
variables where there could be SMP contention. Although read only.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoUse one History table per thread
Marco Costalba [Tue, 2 Jun 2009 09:20:41 +0000 (10:20 +0100)]
Use one History table per thread

This reduces contention and reduce history trashing
effect especially at high search depths.

No functional change for single CPU case.

After 999 games at 1+0 on Dual Core Intel we have

Mod vs Orig  +233 =526 -240  -2 ELO

We need to test at longer time controls and possibly with
a QUAD where we could foreseen an improvment.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoConvert History table H in a local variable
Marco Costalba [Tue, 2 Jun 2009 08:57:15 +0000 (09:57 +0100)]
Convert History table H in a local variable

This is a first step for future patches and in
any case seems a nice thing to do.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoAvoid using EmptySearchStack global
Marco Costalba [Tue, 2 Jun 2009 08:35:49 +0000 (09:35 +0100)]
Avoid using EmptySearchStack global

This reduces contention in SMP case and also
cleanups the code a bit.

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoDetach the state when copying a position
Marco Costalba [Fri, 29 May 2009 15:23:21 +0000 (17:23 +0200)]
Detach the state when copying a position

In Position we store a pointer to a StateInfo record
kept outside of the Position object.

When copying a position we copy also that pointer so
after the copy we have two Position objects pointing
to the same StateInfo record. This can be dangerous
so fix by copying also the StateInfo record inside
the new Position object and let the new st pointer
point to it. This completely detach the copied
Position from the original one.

Also rename setStartState() as saveState() and clean up
the API to state more clearly what the function does.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoOrder bad captures by SEE value
Marco Costalba [Thu, 28 May 2009 12:58:35 +0000 (14:58 +0200)]
Order bad captures by SEE value

We have already calculated it, so just sorting the
moves adds a very little overhead.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoPassed pawns evaluation tweak
Marco Costalba [Mon, 25 May 2009 14:48:47 +0000 (15:48 +0100)]
Passed pawns evaluation tweak

Do not penalize if in our adavncing pawn's path there are
non-pawns enemy pieces. Especially if they can be attacked
by us.

Patch is mine, but original idea and also fixing of a first, wrong,
version of the patch is from Eelco de Groot.

Tests with Joona framework seems to confirm patch is good

Results for patch 'disabled'   based on 5776 games: Win percentage:
41.309  (+- 0.526)  [+- 1.053]
Results for patch 'enabled'  based on 6400 games: Win percentage:
42.422  (+- 0.500)  [+- 1.000]

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMerge hardware POPCNT detection and use
Marco Costalba [Mon, 25 May 2009 06:52:59 +0000 (07:52 +0100)]
Merge hardware POPCNT detection and use

Tests on Joona luxury iCore7 QUAD show that speed increase
against standrd 64bit routine is between 3% and 4%.

So it seems a good thing to have. Also the user feedback at
startup regarding the compile and the hardware detection can
be an useful debug tool.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSplit killer moves from non-captures
Marco Costalba [Mon, 25 May 2009 06:49:50 +0000 (07:49 +0100)]
Split killer moves from non-captures

In MovePicker consider killer moves as a separate
phase from non-capture picking.

Note that this change guarantees that killer1 is always
tried before killer2. Until now, because scoring difference
of the two moves was just 1 point, if psqt tables of killer1
gave a lower value then killer2, the latter was tried as first.

After 999 games at 1+0 we have
Mod vs Orig: +245 =527 -227 +6 ELO

Not a lot but patch is anyhow something worth to have.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRevert _BitScanForward64 support
Marco Costalba [Mon, 25 May 2009 06:28:55 +0000 (07:28 +0100)]
Revert _BitScanForward64 support

It shows almost no improvment and adds a good
bunch of complexity.

So remove for now. No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoAdd a bit more pop_1st_bit<HasBSF> conversions
Marco Costalba [Sun, 24 May 2009 09:25:59 +0000 (10:25 +0100)]
Add a bit more pop_1st_bit<HasBSF> conversions

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoUse compiler name lookup to simplify code
Marco Costalba [Sun, 24 May 2009 09:15:23 +0000 (10:15 +0100)]
Use compiler name lookup to simplify code

We don't need different names between a function and a
template. Compiler will know when use one or the other.

This let use restore original count_1s_xx() names instead of
sw_count_1s_xxx so to simplify a bit the code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoEnable _BitScanForward64 in move generation
Marco Costalba [Sun, 24 May 2009 09:07:03 +0000 (10:07 +0100)]
Enable _BitScanForward64 in move generation

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoEnable _BitScanForward64 at runtime
Marco Costalba [Sun, 24 May 2009 08:46:43 +0000 (09:46 +0100)]
Enable _BitScanForward64 at runtime

Only add infrastructure, still disabled.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoPrint info about use of 64bit functions and hardware POPCNT
Marco Costalba [Sat, 23 May 2009 10:42:43 +0000 (11:42 +0100)]
Print info about use of 64bit functions and hardware POPCNT

With this patch at the applications startup a line is printed
with info about use of optimized 64 bit routines and hardware
POPCNT.

Also allow the possibility to disable POPCNT support during
PGO compiles to exercise the fallback software only path.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoFix compile errors under MSVC
Marco Costalba [Thu, 21 May 2009 16:08:34 +0000 (17:08 +0100)]
Fix compile errors under MSVC

Fallback from previous patches.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoForgot two conversion to new POPCNT interface
Marco Costalba [Thu, 21 May 2009 14:50:19 +0000 (16:50 +0200)]
Forgot two conversion to new POPCNT interface

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoAdd temporary debug info on POPCNT support
Marco Costalba [Thu, 21 May 2009 14:42:07 +0000 (16:42 +0200)]
Add temporary debug info on POPCNT support

To be removed before to release.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoEnable POPCNT at runtime
Marco Costalba [Thu, 21 May 2009 14:41:31 +0000 (16:41 +0200)]
Enable POPCNT at runtime

Runtime detect POPCNT instruction support and
use it.

Also if POPCNT is not supported we don't add _any_ overhead so
that we don't lose any speed in standard case.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoIntroduce bitcount.h
Marco Costalba [Thu, 21 May 2009 13:29:28 +0000 (15:29 +0200)]
Introduce bitcount.h

It will be used for POPCNT intrinsics.

For now no bianry and functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoUnify piece_attacks<> for KNIGHT and KING
Marco Costalba [Thu, 21 May 2009 10:15:52 +0000 (12:15 +0200)]
Unify piece_attacks<> for KNIGHT and KING

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoUse do_move_bb() also for en passant moves
Marco Costalba [Thu, 21 May 2009 09:28:51 +0000 (11:28 +0200)]
Use do_move_bb() also for en passant moves

Unfortunatly, due to Chess960 compatibility we cannot
extend also to castling where the destinations squares
are not guaranteed to be empty.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoIntroduce do_move_bb() to update bitboards after a move
Marco Costalba [Thu, 21 May 2009 08:55:23 +0000 (10:55 +0200)]
Introduce do_move_bb() to update bitboards after a move

Avoid a clear_bit() + set_bit() sequence but update bitboards
with only one xor instructions.

This is faster and simplifies the code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoBackup some mor einfo in do_null_move()
Marco Costalba [Thu, 21 May 2009 07:54:48 +0000 (09:54 +0200)]
Backup some mor einfo in do_null_move()

Faster undo_null_move()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoMove npMaterial[2] to StateInfo in Position
Marco Costalba [Thu, 21 May 2009 07:47:03 +0000 (09:47 +0200)]
Move npMaterial[2] to StateInfo in Position

So to have a bit faster undo_move() and also
a code semplification.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoRetire lastMove from Position class
Marco Costalba [Wed, 20 May 2009 13:12:45 +0000 (15:12 +0200)]
Retire lastMove from Position class

Is not used in any way so remove.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSmall code style in headers
Marco Costalba [Wed, 20 May 2009 13:11:41 +0000 (15:11 +0200)]
Small code style in headers

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoDirectly relate HistoryMax to OnePly
Marco Costalba [Wed, 20 May 2009 12:40:50 +0000 (14:40 +0200)]
Directly relate HistoryMax to OnePly

This obsoletes some remainding comments.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSmall code style massage in uci.cpp
Marco Costalba [Wed, 20 May 2009 10:40:07 +0000 (12:40 +0200)]
Small code style massage in uci.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoSpace inflate and cleanup direction.cpp
Marco Costalba [Wed, 20 May 2009 10:02:39 +0000 (12:02 +0200)]
Space inflate and cleanup direction.cpp

Hopefully it is now more clear what's happening here.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
11 years agoReduce history 4 times instead of 2 when reach the maximum
Marco Costalba [Mon, 18 May 2009 07:51:46 +0000 (09:51 +0200)]
Reduce history 4 times instead of 2 when reach the maximum

This gives more weight to newer entries.

After 999 games at 1'+ 0" we have:

Mod vs Orig +233/-208/=558 51.25% +9 ELO

Confirmed by another session of 437 games:

Mod vs Orig +109/-92/=236 51.95% +14 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
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>