]> git.sesse.net Git - stockfish/log
stockfish
12 years agoAdd also logging of std::cin
Marco Costalba [Mon, 19 Mar 2012 20:36:25 +0000 (21:36 +0100)]
Add also logging of std::cin

Some trial was needed to find the correct recipe but now
we log both stdin and stdout to file "io_log.txt".

Link http://spec.winprog.org/streams/ was very useful
to understand the details of iostreams implementation.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoAdd (smart) logging facility
Marco Costalba [Sun, 18 Mar 2012 02:20:43 +0000 (03:20 +0100)]
Add (smart) logging facility

By means of "Use Debug Log" UCI option it is possible to toggle
the logging of std::cout to file "out.txt" while preserving
the usual output to stdout. There is zero overhead when logging
is disabled and we achieved this without changing a single line
of exsisting code, in particular we still use std::cout as usual.

The idea and part of the code comes from this article:
http://groups.google.com/group/comp.lang.c++/msg/1d941c0f26ea0d81

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoShow startup messages immediately
Marco Costalba [Sun, 18 Mar 2012 22:08:37 +0000 (23:08 +0100)]
Show startup messages immediately

In particular before initialization. So that SF
seems more snappy at startup.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRevert to byTypeBB[0] storing occupied squares
Marco Costalba [Sun, 18 Mar 2012 10:33:54 +0000 (11:33 +0100)]
Revert to byTypeBB[0] storing occupied squares

As it was in Glaurung times. Also rearranged order
so that byTypeBB[0] is accessed before byTypeBB[x]
to be more cache friendly. It seems there is even
a small speedup.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRename occupied_squares() to pieces()
Marco Costalba [Sun, 18 Mar 2012 10:10:12 +0000 (11:10 +0100)]
Rename occupied_squares() to pieces()

Also some microoptimizations, were there from ages
but hidden: the renaming suddendly made them visible!

This is a good example of how better naming lets you write
better code. Naming is really a kind of black art!

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoUCI buttons don't need a value
Marco Costalba [Sat, 17 Mar 2012 20:18:02 +0000 (21:18 +0100)]
UCI buttons don't need a value

Take advantage of this to further simplify the code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoDon't use "OwnBook" by default
Marco Costalba [Sat, 17 Mar 2012 12:16:23 +0000 (13:16 +0100)]
Don't use "OwnBook" by default

Stick to UCI protocol that says:

* by default all the opening book handling is done by the GUI,
  but there is an option for the engine to use its own book
  ("OwnBook" option, see below)

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoRetire "ucinewgame" UCI option
Marco Costalba [Sat, 17 Mar 2012 10:24:19 +0000 (11:24 +0100)]
Retire "ucinewgame" UCI option

UCI protocol it is not clear about what the engine
should be supposed to do when "ucinewgame" is
received. Stockfish simply sets the position to
start FEN, but it is redundant becuase the GUI always
resends the position after "ucinewgame" command, so
it seems we can safely ignore that command.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix UCI 'button' options
Marco Costalba [Sat, 17 Mar 2012 09:29:33 +0000 (10:29 +0100)]
Fix UCI 'button' options

When a button fires UCIOption::operator=() is called and from
there the on_change() function. Now it happens that in case of
a button the on_change() function resets option's value to
"false" triggering again UCIOption::operator=() that calls again
on_change() and so on in an endless loop that is experienced
by the user as an application hang.

Rework the button logic to fix the issue and also be more clear
about how button works.

Reported by several people working with Scid and tracked down
to the "Clear Hash" UCI button by Steven Atkinson.

Bug recently introduced by 2ef5b4066e649.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoDon't sync with C library I/O buffers
Marco Costalba [Mon, 12 Mar 2012 14:21:54 +0000 (15:21 +0100)]
Don't sync with C library I/O buffers

Now we are forced to just use C++ iostream becuase
buffers are independent and using C library functions
like printf() or scanf() could yield to issues.

Speed up of about 1%.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoFix time_to_msec() precision
Marco Costalba [Sat, 10 Mar 2012 18:38:56 +0000 (19:38 +0100)]
Fix time_to_msec() precision

Result of t.time * 1000 should be a 64 bit value, not an int.

Bug reported by several users.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
12 years agoIntroduce Eval namespace
Marco Costalba [Tue, 6 Mar 2012 09:09:37 +0000 (10:09 +0100)]
Introduce Eval namespace

Wrap evaluation related stuff and reshuffle
a bit the code.

No functional change.

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

Fine tune newly introduced pinner bonus score:

After 34696 games at 2"+0.05
Mod vs Orig 7474 - 7087 - 20135 ELO +3 (+- 2.4)

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