stockfish
9 years agoAdd a MovePicker c'tor specialized for qsearch
Marco Costalba [Sun, 23 Jan 2011 21:59:05 +0000 (22:59 +0100)]
Add a MovePicker c'tor specialized for qsearch

This simple patch shows a speed increase of
more then 2% !

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoIntroduce and use qsearch_scoring()
Marco Costalba [Sun, 23 Jan 2011 09:19:30 +0000 (10:19 +0100)]
Introduce and use qsearch_scoring()

Move qsearch scoring functionality out of RootMoveList
initialization. Will be needed by future patches.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRetire InitialDepth
Marco Costalba [Sun, 23 Jan 2011 09:52:51 +0000 (10:52 +0100)]
Retire InitialDepth

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoPass TT move instead of Rml[0].pv[0] to MovePicker
Marco Costalba [Sun, 23 Jan 2011 07:59:16 +0000 (08:59 +0100)]
Pass TT move instead of Rml[0].pv[0] to MovePicker

This is used for secondary scoring so it does not
changes the fact that Rml[0].pv[0] is always tried
as first anyhow.

It happens this is even a no functional change patch
becuase we reinsert PV in TT after a search so that
TT move is actually Rml[0].pv[0].

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoDifferent searchedMoves system
Joona Kiiski [Sun, 16 Jan 2011 23:29:44 +0000 (01:29 +0200)]
Different searchedMoves system

After 8751 games on russian cluster
Mod- Orig: 1426 - 1323 - 6002  ELO +4 (+- 2.9) LOS 86%

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRemove special Root cases
Marco Costalba [Sun, 23 Jan 2011 07:36:12 +0000 (08:36 +0100)]
Remove special Root cases

So to better spot where the differences really
count. Also add some more additional cleanup.

Harmless functional change and no regression.

After 5780 games
Mod- Orig: 931 - 955 - 3894 ELO -1 (+- 3.6)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRetire init_ss_array()
Marco Costalba [Thu, 20 Jan 2011 08:05:52 +0000 (09:05 +0100)]
Retire init_ss_array()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoSmall cleanup in init_sliding_attacks()
Marco Costalba [Wed, 19 Jan 2011 16:48:05 +0000 (17:48 +0100)]
Small cleanup in init_sliding_attacks()

No functional change both in 32 and 64 bits.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoNumbers formatting in bitboard.cpp
Marco Costalba [Wed, 19 Jan 2011 16:00:48 +0000 (17:00 +0100)]
Numbers formatting in bitboard.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoUse opposite_color_squares() instead of same_color_squares()
Marco Costalba [Wed, 19 Jan 2011 12:43:07 +0000 (13:43 +0100)]
Use opposite_color_squares() instead of same_color_squares()

It is almost alwasy the requested test and is a bit faster too.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRetire RelativeRankBB[]
Marco Costalba [Wed, 19 Jan 2011 11:20:06 +0000 (12:20 +0100)]
Retire RelativeRankBB[]

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRetire some unused functions in bitboard.h
Marco Costalba [Wed, 19 Jan 2011 09:53:47 +0000 (10:53 +0100)]
Retire some unused functions in bitboard.h

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix some warnings under icc
Marco Costalba [Tue, 18 Jan 2011 17:35:20 +0000 (18:35 +0100)]
Fix some warnings under icc

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoSort root moves moves in MovePickerExt
Marco Costalba [Tue, 18 Jan 2011 08:18:34 +0000 (09:18 +0100)]
Sort root moves moves in MovePickerExt

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix a (bestValue == -VALUE_INFINITE) assert
Marco Costalba [Tue, 18 Jan 2011 06:34:36 +0000 (07:34 +0100)]
Fix a (bestValue == -VALUE_INFINITE) assert

In case of a Root node we can leave with bestValue set
to -VALUE_INFINITE if search is stopped by the GUI and
stopReques flag is raised.

