]> git.sesse.net Git - stockfish/log
stockfish
12 years agoConvert init of eval to async option
Marco Costalba [Mon, 5 Mar 2012 18:24:59 +0000 (19:24 +0100)]
Convert init of eval to async option

So to be done only once at startup and in the (unlikely)
cases that a relevant UCI parameter is changed, instead
of doing it at the beginning of each search.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoAsync UCI options actions
Marco Costalba [Sun, 4 Mar 2012 16:57:01 +0000 (17:57 +0100)]
Async UCI options actions

Introduce 'on change' actions that are triggered as soon as
an UCI option is changed by the GUI. This allows to set hash
size before to start the game, helpful especially on very fast
TC and big TT size.

As a side effect remove the 'button' type option, that now
is managed as a 'check' type.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoUse new Time class in timed_wait()
Marco Costalba [Sat, 3 Mar 2012 17:53:37 +0000 (18:53 +0100)]
Use new Time class in timed_wait()

And simplify the code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoIntroduce single_bit() helper
Marco Costalba [Sun, 4 Mar 2012 22:26:08 +0000 (23:26 +0100)]
Introduce single_bit() helper

Self-documenting code instead of a tricky
bitwise tweak, not known by everybody.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoIntroduce pinning bonus
Marco Costalba [Sat, 25 Feb 2012 11:45:34 +0000 (12:45 +0100)]
Introduce pinning bonus

Add a bonus if a slider is pinning an enemy piece.
Idea from Critter.

After 27443 games at 2"+0.05
Mod vs Orig 5900 - 5518 - 16025 ELO +4 (+- 2.7)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRewrite time measurement code
Marco Costalba [Sat, 3 Mar 2012 08:35:56 +0000 (09:35 +0100)]
Rewrite time measurement code

Introduce and use a new Time class designed after
QTime, from Qt framework. Should be a more clear and
self documented code.

As an added benefit we now use 64 bits internally to get
millisecs from system time. This avoids to wrap around
to 0 every 2^32 milliseconds, which is 49.71 days.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoHalve rook on open file bonus for endgame
Marco Costalba [Sun, 8 Jan 2012 08:58:03 +0000 (09:58 +0100)]
Halve rook on open file bonus for endgame

After 42206 fast games TC 2"+0.05
Mod vs Orig 12871 - 16849 - 12486 ELO +3 (+- 2.6)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix a shift overflow warning
Marco Costalba [Mon, 27 Feb 2012 19:30:34 +0000 (20:30 +0100)]
Fix a shift overflow warning

Visual Studio 11 is worried that shift result could
overflow an integer, this is impossible becuase max
value of the shift is 4, but compiler cannot know it.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoMicro-optmize castling moves
Marco Costalba [Mon, 27 Feb 2012 11:11:18 +0000 (12:11 +0100)]
Micro-optmize castling moves

Pre compute castle path so to quickly test
for impeded rule.

This speeds up perft on starting position
of more than 2%.

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRename promotion_piece_type() to promotion_type()
Marco Costalba [Sun, 26 Feb 2012 17:31:02 +0000 (18:31 +0100)]
Rename promotion_piece_type() to promotion_type()

Shorter and equally clear to understand.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoIntroduce another two (bitboard,square) operators
Marco Costalba [Sun, 26 Feb 2012 16:34:24 +0000 (17:34 +0100)]
Introduce another two (bitboard,square) operators

And simplify the code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix MSVC warning on streampos to size_t conversion
Marco Costalba [Sun, 26 Feb 2012 11:04:35 +0000 (12:04 +0100)]
Fix MSVC warning on streampos to size_t conversion

Fix this warning with MSVC 64 bits:

warning C4244: '=' : conversion from 'std::streampos' to 'size_t',
possible loss of data

Point is that std::streampos could be negative, while size_t
is always non-negative.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRetire ss->bestMove
Marco Costalba [Mon, 20 Feb 2012 13:21:25 +0000 (14:21 +0100)]
Retire ss->bestMove

And introduce SPlitPoint bestMove to pass back the
best move after a split point.

This allow to define as const the search stack passed
to split.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoDon't update bestValue in check_is_dangerous()
Marco Costalba [Mon, 20 Feb 2012 13:07:43 +0000 (14:07 +0100)]
Don't update bestValue in check_is_dangerous()

It is a prerequisite for next patch and simplifies
the function. testing at ultra fast TC shows no
regression.

