stockfish
10 years agoRetire ThreadsManager::init_hash_tables()
Marco Costalba [Mon, 8 Aug 2011 22:07:09 +0000 (23:07 +0100)]
Retire ThreadsManager::init_hash_tables()

Allocation of pawn and material hash tables should
be strictly bounded to the change of the number of
activeThreads, so move the code inside set_size().

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire Thread::TERMINATED
Marco Costalba [Mon, 8 Aug 2011 20:25:37 +0000 (21:25 +0100)]
Retire Thread::TERMINATED

Use proper way to detect for thread terimnation instead of
our homegrown flag.

It adds more code than it removes and adds also platform specific
code, neverthless I think is the way to go becuase Thread::TERMINATED
flag is intrinsecly racy given that when we raise it thread is still
_not_ terminated nor it can be, and also we don't want to reinvent
the (broken) wheel of thread termination detection when there is
already available the proper one.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire Thread::INITIALIZING
Marco Costalba [Mon, 8 Aug 2011 12:41:58 +0000 (13:41 +0100)]
Retire Thread::INITIALIZING

Was used to prevent issues when creating multiple threads
on Windows, but now it seems we can remove it safely.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoMove idle_loop() under Thread
Marco Costalba [Mon, 8 Aug 2011 11:03:16 +0000 (12:03 +0100)]
Move idle_loop() under Thread

This greatly removes clutter from the difficult idle_loop() function

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoTidy up comments in thread.cpp
Marco Costalba [Mon, 8 Aug 2011 09:53:52 +0000 (10:53 +0100)]
Tidy up comments in thread.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire broken SendSearchedNodes
Marco Costalba [Mon, 8 Aug 2011 09:08:41 +0000 (10:08 +0100)]
Retire broken SendSearchedNodes

Now that we can split at root it happens that SendSearchedNodes
works only once at the end of the iteration, but this is useless
becuase speed info is sent anyhow toghter with the pv line.

So retire for now, waiting to find something SMP compatible.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoSync search() and qsearch() alpha update
Marco Costalba [Sun, 7 Aug 2011 09:29:47 +0000 (10:29 +0100)]
Sync search() and qsearch() alpha update

Change qsearch() to reflect alpha update logic
of search().

To be consistent changed also moves loop condition and
futility pruning condition.

No regression after 5072 games at TC 10"+0.1

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire Thread::BOOKED
Marco Costalba [Sun, 7 Aug 2011 18:56:53 +0000 (19:56 +0100)]
Retire Thread::BOOKED

Start a slave as soon as is allocated.

No functional change with faked split.

Regression tested the full split() series and after
2000 games no regression and no crash.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoFix obey the "maxThreadsPerSplitPoint" setting
Marco Costalba [Sun, 7 Aug 2011 14:15:19 +0000 (15:15 +0100)]
Fix obey the "maxThreadsPerSplitPoint" setting

Spotted by Joona.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoDo not modify alpha in split()
Marco Costalba [Sun, 7 Aug 2011 08:24:40 +0000 (09:24 +0100)]
Do not modify alpha in split()

When calling split or we immediately return because unable to
find available slaves, or we start searching on _all_ the moves
of the node or until a cut-off occurs, so that when returning
from split we immediately leave the moves loop.

Because of this we don't need to change alpha inside split() and
we can use a signature similar to search() so to better clarify
that split() is actually a search on the remaining node's moves.

No functional change with faked split.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoInitialize a new split point out of lock
Marco Costalba [Sat, 6 Aug 2011 18:11:35 +0000 (19:11 +0100)]
Initialize a new split point out of lock

Allocate and initialize a new split point
out of lock becuase modified data is local to
master thread only.

Also better document why we need a lock at
the end of split().

No functional change with faked split.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoUpdate comment on why we call root search with ss+1
Marco Costalba [Sat, 6 Aug 2011 10:19:13 +0000 (11:19 +0100)]
Update comment on why we call root search with ss+1

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoFix an assert when stopping the search
Marco Costalba [Sat, 6 Aug 2011 09:56:06 +0000 (10:56 +0100)]
Fix an assert when stopping the search

When StopRequest is raised we cannot immediately exit the
move loop but first we need to update bestValue so to avoid
assert:

assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoSplit at root!
Joona Kiiski [Sat, 6 Aug 2011 08:43:46 +0000 (09:43 +0100)]
Split at root!

Another great success by Joona !

After 5876 games at 10"+0.1
Mod vs Orig: 1073 - 849 - 3954 ELO +13 (+- 5.2)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoPreparations for splitting at root
Joona Kiiski [Sat, 6 Aug 2011 08:15:46 +0000 (09:15 +0100)]
Preparations for splitting at root

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoSimplify MovePickerExt<>
Marco Costalba [Fri, 5 Aug 2011 06:23:54 +0000 (07:23 +0100)]
Simplify MovePickerExt<>

Now that we don't special case the root moves anymore
we don't need to pass NodeType anymore as template parameter,
a simple bool to detect a SpNode will be enough.

Spotted by Joona.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoFix silly bug in uci loop
Marco Costalba [Fri, 5 Aug 2011 06:15:45 +0000 (07:15 +0100)]
Fix silly bug in uci loop

After issuing "go"-command, at the end of the search
SF shows: "Unknown command: ...".

Spotted by Joona.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoFix a (silly) warning under icc compiler
Marco Costalba [Thu, 4 Aug 2011 09:10:03 +0000 (10:10 +0100)]
Fix a (silly) warning under icc compiler

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoUse std::lexicographical_compare() in UCI options
Marco Costalba [Wed, 3 Aug 2011 13:24:55 +0000 (14:24 +0100)]
Use std::lexicographical_compare() in UCI options

Instead of our home grown function to perform a case
insensitive compare on option names as required by UCI
protocol.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoConsistently set ttMove to Rml.pv[0] in root node
Marco Costalba [Tue, 2 Aug 2011 21:11:19 +0000 (22:11 +0100)]
Consistently set ttMove to Rml.pv[0] in root node

No functional change, but reduce risks of subtle aliasing bugs.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoFix an off-by-one error in UCI print loop
Marco Costalba [Tue, 2 Aug 2011 20:44:22 +0000 (21:44 +0100)]
Fix an off-by-one error in UCI print loop

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRename ok_to_use_TT() in can_return_tt()
Marco Costalba [Tue, 2 Aug 2011 17:49:06 +0000 (18:49 +0100)]
Rename ok_to_use_TT() in can_return_tt()

Seems more appropiate. From Lucas Braesch's DoubleCheck.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoSend PV only for updated lines
Marco Costalba [Tue, 2 Aug 2011 16:59:06 +0000 (17:59 +0100)]
Send PV only for updated lines

It seems FritzGUI already remembers the old lines, so
we just need to update PV info only for the new lines.

Also introduced prevScore field in RootMove to avoid
a bulk copy of Rml.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoSort PV moves always in two steps
Marco Costalba [Tue, 2 Aug 2011 08:53:56 +0000 (09:53 +0100)]
Sort PV moves always in two steps

This should fix following issue:

Suppose the search with MultiPVIteration == 0 returns an exact score

move = Nxf4, score = 100

Now search with MultiPVIteration == 1 and get two scores

move = Qg8, score = 150
move = Ra1, score = 180

If we now reorder all the moves in one step we end up with

pv[0] = Ra1, pv[1] = Qg8

Instead reordering as the current patch we end up in:

pv[0] = Ra1, pv[1] = Nxf4

preserving the first searched move.

No functional change in single PV.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoSmall cleanup of previous patches
Marco Costalba [Tue, 2 Aug 2011 06:50:14 +0000 (07:50 +0100)]
Small cleanup of previous patches

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoReimplement MultiPV mode
Joona Kiiski [Sun, 31 Jul 2011 22:15:11 +0000 (01:15 +0300)]
Reimplement MultiPV mode

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoReimplement support for "searchmoves" option
Joona Kiiski [Sun, 31 Jul 2011 12:18:52 +0000 (15:18 +0300)]
Reimplement support for "searchmoves" option

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRemove now unused RootMove.non_pv_score
Joona Kiiski [Sun, 31 Jul 2011 12:02:36 +0000 (15:02 +0300)]
Remove now unused RootMove.non_pv_score

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoMake root search to use standard MovePicker.
Joona Kiiski [Sat, 30 Jul 2011 21:00:54 +0000 (00:00 +0300)]
Make root search to use standard MovePicker.

