Use exceptions to stop the search

Instead of classical flags, throw an
exception when we want to immediately halt
the search. Currently only one type
is used for both UCI stop and threads
cut off.

No functional change.
Some renaming in TT store()

No functional change.
Simplify DistanceRingsBB init

Verified by same benchmark and picking some random values.

No functional change.
Revert using exceptions

Due to crashes. It will be reapplied once
we understand what's happening.

No functional change.
Use constants arguments where possible

No functional changes.
Normalize "pawn in front of minor" patch

No functional change.
Further tweak movecount pruning

Passed both short TC
LLR: 2.95 (-2.94,2.94)
Total: 15140 W: 3125 L: 2976 D: 9039

And long TC
LLR: 2.95 (-2.94,2.94)
Total: 17118 W: 3165 L: 2974 D: 10979

bench: 4132374
Remove useless condition in KXK endgame

Because eval is never called when in check.

No functional change.
Fix crash when reaching max ply

Bug introduced in 1b7223a53c419212efbd that
updated the ss base stack without increasing
the dimension.

No functional change.
Stockfish 4

Stockfish bench signature is: 4132374
Restore development version

No functional change.
Use null move when depth >= 2 plies

Passed both short TC:
LLR: 2.96 (-2.94,2.94)
Total: 23725 W: 5031 L: 4855 D: 13839

And long TC:
LLR: 2.96 (-2.94,2.94)
Total: 15730 W: 2939 L: 2754 D: 10037

bench: 4729333
Retire redundant endgames

The case of two lone kings on the board is already considered
by the "No pawns" scaling factor rules in material.cpp as is
KBK and KNK.

Moreover we had a small leak in endgames map because for
KK endgame it happens white and black material keys are the
same (both equal to zero), so when adding the black endgame in
Endgames::add() we were overwriting the already exsisting
white one, leading to a memory leak found by Valgrind.

So remove the endgames althogheter and rely on scaling
to correctly set the endgames value to a draw.

No functional change.
Simplify condition for backward pawn

No functional changes.
Fix KBPK bug

With

position fen 7k/8/8/8/8/7P/6K1/7B w - - 0 1
go depth 25

The evaluation at depth 22 is not draw as it should be. The reason is that
when search reaches the position 8/6kP/8/8/8/3B4/6K1/8 w - - 0 1 if white plays
h8R or h8N then we get a position that is a "KNOWN_WIN" and is _not_ a check, so
futility pruning in qsearch kicks in and black may think that it is "futile"
to reply Kxh8 since, according to the logic of the code, it cannot raise the score
back towards a draw.

bench: 4728533
Simplify kf definition in shelter_storm()

No functional change.
Simplify chain detection

No functional change.
Time management: move faster if PV is stable

Move faster but compensate by allocating more
time when the best move changes.

Passed short TC at 15+0.05
LLR: 2.93 (-2.94,2.94)
Total: 13895 W: 3030 L: 2882 D: 798

Long TC at 60+0.05
LLR: 2.96 (-2.94,2.94)
Total: 9266 W: 1777 L: 1624 D: 5865

At time increment 30+0.5
LLR: 2.96 (-2.94,2.94)
Total: 6703 W: 1238 L: 1134 D: 4331

And at fixed game number, longer TC 120+0.05
ELO: 5.17 +-2.8 (95%) LOS: 100.0%
Total: 19306 W: 3378 L: 3091 D: 12837

bench: 4728533
Add lsb() overload

Helper to find least significant bit relative to
the given color.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Replace hardcoded 128 by constant

No functional change.