After 24302 games at 2"+0.05
Mod vs Orig 5122 - 5038 - 13872 ELO +1 (+- 2.9)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix a wrong check in pos_is_ok()
Marco Costalba [Mon, 20 Feb 2012 18:32:15 +0000 (19:32 +0100)]
Fix a wrong check in pos_is_ok()

Bug introduced by revision a44c5cf4f77b05a038
of 3/12/2011.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFurther simplify castling rights
Marco Costalba [Mon, 20 Feb 2012 09:23:55 +0000 (10:23 +0100)]
Further simplify castling rights

Reverse the meaning of castleRightsMask[sq] so that now
is stored the castling right that will be removed in
case a move starts from or arrives to sq square. This
allows to simplify the code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoSpread usage of pos.piece_moved()
Marco Costalba [Mon, 13 Feb 2012 08:17:56 +0000 (09:17 +0100)]
Spread usage of pos.piece_moved()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRetire empty_squares()
Marco Costalba [Sun, 19 Feb 2012 10:44:45 +0000 (11:44 +0100)]
Retire empty_squares()

Use ~pos.occupied_squares() instead and avoid to
hide the ~ computation.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoIndex en-passant zobrist keys by file
Marco Costalba [Sun, 19 Feb 2012 10:28:42 +0000 (11:28 +0100)]
Index en-passant zobrist keys by file

Instead of by square. This is a more conventional
approach, as reported also in:

http://chessprogramming.wikispaces.com/Zobrist+Hashing

We shrink zobEp[] from 64 to 8 keys at the cost of an extra
'and 7' at runtime to get the file out of the ep square.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoMove some stuff out of lock protection in split()
Marco Costalba [Sun, 19 Feb 2012 09:32:06 +0000 (10:32 +0100)]
Move some stuff out of lock protection in split()

We shouldn't need lock protection to increment
splitPointsCnt and set curSplitPoint of masterThread.

Anyhow because this code is very tricky and prone to
races bound the change in a single patch.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoMicro-optimize castleRights update
Marco Costalba [Sat, 18 Feb 2012 20:30:33 +0000 (21:30 +0100)]
Micro-optimize castleRights update

When updating castleRights in do_move() perform only one
64bit xor with zobCastle[] instead of two.

The trick here is to define zobCastle[] keys of composite
castling rights as a xor combination of the keys of the
single castling rights, instead of 16 independent keys.

Idea from Critter although implementation is different.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoSmall renaming in Thread struct
Marco Costalba [Sat, 18 Feb 2012 09:57:00 +0000 (10:57 +0100)]
Small renaming in Thread struct

Should be a bit more clear the meaning of the
single variables.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix a race when extracting PV from TT
Marco Costalba [Fri, 17 Feb 2012 19:38:17 +0000 (20:38 +0100)]
Fix a race when extracting PV from TT

Because TT table is shared tte->move() could change
under our feet, in particular we could validate
tte->move() then the move is changed by another
thread and we call pos.do_move() with a move different
from the original validated one !

This leads to a very rare but reproducible crash once
every about 20K games.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoIncrease MAX_PLY from 100 to 256
Marco Costalba [Sat, 18 Feb 2012 09:16:01 +0000 (10:16 +0100)]
Increase MAX_PLY from 100 to 256

There is no need to limit the maximum ply searched to
100, with deep exclusion search extensions we could
reach it even with much smaller search depths.

The only drawback is an increase in stack usage, but
is limited mainly to id_loop(), in particular the
recursive search() functions are not affected.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoMicro-optimize pop_1st_bit() for 32 bits
Marco Costalba [Mon, 13 Feb 2012 08:52:58 +0000 (09:52 +0100)]
Micro-optimize pop_1st_bit() for 32 bits

Small perft speed-up of 2% and also a code
simplification.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoTempletize sliding attacks
Marco Costalba [Sun, 12 Feb 2012 15:02:13 +0000 (16:02 +0100)]
Templetize sliding attacks

No functional change and no speed regression, it seems
to be even a bit faster on MSVC and gcc.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoSpeedup sliders attacks for 32bit CPU
Marco Costalba [Sun, 12 Feb 2012 14:12:01 +0000 (15:12 +0100)]
Speedup sliders attacks for 32bit CPU

Replace a 64 bit 'and' by two 32 bits ones and
use unsigned instead of int.