This patch fixes the issue.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoAdditional cleanup in id_loop()
Marco Costalba [Mon, 17 Jan 2011 18:02:50 +0000 (19:02 +0100)]
Additional cleanup in id_loop()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoUse a global RootMoveList object instead of a pointer
Marco Costalba [Mon, 17 Jan 2011 17:41:26 +0000 (18:41 +0100)]
Use a global RootMoveList object instead of a pointer

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoMove globals to id_loop()
Marco Costalba [Mon, 17 Jan 2011 09:44:00 +0000 (10:44 +0100)]
Move globals to id_loop()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoIntroduce and use MovePickerExt
Marco Costalba [Sun, 16 Jan 2011 22:40:06 +0000 (23:40 +0100)]
Introduce and use MovePickerExt

A bit of template magic to restore a proper and readable moves
'while' loop that now is again 'similar' to the one that used
to be in search().

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoUnify root_search() step 3
Marco Costalba [Sun, 16 Jan 2011 12:41:57 +0000 (13:41 +0100)]
Unify root_search() step 3

Retire root_search()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoUnify root_search() step 2
Marco Costalba [Sun, 16 Jan 2011 12:38:05 +0000 (13:38 +0100)]
Unify root_search() step 2

Enable the change: now we use search() instead of root_search()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoUnify root_search() step 1
Marco Costalba [Sun, 16 Jan 2011 11:02:32 +0000 (12:02 +0100)]
Unify root_search() step 1

Teach search() to behave as a root node if requested.
Just added code, but still no functional change.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix very theoretical History corner case
Joona Kiiski [Mon, 17 Jan 2011 13:20:05 +0000 (15:20 +0200)]
Fix very theoretical History corner case

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoSync root_search() with search()
Marco Costalba [Sun, 16 Jan 2011 11:34:47 +0000 (12:34 +0100)]
Sync root_search() with search()

This will let unification easier.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoMove fail loops out of root_search() to id_loop()
Marco Costalba [Tue, 11 Jan 2011 08:56:47 +0000 (09:56 +0100)]
Move fail loops out of root_search() to id_loop()

And sync root_search() with search()

After 9384 games Mod - Orig:
1532 - 1433 - 6419  ELO +3 (+- 2.8)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoLast touches in history.h
Marco Costalba [Sat, 15 Jan 2011 13:58:25 +0000 (14:58 +0100)]
Last touches in history.h

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix a warning with __popcnt64() intrinsics
Marco Costalba [Sat, 15 Jan 2011 11:05:31 +0000 (12:05 +0100)]
Fix a warning with __popcnt64() intrinsics

Returns an int64_t while we want a simple int.

This occurs only when compiling with MSVC on a 64 bit platform.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoPartially restore HistoryMax
Marco Costalba [Sat, 15 Jan 2011 10:21:00 +0000 (11:21 +0100)]
Partially restore HistoryMax

Should be not useful but better safe than sorry.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoMove Min() and Max() macros to types.h
Marco Costalba [Sat, 15 Jan 2011 09:47:11 +0000 (10:47 +0100)]
Move Min() and Max() macros to types.h

As usual a bit of cleanup while there...

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoClarify we want Score and Value to be integers
Marco Costalba [Sat, 15 Jan 2011 09:13:26 +0000 (10:13 +0100)]
Clarify we want Score and Value to be integers

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRetire history.cpp
Marco Costalba [Sat, 15 Jan 2011 08:49:03 +0000 (09:49 +0100)]
Retire history.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRetire HistoryMax
Marco Costalba [Sat, 15 Jan 2011 08:30:07 +0000 (09:30 +0100)]
Retire HistoryMax

Infact we don't use it anymore already.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoSet HistoryMax infinitely high
Joona Kiiski [Sun, 9 Jan 2011 16:38:55 +0000 (18:38 +0200)]
Set HistoryMax infinitely high

Respin this old idea. Earlier we tried only
with < 1000 games and result was inconclusive.

