Fix an hang when max depth is reached

In this case SF stop searching and goes sleeping
waiting for a stop / ponderhit before to return
best move. So when a "stop" arrives we need to wake
up the main thread again.

Another regression introduced by 3aa471f2a9cb,
hopefully the last one.

Thanks to Otello1984 to reporting this.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Last touches to pawns shelter code

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Merge remote-tracking branch 'origin/master' into bishop_pawns
Merge from upstream/master
Revert "Call wait_for_search_finished() only when quitting"

We need to wake up main thread if it is sleeping
waiting for stop or ponderhit, so we cannot skip
calling wait_for_search_finished().

Found by Othello1984.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Reset search time as early as possible

In particualr before to wake up main thread that
could take some random time. Until we don't reset
search time we are not able to correctly track
the elapsed search time and this can be dangerous
under extreme time pressure.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Complete the renaming in Search::LimitsType

This completes the job started with revision
4124c94583c8f61.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Rename Materials and Pawns hash stuff

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Use std::vector to implement HashTable

Allows some code semplification and avoids directly
allocation and managing heap memory.

Also the usual renaming while there.

No functional change and no speed regression.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Process 'bench' also from SF prompt

It is possible to start with 'stockfish', then from
command prompt type 'bench' and SF will do what you expect.
Old behaviour is anyhow preserved. As a bonus we can now
start from command line any UCI command understood by
Stockfish. The difference is that after execution of a
command from arguments SF quits, while at the end of the
same command from prompt SF stays in UCI loop.

No functional change.

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

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Better document square flipping helpers

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Retire platform specifics include in misc.cpp

Now that platform.h is included in types.h we
don't need this stuff anymore.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Use a std::vector to store searchMoves

A std::set (that is a rb_tree) seems really
overkill to store at most a handful of moves
and nothing in the common case.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Use polymorphism to resolve map() overloading

The 2 overload functions map() accept a pointer to
EndgameBase<Value> or a pointer to EndgameBase<ScaleFactor>.

Because Endgame<E> is derived from one of them we can
directly use a pointer to this class to resolve the
overload as is needed in Endgames::add().

Also made class Endgames fully parametrized and no more
hardcoded to the types (Value or ScaleFactor) of endgames
stored.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Simplify Endgames::probe()

With this API change we simplify both function and caller site.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Merge from upstream/master
Fix break after merge from upstream.