This simple patch increases perft speed of 6% on
my Intel Core 2 Duo !

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoDon't wake up threads at the beginning of the search
Marco Costalba [Sun, 12 Feb 2012 13:07:21 +0000 (14:07 +0100)]
Don't wake up threads at the beginning of the search

But only when needed, after a split point. This behaviour
does not apply when useSleepingThreads is false, becuase
in this case threads are not woken up at split points so
must be already running.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoDon't reset 50-move counter after castling
Marco Costalba [Sun, 12 Feb 2012 08:59:19 +0000 (09:59 +0100)]
Don't reset 50-move counter after castling

Rule says should be reset only after a capture and/or
a pawn move.

This incredible bug was here since Glaurung times !

Spotted by Kiriakos.

No functional change in the test bench because we
don't reach the 50 moves limits.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoMerge pull request #3 from glinscott/b46bf29
mcostalba [Mon, 6 Feb 2012 05:34:32 +0000 (21:34 -0800)]
Merge pull request #3 from glinscott/b46bf29

Detect stalemate in evaluation

12 years agoSimpler stalemate check.
Gary Linscott [Sun, 5 Feb 2012 19:52:01 +0000 (14:52 -0500)]
Simpler stalemate check.

12 years agoDetect stalemate in KXK endgames
Gary Linscott [Sun, 5 Feb 2012 15:24:53 +0000 (10:24 -0500)]
Detect stalemate in KXK endgames

Also, handle cases where there are 2 bishops of the same color.

12 years agoAdd "Slow Mover" UCI parameter to adjust time management
Marco Costalba [Sat, 4 Feb 2012 09:41:09 +0000 (10:41 +0100)]
Add "Slow Mover" UCI parameter to adjust time management

With default value of 100 no change in regard of current
behaviour. Increasing the value makes SF to think a
longer time for each move. Decreasing the value makes SF
to move faster.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoMove wait_for_stop_or_ponderhit() under Thread
Marco Costalba [Fri, 3 Feb 2012 15:07:13 +0000 (16:07 +0100)]
Move wait_for_stop_or_ponderhit() under Thread

This method belongs to Thread, not to ThreadsManager.

Reshuffle stuff in thread.cpp while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoReduce lock contention in idle_loop
Marco Costalba [Fri, 3 Feb 2012 12:18:51 +0000 (13:18 +0100)]
Reduce lock contention in idle_loop

Release split point lock before to wake up
master thread. This seems to increase speed
in case "sleeping threads" are used:

After 7792 games with 4 threads at very fast TC (2"+0.05)
Mod vs Orig 1722 - 1627 - 4443 ELO +4 (+- 5.1)

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix an alignment warning with MSVC
Marco Costalba [Fri, 3 Feb 2012 07:03:17 +0000 (08:03 +0100)]
Fix an alignment warning with MSVC

The declared alignment is different from the one
in the definition.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix subtle race with slave allocation
Marco Costalba [Mon, 30 Jan 2012 13:09:20 +0000 (14:09 +0100)]
Fix subtle race with slave allocation

When allocating a slave we set both is_searching
and splitPoint under lock protection.

Unfortunatly the order in which the variables are
set is not defined. This article was very clarifying:

http://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming/

So when in idle loop we test for is_searching and then
access splitPoint, it could happen that splitPoint is still
not updated leading to a possible crash.

Fix the race lock protecting splitPoint access.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix bug in useless checks prune
Marco Costalba [Sun, 29 Jan 2012 21:38:08 +0000 (22:38 +0100)]
Fix bug in useless checks prune

With current code we could raise bestValue above beta,
not what is intended for.

Spotted by Richard Vida.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoReformat kpk bitbase
Marco Costalba [Sun, 29 Jan 2012 11:41:50 +0000 (12:41 +0100)]
Reformat kpk bitbase

Simplify and streamline the code. Verified all the
resulting bitbases are not changed.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoDon't log search info after a stop
Marco Costalba [Sun, 29 Jan 2012 10:25:02 +0000 (11:25 +0100)]
Don't log search info after a stop

Fix an issue where the log file stores an incorrect +0.00
eval after a search has been stopped.

Bug reported by Ajedrecista.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoBitwise operator overloads between Bitboard and Square
Marco Costalba [Sun, 29 Jan 2012 08:54:17 +0000 (09:54 +0100)]
Bitwise operator overloads between Bitboard and Square

Yes, we try to be fancy here ;-)

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoReplace clear_bit() with xor_bit()
Marco Costalba [Sun, 29 Jan 2012 08:11:03 +0000 (09:11 +0100)]
Replace clear_bit() with xor_bit()

