Fix signature-build under OSX

On OS X when you use -i an extension for the in-place
substitution a backup files is required.

http://stackoverflow.com/questions/4247068/sed-command-failing-on-mac-but-works-on-linux

So rewrite to make sed flushing sign.txt in one go and avoid
using -i option.

Reported by Louis Zulli

No functional change.
Speedup see()

And rename next_attacker() SEE helper

This very simple patch is able to speed up
bench run of almost 2% !

No functional change.
Fix critical SEE bug

It is somewhat unbilievable but our SEE is broken !

If the first SEE move is a king capture and square is
defended then SEE continues instead of breaking.

The bug shows only on normal SEE, not see_sign() so
probing with a:

dbg_hit_on_c(slIndex==1, captured == KING);

reports just a tiny:

Total 3465656 Hits 6646 hit rate (%) 0

Bug was there since 351ef5c85b6d4b9c71e9da of 26/6/2011 (!)
although for some reason didn't show immediately, indeed the
bougous patch was a "No functional change" (!!)

bench: 4793754
Yet another attempt at signature-build

This one should work on all flavours of sed

Suggested by by Louis Zulli

No functional change.
Revert all the SEE stuff

The speed up seems to introduce some
functionality change.

Revert to original master for now.

bench: 4769737
Fix critical SEE bug (take 2)

It is somewhat unbilievable but our SEE is broken !

    If the first SEE move is a king capture and square is
    defended then SEE continues instead of breaking.

    The bug shows only on normal SEE, not see_sign() so
    probing with a:

    dbg_hit_on_c(slIndex==1, captured == KING);

    reports just a tiny:

    Total 3465656 Hits 6646 hit rate (%) 0

    Bug was there since Retire seeValues[] and move PieceValue[] out of Position of 26/6/2011 (!)
    although for some reason didn't show immediately, indeed the
    bougous patch was a "No functional change" (!!)

    bench: 4699504
Revert "Yet another attempt at signature-build"

Still broken on OS X

No functional change.
Revert "Fix critical SEE bug (take 2)"

This reverts commit 3e95800814d

For some reason it fails the short TC test:
LLR: -2.96 (-2.94,2.94)
Total: 20033 W: 4214 L: 4265 D: 11554

bench: 4769737
Rewrite and simplify SEE

This very speed critical code was full of clever (!)
tricks and subtle details.

So I have rewritten it in a more straithforward way
and, as very often happens, result is even faster
than original.

No functional change.
Some renaming in MovePicker

No functional change.
Small touches in move generation

No functional change.
Better condition in is_pseudo_legal()

Simplify occupied destination condition.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Use arrow operator instead of * and .

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Tune pawn PSQT values

Reduces the influence of PSQT for entries such as
the extended center and the h-file.

Passed both short TC test:
LLR: 2.95 (-2.94,2.94)
Total: 23919 W: 5207 L: 5029 D: 13683

And long TC one:
LLR: 2.96 (-2.94,2.94)
Total: 5762 W: 1108 L: 974 D: 3680

Bench: 4617880

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Revert "Halve king eval margin"

This reverts commit 4b3a0fdab03a7529ede42891963d3036712a0bd5.

As Gary says: " It failed when I tried it at long TC previously, and only
barely passed this time.  Some anecdotal evidence is that it hurts vs other
engines as well (the Lightspeed rating list showed a 16 elo drop from previous
best version - still +- 5 error bars on both, but that's still significant)"

I also agree that if we have some doubts (like in this case) it is better to
be safe than sorry.

bench: 4615572
Simplify captures ordering

A big simplification and removing of useless code.

Finished at 50% both at short TC (with SPRT) than
at long TC at fixed number of games:
ELO: -0.14 +-3.4 (95%) LOS: 46.8%
Total: 15206 W: 2836 L: 2842 D: 9528

bench: 5059948
Use #ifndef instead of #if !defined

And #ifdef instead of #if defined

This is more standard form (see for example iostream file).

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Fix a typo in bitboard.h

Introduced by previous patch.

Spotted by Joerg Oster

No functional change.
Rewrite pawn shield and storm code

Passes quickly both short TC:
LLR: 2.95 (-2.94,2.94)
Total: 5755 W: 1349 L: 1222 D: 3184

And long TC:
LLR: 2.95 (-2.94,2.94)
Total: 2744 W: 628 L: 505 D: 1611

bench: 4727133
Fix an assert in KBK endgame

The endgame king + minor vs king is erroneusly
detected as king + minor vs king + minor

Here the fix is to detect king + minor earlier,
in particular to add these trivial cases to
endgame evaluation functions.

Spotted by Reuven Peleg

bench: 4727133