This patch temporarily breaks MultiPV and searchmove
features, but they will be re-implemented in future
patches.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoDon't probe TT at RootNode
Joona Kiiski [Thu, 28 Jul 2011 21:02:50 +0000 (00:02 +0300)]
Don't probe TT at RootNode

In that case we should also update RootMoveList to avoid
bogus output

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoFix pretty_pv() output in Chess960
Marco Costalba [Tue, 26 Jul 2011 07:47:20 +0000 (09:47 +0200)]
Fix pretty_pv() output in Chess960

And move it to search.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoFix PV output in Chess960
Joona Kiiski [Sun, 24 Jul 2011 10:56:47 +0000 (11:56 +0100)]
Fix PV output in Chess960

We missed to set chess960 flag into the std::stringstream used to
setup the PV line.

Bug introduced with commit f803f33e6383fea1074aca2cf625983e148a6668
of 30/12/2010 when we started to print PV line into a std::stringstream
instead of directly into cout, where the chess960 flag is correctly set.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoTidy up benchmark.cpp
Marco Costalba [Sun, 24 Jul 2011 07:26:35 +0000 (08:26 +0100)]
Tidy up benchmark.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRename execute_uci_command() to uci_loop()
Marco Costalba [Sun, 24 Jul 2011 06:56:26 +0000 (07:56 +0100)]
Rename execute_uci_command() to uci_loop()

As a side effect now root position can be directly
allocated on the stack and doesn't need to be defined
static anymore.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoUnhide the istringstream behind UCIParser
Marco Costalba [Sun, 24 Jul 2011 06:22:37 +0000 (07:22 +0100)]
Unhide the istringstream behind UCIParser

It is misnamed because it is not a parser, perhaps a
tokenizer, anyhow better call it for what it is, an
input string stream.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoFix startpos_ply_counter() regression
Marco Costalba [Sun, 24 Jul 2011 04:59:16 +0000 (05:59 +0100)]
Fix startpos_ply_counter() regression

Return the correct number of played plies at the end
of the setup moves. Currently it always returns 0 when
starting from start position, like in real games.

We fix this adding st->pliesFromNull that starts from 0
and is incremented after each setup move and is never
reset in the setup phase but only once search is started.

It is an hack because startpos_ply_counter() will return
different values during the search and is correct only
at the beginning of the search.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoUse a circular buffer to keep track of setup states
Marco Costalba [Sat, 23 Jul 2011 11:52:49 +0000 (12:52 +0100)]
Use a circular buffer to keep track of setup states

This fixes a regression on real games due to the fact that
we have some mismatches:

    history[st->gamePly - i] != stp->key

when st->gamePly - i == 0,this is due to a nasty bug I have
introduced when using std::vector<> as StateInfo backup. The
point is that StateInfo keeps inside a pointer to the previous
StateInfo in a kind of linked list. But when std::vector<> is
resized reallocates a larger chunk of memory and moves the
data there so these pointers became stale.

This patch fixes the issue.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoDon't update gamePly after each move
Marco Costalba [Wed, 20 Jul 2011 08:45:40 +0000 (10:45 +0200)]
Don't update gamePly after each move

We just need startup value to calculate available
thinking time. So remove from state.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoUse std::vector<Move> to store UCI search moves
Marco Costalba [Wed, 20 Jul 2011 08:21:41 +0000 (10:21 +0200)]
Use std::vector<Move> to store UCI search moves

Avoid the ugly and anyhow incorrect hard limit on the
maximum number of moves and allow to handle an arbitrary
number of moves to search.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoUse st->gamePly to store fullMoves
Marco Costalba [Wed, 20 Jul 2011 08:01:12 +0000 (10:01 +0200)]
Use st->gamePly to store fullMoves

This allow to retire do_setup_move() and also to simplify
draw detection logic becuase now we always have:

Min(st->rule50, st->gamePly) = st->rule50

This was already true when starting from starting position,
but now is true even when starting from a FEN string because
now we take in account fullmove number in counting gamePly so
that it is always.