This allows to retire ClearMaskBB[] and use just
one SquareBB[] array to set and clear a bit.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRename ValueType to Bound
Marco Costalba [Fri, 27 Jan 2012 18:47:56 +0000 (19:47 +0100)]
Rename ValueType to Bound

It is a more conventional and common naming.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoDo not require -lpthread when linking in mingw
Marco Costalba [Fri, 27 Jan 2012 18:41:12 +0000 (19:41 +0100)]
Do not require -lpthread when linking in mingw

With this we should compeltely remove the need
of installing third party POSIX threads library
when compiling with mingw-gcc under Windows.

Spotted by Trung Tu.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRestore LMR depth limit
Marco Costalba [Tue, 24 Jan 2012 06:17:15 +0000 (07:17 +0100)]
Restore LMR depth limit

It is not clear the advantage and we don't want
to risk of introducing regressions on this
very critical parameter. So revert to old limit.

After 16003 games
Mod vs Orig 2496 - 2421 - 11086 ELO +1 (+-3)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoReformat threads code
Marco Costalba [Thu, 26 Jan 2012 22:18:43 +0000 (23:18 +0100)]
Reformat threads code

Apart from some renaming the biggest change
is the retire of split_point_finished()
replaced by slavesMask flags. As a side
effect we now take also split point lock
when allocation available threads.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoUse Windows threads library with mingw
Marco Costalba [Wed, 25 Jan 2012 05:29:30 +0000 (06:29 +0100)]
Use Windows threads library with mingw

Instead of Posix threads. This seems to fix time
losses of the gcc compiled version for Windows.
The patch replaces the MSVC specific _MSC_VER flag
with _WIN32 and _WIN64 that are defined both by
MSVC and mingw-gcc.

Workaround found by Jim Ablett.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoOrder bad captures by MVV/LVA
Marco Costalba [Sat, 21 Jan 2012 19:53:42 +0000 (20:53 +0100)]
Order bad captures by MVV/LVA

Instead of by SEE. Almost no ELO change but it is
a bit easier and is a more natural choice given
that good captures are ordered in the same way.

After 10424 games
Mod vs Orig 1639 - 1604 - 7181 ELO +1 (+-3.8)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRevert "Fix link time optimization gcc option"
Marco Costalba [Mon, 23 Jan 2012 19:47:20 +0000 (20:47 +0100)]
Revert "Fix link time optimization gcc option"

It seems we need to pass the full optimization
flags to the linker otherwise we end up in a
slow compile:

http://lists.debian.org/debian-devel/2011/06/msg00181.html

Regression reported by Benigno Hernandez.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoSimplify locking usage
Marco Costalba [Mon, 23 Jan 2012 14:20:53 +0000 (15:20 +0100)]
Simplify locking usage

pass references (Windows style) instead of
pointers (Posix style) as function arguments.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoSimplify our insertion sort implementation
Marco Costalba [Sun, 22 Jan 2012 21:53:57 +0000 (22:53 +0100)]
Simplify our insertion sort implementation

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix link time optimization gcc option
Auguste Pop [Wed, 4 Jan 2012 10:01:12 +0000 (18:01 +0800)]
Fix link time optimization gcc option

The previous line, LDFLAGS += $(CXXFLAGS), does not make sense, and
breaks profile-build, thus changing it into: LDFLAGS += -flto.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoShrink sequencer table
Marco Costalba [Sun, 22 Jan 2012 13:25:31 +0000 (14:25 +0100)]
Shrink sequencer table

Integrate TT_MOVE step into the first state. This allows to
avoid the first call to next_phase() in case of a TT move.

And use overflow detection instead of the bunch of STOP_XX
states to detect end of moves.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoAssorted code style in movepicker.cpp
Marco Costalba [Sun, 22 Jan 2012 10:57:42 +0000 (11:57 +0100)]
Assorted code style in movepicker.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix incorrect assert(PvNode == (alpha != beta - 1))
Marco Costalba [Sun, 22 Jan 2012 10:33:53 +0000 (11:33 +0100)]
Fix incorrect assert(PvNode == (alpha != beta - 1))