After 5845 games
Mod vs Orig: 935 - 936 - 3974 ELO (+-3.6)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoSimplify from_fen()
Marco Costalba [Fri, 14 Jan 2011 08:20:23 +0000 (09:20 +0100)]
Simplify from_fen()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoInitialize killers at ss+2 also in root_search()
Marco Costalba [Wed, 5 Jan 2011 09:08:25 +0000 (10:08 +0100)]
Initialize killers at ss+2 also in root_search()

After 4955 games:
Mod - Orig: 786 - 768 - 3401 +1 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix an hang on 32 bits while allocating big TT table
Marco Costalba [Thu, 13 Jan 2011 18:25:42 +0000 (19:25 +0100)]
Fix an hang on 32 bits while allocating big TT table

If size_t is defined as a 32 bit quanitity then we have an
overflow in the left term of the while condition if mbSize
is bigger then 2048.

For instance if mbSize is 2049 then when newSize will reach
0x80000000 (2048MB) comparison is still true, 'while' loops
again and we have an overflow in the expression (2*newSize)
so that result is 0 and at that point 'while' keeps looping
forever hanging the application.

This patch fixes the bug and also makes operator new do not
throw an exception upon failure but return a NULL pointer
instead.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoSet unbuffered I/O also for C standard library
Marco Costalba [Tue, 11 Jan 2011 15:22:12 +0000 (16:22 +0100)]
Set unbuffered I/O also for C standard library

In input_available() we use function select(), so
we have to set as unbuffered also C library I/O
functions otherwise we can miss some input.

For instance in case GUI sends "go infinite\nstop\n" we
parse the "go infinite" but then input_available() under Linux
is unable to detect that we still have "stop" to be processed.

This is because "select" uses file descriptors instead of file
pointers. So it cannot know about the buffer associated to a file
pointer.

This patch, by BB+, should fix the problem.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoBig book.cpp cleanup
Marco Costalba [Mon, 10 Jan 2011 08:41:26 +0000 (09:41 +0100)]
Big book.cpp cleanup

Better document PolyGlot formats and greatly
reduce line count.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoCompile fix in types.h
Marco Costalba [Mon, 10 Jan 2011 08:40:32 +0000 (09:40 +0100)]
Compile fix in types.h

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoSmall cleanup in execute_uci_command()
Marco Costalba [Sun, 9 Jan 2011 14:57:18 +0000 (15:57 +0100)]
Small cleanup in execute_uci_command()

With a little fall out in siblings functions...

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoSimplify set_option()
Marco Costalba [Sun, 9 Jan 2011 13:45:49 +0000 (14:45 +0100)]
Simplify set_option()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoTTEntry simplification
Joona Kiiski [Sat, 8 Jan 2011 11:34:29 +0000 (13:34 +0200)]
TTEntry simplification

Now that move is fitted in 16 bits we can simplify TTEntry.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoDon't copy Position in pretty_pv()
Marco Costalba [Sun, 9 Jan 2011 10:22:59 +0000 (11:22 +0100)]
Don't copy Position in pretty_pv()

Also let do_setup_move() don't reuse same StateInfo so that
we can remove the check about different StateInfo objects
before memcpy() in do_move.

Functional change due to harmless additionals
do_move() / undo_move() steps.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoMerge line_to_san() into pretty_pv()
Marco Costalba [Sat, 8 Jan 2011 17:31:14 +0000 (18:31 +0100)]
Merge line_to_san() into pretty_pv()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRessurect move.cpp
Marco Costalba [Sat, 8 Jan 2011 16:34:17 +0000 (17:34 +0100)]
Ressurect move.cpp

Actually it is san.cpp renamed. Because now has the move
conversions functions and doesn't have any more the bulky
move_from_san(), it is better to call it move.cpp

Remove san.h while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix build failure under Linux
Joona Kiiski [Sat, 8 Jan 2011 15:23:02 +0000 (17:23 +0200)]
Fix build failure under Linux

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRetire move_from_san()
Marco Costalba [Sat, 8 Jan 2011 15:23:46 +0000 (16:23 +0100)]
Retire move_from_san()

It is unused and it is big.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoGreatly simplify move_from_uci()
Marco Costalba [Sat, 8 Jan 2011 15:00:22 +0000 (16:00 +0100)]
Greatly simplify move_from_uci()