st->rule50 <= st->gamePly

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire history[]
Marco Costalba [Mon, 18 Jul 2011 08:20:37 +0000 (10:20 +0200)]
Retire history[]

Use key saved in state instead.

No functional change (in real games) and no speed regression.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoDo not exit early even when seeing mate
Joona Kiiski [Sat, 23 Jul 2011 21:18:28 +0000 (22:18 +0100)]
Do not exit early even when seeing mate

Fixes the reported KNNK ending problem:

http://talkchess.com/forum/viewtopic.php?t=39347

Joona says:

Now I finally had a time to take a look at on this issue.

I've reproduced the problem starting from this position:
1B6/1B2k3/P7/1P3p2/1K6/8/4b3/4b3 w - - 6 85

I made Stockfish play as white and Fruit as black.
I repeated test ten times and once SF was not able to deliver mate.

But I observed several times that SF had reported on last something like mate in 10.
However next time it played move with score mate in 15.

Easiest way to solve the problem is attached as a patch. I tested it several times and SF always
ended up playing the optimal move. Of course the downside is that now delivering mate
takes a bit longer, but IMO it's better to lose once in a while by time in sudden death
game than not being able to deliver simple mate with long time controls.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRevert previous patches due to bug
Marco Costalba [Wed, 20 Jul 2011 02:31:50 +0000 (03:31 +0100)]
Revert previous patches due to bug

We have a bug (possibly because of returning draw from
root move list), it is possible to see when looking at
games with a GUI, we can see rarely but consistently the
score return as #0 for many depths until it comes back to
normal values.

Revert patches until it is not fixed.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoMove the draw check also for qsearch
Joona Kiiski [Mon, 11 Jul 2011 23:00:30 +0000 (02:00 +0300)]
Move the draw check also for qsearch

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoMove draw checks right after doing the move
Joona Kiiski [Mon, 11 Jul 2011 21:09:50 +0000 (00:09 +0300)]
Move draw checks right after doing the move

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoSmall touches in set_option()
Marco Costalba [Sun, 17 Jul 2011 11:26:50 +0000 (12:26 +0100)]
Small touches in set_option()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoValidate input UCI moves
Marco Costalba [Sun, 17 Jul 2011 09:22:08 +0000 (10:22 +0100)]
Validate input UCI moves

Running following command:

  position startpos moves e1e8

Makes SF to assert in debug mode in do_move() but to accept
bad input and continue in release mode where probably it is
going to crash little later.

So validate input before to feed do_move().

Suggestion by Yakovlev Vadim.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRemove some useless include
Marco Costalba [Sat, 16 Jul 2011 21:59:14 +0000 (22:59 +0100)]
Remove some useless include

Spotted by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoDon't need to assert for pos.is_ok() when position is constant
Marco Costalba [Sat, 16 Jul 2011 09:42:27 +0000 (10:42 +0100)]
Don't need to assert for pos.is_ok() when position is constant

It's only necessary to do the checking at the end of every non-const
member (including the constructors and from_fen()) of class Position.
Once the post-condition of every modifier guarantees the class invariant,
we don't need to verify sanity of the position as preconditions for outside
callers such as movegen, search etc. For non-class types such as Move and
Square we still need to assert of course.

Suggested by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoChange hidden checkers API
Marco Costalba [Sat, 16 Jul 2011 08:56:34 +0000 (09:56 +0100)]
Change hidden checkers API

After previous patch is no more needed to pass
the color, becuase it is always the side to move.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoSimplified discovered check connected_moves()
Marco Costalba [Sat, 16 Jul 2011 08:36:03 +0000 (09:36 +0100)]
Simplified discovered check connected_moves()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoSimplify and micro-optimize hidden_checkers()
Marco Costalba [Fri, 15 Jul 2011 21:24:18 +0000 (22:24 +0100)]
Simplify and micro-optimize hidden_checkers()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoNo need to declare default Position c'tor
Marco Costalba [Fri, 15 Jul 2011 20:51:19 +0000 (21:51 +0100)]
No need to declare default Position c'tor

Pointed out by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoFix a warning under MSVC
Marco Costalba [Fri, 15 Jul 2011 11:20:31 +0000 (12:20 +0100)]
Fix a warning under MSVC

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoFix parametrized direction in pawns generation
Marco Costalba [Fri, 15 Jul 2011 09:40:09 +0000 (11:40 +0200)]
Fix parametrized direction in pawns generation