In case of a PvNode could happen that alpha == beta - 1,
for instance in case the same previous node was visited
with same beta during a non-pv search, the node failed low
and stored beta-1 in TT. Then the node is searched again
in PV mode, TT value beta-1 is retrieved and updates alpha
that now happens to be beta-1.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoOrder the recaptures by MVV/LVA
Marco Costalba [Sun, 22 Jan 2012 10:19:44 +0000 (11:19 +0100)]
Order the recaptures by MVV/LVA

Almost no functional change because multiple recaptures
to same square are very rare, but neverthless it seems
the correct thing to do.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRename NON_CAPTURE to QUIET
Marco Costalba [Sat, 21 Jan 2012 17:45:18 +0000 (18:45 +0100)]
Rename NON_CAPTURE to QUIET

It is a more conventional naming and is nicer.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoReshuffle stuff in MovePicker
Marco Costalba [Sat, 21 Jan 2012 22:32:48 +0000 (23:32 +0100)]
Reshuffle stuff in MovePicker

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix ss->currentMove when probcutting
Marco Costalba [Sat, 21 Jan 2012 22:30:56 +0000 (23:30 +0100)]
Fix ss->currentMove when probcutting

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoUse an enum instead of a table as MovePicker sequencer
Marco Costalba [Sat, 21 Jan 2012 12:43:24 +0000 (13:43 +0100)]
Use an enum instead of a table as MovePicker sequencer

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoSync generate_direct_checks() with generate_piece_moves()
Marco Costalba [Sat, 21 Jan 2012 11:07:03 +0000 (12:07 +0100)]
Sync generate_direct_checks() with generate_piece_moves()

They are almost the same, if the function arguments would
have been the same they could even be integrated.

Also a bit of renaming while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoTriviality in SERIALIZE_PAWNS() macro usage
Marco Costalba [Wed, 18 Jan 2012 16:52:55 +0000 (17:52 +0100)]
Triviality in SERIALIZE_PAWNS() macro usage

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRemove unused #include lines
Justin Blanchard [Mon, 16 Jan 2012 20:20:13 +0000 (04:20 +0800)]
Remove unused #include lines

12 years agoFix "go nodes", at least when Threads=1
Justin Blanchard [Fri, 13 Jan 2012 06:33:22 +0000 (14:33 +0800)]
Fix "go nodes", at least when Threads=1

12 years agoDon't allow LMR to fall in qsearch
Marco Costalba [Sun, 15 Jan 2012 08:54:27 +0000 (09:54 +0100)]
Don't allow LMR to fall in qsearch

And increase LMR limit. Tests show no change ELO wise,
but we prefer to take the risk to commit anyhow becuase
is a 'prune reducing' patch.

After 10749 games
Mod vs Orig: 1670 - 1676 - 7403 ELO 0 (+-3.7)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoMicroptimize generation of pawn evasions
Marco Costalba [Tue, 17 Jan 2012 20:31:49 +0000 (21:31 +0100)]
Microptimize generation of pawn evasions

Skip calling promotion generation functions in
the very common case of no possible promotion
evasion. Also retire generate_pawn_captures()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoSimplify pawn captures generation
Marco Costalba [Mon, 16 Jan 2012 13:27:12 +0000 (14:27 +0100)]
Simplify pawn captures generation

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix a (bogus) warning with gcc 4.4
Marco Costalba [Mon, 16 Jan 2012 09:11:52 +0000 (10:11 +0100)]
Fix a (bogus) warning with gcc 4.4

Fix an incorrect warning: 'bm may be used uninitialized'
with the old but still commonly used gcc 4.4

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRetire double-profile-build Makefile target
Marco Costalba [Sun, 15 Jan 2012 16:02:06 +0000 (17:02 +0100)]
Retire double-profile-build Makefile target

Now that we don't support anymore popcount detection
at runtime this target is obsolete.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix gcc name used in Link Time Optimization
Marco Costalba [Sun, 15 Jan 2012 11:50:09 +0000 (12:50 +0100)]
Fix gcc name used in Link Time Optimization

Use $(CXX) instead of assuming compiler name is 'gcc'

Spotted by Louis Zulli.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoMake init_magic() piece agnostic
Marco Costalba [Sun, 15 Jan 2012 07:24:50 +0000 (08:24 +0100)]
Make init_magic() piece agnostic