Use a reverse logic: among the list of generated legal moves
transformed in UCI coordinate notation find the one that
matches the given string.

It is a bit slower, but here is not performance critical and
is much more simplified then before.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoMove uci move parsing under san.cpp
Marco Costalba [Sat, 8 Jan 2011 14:53:08 +0000 (15:53 +0100)]
Move uci move parsing under san.cpp

This partially reverts 1e7aaed8bc keeping the conversion
functions from/to move to uci string in the same file.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoChange Emergency time maximum from 60000 to 30000
Joona Kiiski [Fri, 7 Jan 2011 22:13:22 +0000 (00:13 +0200)]
Change Emergency time maximum from 60000 to 30000

I got report from Werner that Shredder Gui has problems with
UCI values which maximum value is greater than 30000.

Of course it's stupid to change engine to fix a GUI's bug,
but on the other hand 30000 ms as maximum value is clearly enough,
so why not to be merciful

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix Makefile's GPL-notice to be similar to other files
Joona Kiiski [Fri, 7 Jan 2011 22:12:26 +0000 (00:12 +0200)]
Fix Makefile's GPL-notice to be similar to other files

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoImprove I/O responsivness
Marco Costalba [Sat, 8 Jan 2011 13:16:04 +0000 (14:16 +0100)]
Improve I/O responsivness

Added checking of (stdin->_cnt > 0) from Greko.

This seems to greatly improve responsivness when running
under console. Now while running a 'stockfish bench', any key
press immediately is detected by SF while before there was a
delay of some fraction of a second.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix reading a book under-promotion move
Marco Costalba [Sat, 8 Jan 2011 12:06:51 +0000 (13:06 +0100)]
Fix reading a book under-promotion move

This is an old Glaurung bug that prevented a Polyglot
book move to be read correctly in case of underpromotion.

This patch fixes the bug restoring support for both
queen and underpromotions.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoTriviality in data_available()
Marco Costalba [Sat, 8 Jan 2011 11:53:41 +0000 (12:53 +0100)]
Triviality in data_available()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoForce inlining of move generation functions
Marco Costalba [Fri, 7 Jan 2011 15:33:15 +0000 (16:33 +0100)]
Force inlining of move generation functions

MSVC (and possibly other compilers) does not inline
as requested, so force it to do so.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoSmall tweak to generate_castle_moves()
Marco Costalba [Fri, 7 Jan 2011 14:17:28 +0000 (15:17 +0100)]
Small tweak to generate_castle_moves()

Move the castling condition test out of the
function. This avoids a function call most of
the times.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoUnify move generation
Marco Costalba [Wed, 5 Jan 2011 18:47:01 +0000 (19:47 +0100)]
Unify move generation

Functional change due only to moves reorder. Anyhow after
5242 games at 15"+0.1 TC verified we have no regression.

Mod vs Orig 994 - 958 - 3290 +2 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoTempletize move generation API
Marco Costalba [Wed, 5 Jan 2011 18:00:30 +0000 (19:00 +0100)]
Templetize move generation API

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRetire move.cpp
Marco Costalba [Fri, 7 Jan 2011 12:00:25 +0000 (13:00 +0100)]
Retire move.cpp

Move its functions where they belong.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoUse 16 bits to store a move instead of 17
Marco Costalba [Fri, 7 Jan 2011 10:50:38 +0000 (11:50 +0100)]
Use 16 bits to store a move instead of 17

Shrink of 1 bit so to fit a move in an uint_16 and
possibly a MoveStack in an uint_32.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoUse a 32 bit bitwise 'and' in SimpleHash lookup
Marco Costalba [Fri, 7 Jan 2011 10:10:20 +0000 (11:10 +0100)]
Use a 32 bit bitwise 'and' in SimpleHash lookup

A bit faster on 32 bits machines, more similar to
TranspositionTable::first_entry() and same result.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoIntroduce SimpleHash class
Marco Costalba [Fri, 7 Jan 2011 09:34:16 +0000 (10:34 +0100)]
Introduce SimpleHash class