It worked by accident because we always called both directions,
but definition was wrong.

Functional change due to different generation order, but
perft numbers are the correct ones.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoCleanup handling of Delta enums
Marco Costalba [Fri, 15 Jul 2011 09:19:49 +0000 (11:19 +0200)]
Cleanup handling of Delta enums

Ispired by Rein's code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoUse std library to sort moves
Marco Costalba [Thu, 14 Jul 2011 11:12:49 +0000 (12:12 +0100)]
Use std library to sort moves

Functional change due to the fact that now pick_best() is
stable, but should be no change in strenght.

Example code and ideas by Rein Halbersma.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoFix icc's "unreachable code" warning
Marco Costalba [Mon, 11 Jul 2011 10:17:50 +0000 (11:17 +0100)]
Fix icc's "unreachable code" warning

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoTeach to_fen() about Halfmove and Fullmove number
Marco Costalba [Sun, 3 Jul 2011 10:32:34 +0000 (11:32 +0100)]
Teach to_fen() about Halfmove and Fullmove number

And also fix the last '/' at the end of the piece placement field.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoUse MoveList also in Position::move_is_pl_slow()
Marco Costalba [Sun, 3 Jul 2011 09:38:20 +0000 (10:38 +0100)]
Use MoveList also in Position::move_is_pl_slow()

And rename it in Position::move_is_legal()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire move_is_short_castle() and move_is_long_castle()
Marco Costalba [Sun, 3 Jul 2011 09:08:09 +0000 (10:08 +0100)]
Retire move_is_short_castle() and move_is_long_castle()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRestore startpos_ply_counter() instead of full_moves()
Marco Costalba [Sat, 2 Jul 2011 15:15:20 +0000 (16:15 +0100)]
Restore startpos_ply_counter() instead of full_moves()

And pass correct currentPly to TimeManager::init().

This restores old behaviour, in particular now black has
a different timing than white becuase is no more:

currentPly = 2 * fullMoveNumber;

but becomes

2 * (fullMoves - 1) + int(sideToMove == BLACK)

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoIntroduce and use struct MoveList
Marco Costalba [Sat, 2 Jul 2011 12:33:06 +0000 (13:33 +0100)]
Introduce and use struct MoveList

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRemove MSVC debug window hack in bench
Marco Costalba [Sat, 2 Jul 2011 10:52:22 +0000 (11:52 +0100)]
Remove MSVC debug window hack in bench

Interference with profile-build under mingw

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRearrange structs to avoid internal padding
Marco Costalba [Sat, 2 Jul 2011 10:01:12 +0000 (11:01 +0100)]
Rearrange structs to avoid internal padding

Found with gcc -Wpadded gcc option.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRevert PHQ-2
Marco Costalba [Sat, 2 Jul 2011 08:45:41 +0000 (09:45 +0100)]
Revert PHQ-2

No clear advantage again standard, possibly we will
retest before to release.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoSmall touches to do/undo_castle_move()
Marco Costalba [Thu, 30 Jun 2011 14:28:58 +0000 (16:28 +0200)]
Small touches to do/undo_castle_move()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoBetter document generate_castle_moves()
Marco Costalba [Thu, 30 Jun 2011 08:29:58 +0000 (10:29 +0200)]
Better document generate_castle_moves()

No functional change also in Chess960

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoSmall tweaks to search()
Marco Costalba [Sat, 25 Jun 2011 13:31:57 +0000 (14:31 +0100)]
Small tweaks to search()

No functional change also in faked split mode

To be sure verified in real games with 4 threads TC 2"+0.1
After 11125 games 2497 - 2469 - 6159 ELO +0 (+- 4.4)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRemove duplicated enum Phase definition
Marco Costalba [Wed, 29 Jun 2011 16:40:33 +0000 (17:40 +0100)]
Remove duplicated enum Phase definition

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire find_checkers()
Marco Costalba [Tue, 28 Jun 2011 17:01:51 +0000 (18:01 +0100)]
Retire find_checkers()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire square_is_weak()
Marco Costalba [Tue, 28 Jun 2011 14:25:44 +0000 (16:25 +0200)]
Retire square_is_weak()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire one piece_list() overload
Marco Costalba [Tue, 28 Jun 2011 14:16:43 +0000 (16:16 +0200)]
Retire one piece_list() overload

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRename pieces_of_color() in pieces()
Marco Costalba [Tue, 28 Jun 2011 13:36:39 +0000 (15:36 +0200)]
Rename pieces_of_color() in pieces()