All the piece dependant data is passed now as
function arguments so that the code is exactly
the same for bishop and rook.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoUnify some template specializations
Marco Costalba [Sat, 14 Jan 2012 22:01:09 +0000 (23:01 +0100)]
Unify some template specializations

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRetire queen_attacks_bb()
Marco Costalba [Sat, 14 Jan 2012 22:00:10 +0000 (23:00 +0100)]
Retire queen_attacks_bb()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoUse 'adjacent' instead of 'neighboring'
Marco Costalba [Sat, 14 Jan 2012 17:03:57 +0000 (18:03 +0100)]
Use 'adjacent' instead of 'neighboring'

It is more correct and specific. Another naming
improvement while reading Critter sources.

No functional changes.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRestore development version
Marco Costalba [Mon, 2 Jan 2012 17:23:05 +0000 (18:23 +0100)]
Restore development version

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoStockfish 2.2.2
Marco Costalba [Thu, 29 Dec 2011 10:09:11 +0000 (11:09 +0100)]
Stockfish 2.2.2

Dedicated to the new Jim's super fast builds ! :-)

stockfish bench signature is: 5447426

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoMove struct RootMove to Search namespace
Marco Costalba [Sat, 14 Jan 2012 12:49:25 +0000 (13:49 +0100)]
Move struct RootMove to Search namespace

And directly pass RootMoves instead of SearchMoves
to main thread. A class declaration is better suited
in a header and slims a bit the fatty search.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoUse a set to store SearchMoves
Marco Costalba [Sat, 14 Jan 2012 10:45:54 +0000 (11:45 +0100)]
Use a set to store SearchMoves

We just need to verify if a legal move is among the
SearchMoves, so we don't need a vector for this.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix a gcc 4.7 warning
Marco Costalba [Fri, 13 Jan 2012 06:56:59 +0000 (07:56 +0100)]
Fix a gcc 4.7 warning

New gcc 4.7 complains about casting a volatile pointer
to void* so assign the variables directly.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoEnable easy move detection only for recaptures
Marco Costalba [Thu, 12 Jan 2012 20:26:25 +0000 (21:26 +0100)]
Enable easy move detection only for recaptures