And use it for pawns and material infos.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoSmall tidy up of inttypes for Windows
Marco Costalba [Thu, 6 Jan 2011 22:25:21 +0000 (23:25 +0100)]
Small tidy up of inttypes for Windows

There was a strange "int16" type and "int64_t"
was defined twice.

Spotted by Joona.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoSimplify 50 move rule condition
Joona Kiiski [Thu, 6 Jan 2011 13:21:30 +0000 (15:21 +0200)]
Simplify 50 move rule condition

We never reach a position where rule50 > 100.
When rule50 == 100, it's either draw or mate and
there is no way search could go deeper.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoClean up position setup code
Joona Kiiski [Thu, 6 Jan 2011 11:34:16 +0000 (13:34 +0200)]
Clean up position setup code

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoParse halfmove clock and fullmove number from FEN
Joona Kiiski [Thu, 6 Jan 2011 10:13:28 +0000 (12:13 +0200)]
Parse halfmove clock and fullmove number from FEN

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoMinimal restructuring of value.h
Joona Kiiski [Thu, 6 Jan 2011 09:15:10 +0000 (11:15 +0200)]
Minimal restructuring of value.h

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoDo not make any assumption on the move in move_is_legal()
Marco Costalba [Thu, 6 Jan 2011 12:33:40 +0000 (13:33 +0100)]
Do not make any assumption on the move in move_is_legal()

We must be able to filter out also moves where move_is_ok()
is false.

And actually we are. Tested on all the default position injecting
a number from -1000000 to 1000000 casted to a Move.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoChange move_is_ok() and square_is_ok() in something useful
Marco Costalba [Thu, 6 Jan 2011 09:32:27 +0000 (10:32 +0100)]
Change move_is_ok() and square_is_ok() in something useful

As is defined now is always true, tested with:

  for (long i=-1000000; i < 1000000; i++)
      if (!move_is_ok(Move(i)))
          exit(0);

Reason is that move_from() and move_to() already truncate the
input value to something in the range [0, 63] that is always
a possible square.

So change definition to something useful.

The same applies also to square_is_ok()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoImprove update_killers() signature
Marco Costalba [Thu, 6 Jan 2011 08:09:53 +0000 (09:09 +0100)]
Improve update_killers() signature

Will be used by future patches and is cleaner.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix variable naming in prototypes at uci.cpp
Joona Kiiski [Wed, 5 Jan 2011 22:34:51 +0000 (00:34 +0200)]
Fix variable naming in prototypes at uci.cpp

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRemove a false comment
Joona Kiiski [Wed, 5 Jan 2011 22:16:33 +0000 (00:16 +0200)]
Remove a false comment

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoSet moveCount base to 1 as in search()
Marco Costalba [Wed, 5 Jan 2011 12:39:31 +0000 (13:39 +0100)]
Set moveCount base to 1 as in search()

Now first move has moveCount == 1 also in root_search()

Also added small readibility touches.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoUse killers also in root_search()
Marco Costalba [Tue, 4 Jan 2011 10:43:20 +0000 (11:43 +0100)]
Use killers also in root_search()

After 4238 games
Mod-Orig 800 - 686 - 2752 +9 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoPerft should return an int64_t not an int
Marco Costalba [Wed, 5 Jan 2011 16:03:57 +0000 (17:03 +0100)]
Perft should return an int64_t not an int

Found by Louis Zulli with his super fast
hardware: 65M nodes/sec at perft !

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix POPCNT support for Intel compiler under Windows
Marco Costalba [Wed, 5 Jan 2011 10:02:05 +0000 (11:02 +0100)]
Fix POPCNT support for Intel compiler under Windows

Reported by Martin Wyngaarden that also confirmed
this patch to work.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoEsplicitly inline generate_piece_moves() & friends
Marco Costalba [Wed, 5 Jan 2011 08:49:58 +0000 (09:49 +0100)]
Esplicitly inline generate_piece_moves() & friends