To be uniform with other overloads.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire redundant square_is_occupied()
Marco Costalba [Tue, 28 Jun 2011 13:29:58 +0000 (15:29 +0200)]
Retire redundant square_is_occupied()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoChange Position::pst() signature
Marco Costalba [Tue, 28 Jun 2011 12:59:33 +0000 (14:59 +0200)]
Change Position::pst() signature

To be more clear what is the underlying table.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoFix Shredder-FEN regression in from_fen()
Marco Costalba [Tue, 28 Jun 2011 07:35:51 +0000 (09:35 +0200)]
Fix Shredder-FEN regression in from_fen()

Fix also an incredible 3% speed regression by an almost
never called function. I guess this is due to mingw very low
quality standard libraries implementation.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoGreatly simplify castling rights handling
Marco Costalba [Mon, 27 Jun 2011 15:06:15 +0000 (16:06 +0100)]
Greatly simplify castling rights handling

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoAssume input FEN string is correct in from_fen()
Marco Costalba [Mon, 27 Jun 2011 09:07:57 +0000 (10:07 +0100)]
Assume input FEN string is correct in from_fen()

And also tolerate a 0 value for full move number.

Revert BUG_41 patch, now we set initial King file only
if a castling is possible, so we don't need the fix
anymore in case of correct FEN.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoFix a bug in Position::is_ok()
Marco Costalba [Sun, 26 Jun 2011 10:42:58 +0000 (11:42 +0100)]
Fix a bug in Position::is_ok()

If we cannot castle castleRightsMask[] could be not valid,
for instance when king initial file is FILE_A as queen rook.

In this case castleRightsMask[] at initialQRFile is different
from the expected (ALL_CASTLES ^ WHITE_OOO).

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRename type_of_piece() and color_of_piece()
Marco Costalba [Sun, 26 Jun 2011 09:52:42 +0000 (10:52 +0100)]
Rename type_of_piece() and color_of_piece()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire Position::color_of_piece_on()
Marco Costalba [Sun, 26 Jun 2011 09:37:13 +0000 (10:37 +0100)]
Retire Position::color_of_piece_on()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire Position::type_of_piece_on()
Marco Costalba [Sun, 26 Jun 2011 09:28:54 +0000 (10:28 +0100)]
Retire Position::type_of_piece_on()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire seeValues[] and move PieceValue[] out of Position
Marco Costalba [Sun, 26 Jun 2011 09:16:31 +0000 (10:16 +0100)]
Retire seeValues[] and move PieceValue[] out of Position

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRestore user weights to 100
Marco Costalba [Fri, 24 Jun 2011 09:22:26 +0000 (10:22 +0100)]
Restore user weights to 100

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoPHQ settings for King and Mobility
Marco Costalba [Sat, 18 Jun 2011 22:48:42 +0000 (23:48 +0100)]
PHQ settings for King and Mobility

See:
http://talkchess.com/forum/viewtopic.php?t=39327

After 8130 games on QUAD at 20"+0.1
1342 - 1359 - 5429 ELO +0 (+- 4.4)

Tried also version with just king settings changed:
After 5932 games 962 - 1052 - 3918 ELO -5 (+- 5.2)

And with just mobility settings changed:
After 4114 games 618 - 619  - 2877 ELO +0 (+- 5.9)

Frank has tested only 1200 games, but at longer TC and
against many engines, so because PHQ results are not worst
than other combination and not worst than original let's
commit his version.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoFix move_is_capture() to detect capture promotions
Marco Costalba [Wed, 22 Jun 2011 22:04:57 +0000 (23:04 +0100)]
Fix move_is_capture() to detect capture promotions

We miss to account as a capture a promotion capture !

Incredible bug in this critical function that is here
since a long time (b50921fd5c3e1753 of 21/10/2009 !!)