It could lead to terrible mistakes otherwise, as
it happened during a game on playchess when on
this position (after white's f4):

2q4r/4b1k1/p3rpp1/3np2p/PpNpNP1P/1P1P2PQ/2P1R3/4R1K1 b - - 0 1

SF moves immediately e5xf4 instead of the correct f5.
In general during engine matches it is impossible the
opponent leaves a piece hanging or anyhow starts a
clear losing sequence. So avoid to fall in subtle traps.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoUse operator~ to flip colors and squares
Marco Costalba [Thu, 12 Jan 2012 18:31:18 +0000 (19:31 +0100)]
Use operator~ to flip colors and squares

More natural and nicer. Idea from Critter.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoSmall touches in FEN decoding
Marco Costalba [Thu, 12 Jan 2012 17:12:25 +0000 (18:12 +0100)]
Small touches in FEN decoding

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRetire is_mate()
Marco Costalba [Tue, 10 Jan 2012 10:57:06 +0000 (11:57 +0100)]
Retire is_mate()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoIntroduce piece_moved() to simplify common code
Marco Costalba [Mon, 9 Jan 2012 21:34:00 +0000 (22:34 +0100)]
Introduce piece_moved() to simplify common code

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoUnify PseudoAttacks arrays
Marco Costalba [Mon, 9 Jan 2012 08:48:27 +0000 (09:48 +0100)]
Unify PseudoAttacks arrays

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoUse CheckInfo to generate checks
Marco Costalba [Sun, 8 Jan 2012 14:08:20 +0000 (15:08 +0100)]
Use CheckInfo to generate checks

It should help to avoid recalculating check squares
of sliding attackers for queen when already done for
bishops and rooks. Of course this helps when there are
bishop, rook and queen on the board !

Fixed also a subtle bug (use of same variable b in while
condition and in condition body) introduced recently by
revision d655147e8c that triggers
in case we have at least 2 non-pawn discovered check pieces.
This is very rare that's why didn't show in the node count
verification where we actually have a case of 2 dc pieces
in position 14, but one is a pawn.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoAdd castling to generation of checking moves
Marco Costalba [Sun, 8 Jan 2012 11:08:16 +0000 (12:08 +0100)]
Add castling to generation of checking moves

During generation of non-captures checks (in qsearch)
we don't consider castling moves that give check,
this patch includes also this rare case. Verified with
perft that all the non-capture checks are now generated.

There should be a very little slowdown due to the extra
work, but actually I failed to measure it. I don't expect
any ELO improvment, there is even no functional change on
the standard depth 12 search, it is just to have a correct
move generator.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoLast touches to movegen.cpp
Marco Costalba [Fri, 6 Jan 2012 11:37:33 +0000 (12:37 +0100)]
Last touches to movegen.cpp

The full movegen patch series shows a speed up of almost
6% (!) on perft, and code is much more readable too.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRetire the redundant MV_CHECK
Marco Costalba [Thu, 5 Jan 2012 09:50:51 +0000 (10:50 +0100)]
Retire the redundant MV_CHECK

MV_CHECK is an alias of the more appropiate named
MV_NON_CAPTURE_CHECK so use only the latter.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRetire generate_discovered_checks
Marco Costalba [Thu, 5 Jan 2012 08:27:50 +0000 (09:27 +0100)]
Retire generate_discovered_checks

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRearrange pawn moves generation
Marco Costalba [Wed, 4 Jan 2012 15:40:12 +0000 (16:40 +0100)]
Rearrange pawn moves generation

Functional change due only to rearrangement

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoReshuffle stuff in movegen.cpp
Marco Costalba [Wed, 4 Jan 2012 13:10:53 +0000 (14:10 +0100)]
Reshuffle stuff in movegen.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRetire OLD_LOCKS option
Marco Costalba [Sat, 7 Jan 2012 10:17:10 +0000 (11:17 +0100)]
Retire OLD_LOCKS option

And make CRITICAL_SECTION locks the only option for Windows.
This guarantees backward compatibility with all the Windows
versions (even XP and older) and an hassle free experience
when compiling for Windows. Tests performed by Ingo and
reported on talkchess confirm there is no speed penalty
against the most modern SRW locks:

http://www.talkchess.com/forum/viewtopic.php?t=41835&start=20

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix compile on HP-UX 11's HP's C++
Marco Costalba [Fri, 6 Jan 2012 23:04:08 +0000 (00:04 +0100)]
Fix compile on HP-UX 11's HP's C++

On that platform non-bracketed casting are not supported.

Reported by Richard Lloyd.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRestore development version
Marco Costalba [Mon, 2 Jan 2012 17:23:05 +0000 (18:23 +0100)]
Restore development version

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoStockfish 2.2.1
Marco Costalba [Thu, 29 Dec 2011 10:09:11 +0000 (11:09 +0100)]
Stockfish 2.2.1

Hopefully fixed the "lose on time" issue.

stockfish bench signature is: 5457475

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoExtra time management safety
Marco Costalba [Fri, 6 Jan 2012 09:28:15 +0000 (10:28 +0100)]
Extra time management safety

Further increase safety against time losses. After this
change (tested on LittleBlitzer and cutechess) I had no
more time losses at 2" and 1"+0.02 TC both on Windows
and Linux on more than 10000 games.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoTry hard not to lose on time
Marco Costalba [Mon, 2 Jan 2012 22:40:14 +0000 (23:40 +0100)]
Try hard not to lose on time

We try hard not to lose on time even under extreme
time pressure. We achieve this through 3 different but
coordinated steps:

    1) Increase max frequency of timer events

    2) Quickly return after a stop signal

    3) Take in account timer resolution

With these SF played under LittleBlitzer at 1"+0.02 and 3"+0
without losing on time even one game.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoAvoid a race at thread creation
Marco Costalba [Tue, 3 Jan 2012 20:13:29 +0000 (21:13 +0100)]
Avoid a race at thread creation

Before creating main thread we set its do_sleep flag to true,
then thread is created and it will go to sleep in main_loop()
after resetting do_sleep.

But if after the setting of do_sleep and before its resetting
the UI thread calls start_thinking() it will not wait on:

  if (!asyncMode)
      while (!main.do_sleep)
          cond_wait(&sleepCond, &main.sleepLock);

as it should but will immediately return before the main thread has
started the search. This very rare race show itself during bench,
when the first position is erroneusly skipped so that bench node count
results of 5309038 instead of the correct 5457475.

The patch is somewhat tricky, but is simple and it works!

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoStreamline generation of MV_NON_EVASION
Marco Costalba [Tue, 3 Jan 2012 14:16:01 +0000 (15:16 +0100)]
Streamline generation of MV_NON_EVASION

Small speed-up of 3% in perft.

No functional change.

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