Should be already inlined by the compiler when
optimizing but better safe than sorry ;-)

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoUse 'moveCount' name also in RootSearch
Marco Costalba [Tue, 4 Jan 2011 10:35:54 +0000 (11:35 +0100)]
Use 'moveCount' name also in RootSearch

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoUse -O3 instead of -fast for Linux icc
Marco Costalba [Tue, 4 Jan 2011 10:09:35 +0000 (11:09 +0100)]
Use -O3 instead of -fast for Linux icc

Reported by Heinz and confirmed by Joona to increase
the speed of 6% !

No change for icc on OSX

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoAnother round of bitboard.cpp cleanups
Marco Costalba [Mon, 3 Jan 2011 10:50:41 +0000 (11:50 +0100)]
Another round of bitboard.cpp cleanups

Also renamed StepAttackBB[] in NonSlidingAttacksBB[]

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRestore development version
Marco Costalba [Tue, 4 Jan 2011 08:55:17 +0000 (09:55 +0100)]
Restore development version

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoStockfish 2.0.1
Marco Costalba [Tue, 4 Jan 2011 07:24:05 +0000 (08:24 +0100)]
Stockfish 2.0.1

Always same siganture: 7224363

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoUpdate Readme and polyglot files
Marco Costalba [Mon, 3 Jan 2011 22:55:12 +0000 (23:55 +0100)]
Update Readme and polyglot files

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoAnother attempt at fixing Chess960
Marco Costalba [Mon, 3 Jan 2011 11:50:49 +0000 (12:50 +0100)]
Another attempt at fixing Chess960

Keep the isChess960 flag inside Position so that is
copied with the Position, but esplicitly highlight the
fact that a FEN string has not enough information to detect
Chess960 in general case. To do this add a boolean argument
isChess960 to from_fen() function so to self document this
shortcoming of FEN notation.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRevert Chess960 fix
Marco Costalba [Mon, 3 Jan 2011 21:31:17 +0000 (22:31 +0100)]
Revert Chess960 fix

Will be substituted by a better next patch.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoReintroduce the old "trapped bishop in the corner" evaluation term
Tord Romstad [Mon, 3 Jan 2011 21:32:57 +0000 (22:32 +0100)]
Reintroduce the old "trapped bishop in the corner" evaluation term
for Chess960 games.

After 1918 games at 30"
Mod - Orig: 1052-866 (+532,-346,=1040), Elo +33.8

9 years agoUse simple macro to enable operators
Joona Kiiski [Mon, 3 Jan 2011 14:09:38 +0000 (16:09 +0200)]
Use simple macro to enable operators

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoWorkaround broken function-style cast support in HP-UX
Marco Costalba [Mon, 3 Jan 2011 10:36:32 +0000 (11:36 +0100)]
Workaround broken function-style cast support in HP-UX

It seems HP's ANSI C++ doesn't understand very well
standard function-style cast.

Reported by Richard Lloyd.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoReadd SRWLOCK and Condition Variables under Windows
Marco Costalba [Mon, 3 Jan 2011 09:49:33 +0000 (10:49 +0100)]
Readd SRWLOCK and Condition Variables under Windows

And set them as default.

Introduce compile switch OLD_LOCKS to allow to fallback on
compatible locks supported by Windows XP and older versions.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix Chess960 regression
Marco Costalba [Sun, 2 Jan 2011 23:35:05 +0000 (00:35 +0100)]
Fix Chess960 regression

Introduced by me in before 1.9 and found by Tord that says:

The 'isChess960' slot in the 'Position' class is currently
set depending on the initial files of the rooks, and not on the value
of the UCI_Chess960 parameter. This is incorrect, as there are lots of
Chess960 positions where the rooks start on the usual files. As a
consequence (unless I am missing something), Stockfish will occasionally
output castling moves as e1g1/e1c1 rather than the correct e1h1/e1a1 format
in Chess960 games. It is possible that some or even most GUIs are robust
enough to accept both notations, but I wouldn't bet on it. And in any case,
Stockfish's behavior clearly violates the protocol.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoAnother (final?) attempt at squares_delta()
Marco Costalba [Sun, 2 Jan 2011 10:45:03 +0000 (11:45 +0100)]
Another (final?) attempt at squares_delta()