This patch fixes the bug and readds the faster
move_is_capture_or_promotion() that slightly increases
overall speed.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRewrite how uci info is sent to GUI
Marco Costalba [Wed, 22 Jun 2011 06:03:28 +0000 (07:03 +0100)]
Rewrite how uci info is sent to GUI

It is now much more modular than before and also we
always send the seldepth when we send the depth, this
avoids to make seldepth disappearing from GUI at the
start of a new iteration.

Print also fails high/low pv lines at high enough
search depths.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoSimplify sliding_attacks()
Marco Costalba [Tue, 21 Jun 2011 17:48:14 +0000 (18:48 +0100)]
Simplify sliding_attacks()

Easy, almost trivial simplification, I don't understand
how I missed this before !!

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire ksq from CheckInfo
Marco Costalba [Tue, 21 Jun 2011 06:52:35 +0000 (08:52 +0200)]
Retire ksq from CheckInfo

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoUse CheckInfo to store pinned bitboard
Marco Costalba [Mon, 20 Jun 2011 07:46:31 +0000 (09:46 +0200)]
Use CheckInfo to store pinned bitboard

This trivial change gives an impressive 2,5% speedup !!!!

Also retire one unused move_gives_check() overload.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoOmit mate distance pruning at root
Marco Costalba [Sat, 18 Jun 2011 16:10:29 +0000 (17:10 +0100)]
Omit mate distance pruning at root

Restore original behaviour, before root unification and
remove a now useless ugly hack for alpha in multi-pv case.

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoUse an array index instead of an iterator in root list
Marco Costalba [Sat, 18 Jun 2011 06:43:25 +0000 (07:43 +0100)]
Use an array index instead of an iterator in root list

It is not correct to use an iterator stick on a vector that
is sorted becuase iterator is invalidated in general case.

It happens to work by accident because iterators are implemented
as pointers and so they behave in the same (correct) way then
using array indices, but the latters are the correct thing to use.

Also better document the code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRemove useless bestValue = alpha assignement
Marco Costalba [Wed, 15 Jun 2011 11:31:27 +0000 (12:31 +0100)]
Remove useless bestValue = alpha assignement

It is a fossil from the root_search() era, no more
needed today.

Spotted by Onno

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoTry only recaptures in qsearch if depth is very low
Marco Costalba [Sun, 12 Jun 2011 06:25:51 +0000 (07:25 +0100)]
Try only recaptures in qsearch if depth is very low

This avoids search explosion in qsearch for some
patological cases like:

r1n1n1b1/1P1P1P1P/1N1N1N2/2RnQrRq/2pKp3/3BNQbQ/k7/4Bq2 w - - 0 1

After 9078 games 20"+0.1 QUAD:
Mod vs Orig 1413 - 1319 - 6346 ELO +3 (+- 4)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoSpeed up kpk initialization
Marco Costalba [Wed, 15 Jun 2011 07:09:04 +0000 (09:09 +0200)]
Speed up kpk initialization

The trick is to classify more position at first cycle,
so to reduce following work. Speed up is of about 50% !

Also some cleanup while there.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoUse Carry-Rippler trick to speed up magics
Marco Costalba [Tue, 14 Jun 2011 17:40:52 +0000 (18:40 +0100)]
Use Carry-Rippler trick to speed up magics

Nice trick discovered on:

http://chessprogramming.wikispaces.com/Traversing+Subsets+of+a+Set

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoRetire init_piece_square_tables()
Marco Costalba [Mon, 13 Jun 2011 14:59:03 +0000 (16:59 +0200)]
Retire init_piece_square_tables()

Merge in init_zobrist() and rename the latter.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoIncrease LMR limit by one ply
Marco Costalba [Thu, 2 Jun 2011 07:35:35 +0000 (08:35 +0100)]
Increase LMR limit by one ply

Seems there is no regression so prefer to prune less.

After 8278 games
Mod vs Orig 1246 - 1265 - 5767 +0 ELO (+- 4.2)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
10 years agoBetter self-document init_zobrist()
Marco Costalba [Sun, 12 Jun 2011 10:46:24 +0000 (11:46 +0100)]
Better self-document init_zobrist()

No functional change.

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