This time I have removed the function alltogether !

Sorry to work above a patch of UncombedCoconut (Justin Blanchard)
but I couldn't resist ;-)

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix old Glaurung bug related to search logging
Marco Costalba [Sun, 2 Jan 2011 10:21:37 +0000 (11:21 +0100)]
Fix old Glaurung bug related to search logging

When we log best and ponder move to a file before to
return from think we change the position. If position is
then not resended by GUI, as for manual user input we got
an error:

justinb@malibu:~$ stockfish
Stockfish 2.0 JA 64bit by Tord Romstad, Marco Costalba, Joona Kiiski
setoption name Use Search Log value true
go depth 1
info depth 1
info depth 1 seldepth 1 multipv 1 score cp 72 time 59 nodes 20 nps 338 pv g1f3
info depth 2
info depth 2 seldepth 2 multipv 1 score cp 12 time 59 nodes 44 nps 745 pv g1f3 g8f6
info nodes 84 nps 1423 time 59
bestmove g1f3 ponder g8f6
go depth 1
info depth 1 score mate 0
info nodes 87 nps 0 time 0
bestmove (none) ponder (none)

Bug spotted and fixed by UncombedCoconut.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoSimplify squares_delta()
Marco Costalba [Sun, 2 Jan 2011 09:41:05 +0000 (10:41 +0100)]
Simplify squares_delta()

And rename in ray_direction()

Patch from UncombedCoconut.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix a crash on multi-pv
Marco Costalba [Sat, 1 Jan 2011 22:10:37 +0000 (23:10 +0100)]
Fix a crash on multi-pv

Bug reported by Tobias Haspel and fixed by Joona.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRestore development version
Marco Costalba [Sat, 1 Jan 2011 11:28:33 +0000 (12:28 +0100)]
Restore development version

And set "Use Sleeping Threads" to true because it keeps
much more responsive and cool my QUAD during tests :-)

It will be reverted back before to release that's the
reason to bundle it here.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoStockfish 2.0 (take 2)
Marco Costalba [Sat, 1 Jan 2011 15:08:55 +0000 (16:08 +0100)]
Stockfish 2.0 (take 2)

Always same siganture: 7224363

Hopefully some more bug fixed and restored
compatibility with WIndows XP.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoDon't use SRWLOCK and Condition Variables under Windows
Marco Costalba [Sat, 1 Jan 2011 14:49:26 +0000 (15:49 +0100)]
Don't use SRWLOCK and Condition Variables under Windows

They are not compatible with Windows XP

Revert to old CRITICAL_SECTION locks and events.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix an off-by-one bug in sort_multipv()
Marco Costalba [Sat, 1 Jan 2011 14:07:45 +0000 (15:07 +0100)]
Fix an off-by-one bug in sort_multipv()

Second parameter of insertion_sort() is a pointer to the
element _after_ the last of the list, e.g. end() when sorting
all items.

If we want to sort say the first 2 moves we should write:

sort_multipv(2);

So, becuase in root moves loop move counter 'i' starts
from 0, we need to pass:

sort_multipv(i+1);

To sort up to move 'i' included.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoRemove artificial Iteration >= 3 constraint on time manager
Marco Costalba [Sat, 1 Jan 2011 13:13:15 +0000 (14:13 +0100)]
Remove artificial Iteration >= 3 constraint on time manager

It doesn't seem to have any meaning.

Also add a FIXME on the MaxNodes condition that now is broken
in SMP case due to known issue with pos.nodes_searched()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
9 years agoFix: Honour UCI "quit" command while still in the book
Marco Costalba [Sat, 1 Jan 2011 12:54:44 +0000 (13:54 +0100)]
Fix: Honour UCI "quit" command while still in the book

We were not quitting the engine after a "quit" command
while still in the book and pondering.

No functional change.

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