1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00
Commit graph

2849 commits

Author SHA1 Message Date
Marco Costalba
56d2c3844a Further tweak Position::flip
No functional change.
2013-08-05 14:44:06 +02:00
Marco Costalba
23b6809f3d Rewrite flip() to use FEN string manipulation
Instead of dealing directly with internal parameters
just "flip" the FEN string and set the position from
that.

No functional change.
2013-08-05 12:58:14 +02:00
Marco Costalba
f31847302d Streamline time computation
No functional change.
2013-08-03 18:30:43 +02:00
Marco Costalba
b1a4a18d63 Update polyglot.ini with new "Min Split Depth" default
No functional change.
2013-08-03 16:41:18 +02:00
Dan Schmidt
f7096ea7ce Refactor do_castle()
Not a real functional change, but bench changed due to different piecelist
reordering. To verify it a temporary my canonicalize_rooks function was
written as follows. It just ensures that the rook on the "smaller" square
is listed first.

void Position::canonicalize_rooks(Color c)
{
   if (pieceCount[c][ROOK] == 2)
   {
      Square s0 = pieceList[c][ROOK][0];
      Square s1 = pieceList[c][ROOK][1];
      if (s0 > s1)
      {
         pieceList[c][ROOK][0] = s1;
         pieceList[c][ROOK][1] = s0;
         index[s0] = 1;
         index[s1] = 0;
      }
   }
}

With this both bench and the test on Chess960 positions

./stockfish bench 128 1 8 Chess960.epd file > /dev/null

Gives same result.

bench: 4424151
2013-08-03 16:18:28 +02:00
Joona Kiiski
a16ba5bbd1 Retire cpu_count()
Set threads number always to 1 at startup and let the
user explicitly to chose the number of threads.

Also preserve the useful behavior of automatically set
"Min Split Depth" according to the requested threads,
indeed this parameter is too technical for a casual user,
so, when left to zero, we set it on a sensible value.

No functional change
2013-08-02 16:48:25 +02:00
Marco Costalba
408e6ee9b6 Further factor out position update code
Along the lines of previous patch.

No functional change
2013-08-01 16:32:46 +02:00
Dan Schmidt
7b4f5c8f72 Factor out pieceList updating code
The new Position methods add_piece, move_piece, and remove_piece
now manage the member variables pieceList, pieceCount, and index,
and 9 blocks of code in Position that used to manipulate those
data structures by hand now call the new methods.

There is a slightly slowdown (< 1%) on Clang and on perft,
but the cleanup compensates the little speed loss.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2013-08-01 15:50:19 +02:00
Marco Costalba
55948623e7 Rework Thread hierarchy
Introduce ThreadBase struct that is search
agnostic and just handles low level stuff,
and derive all the other specialized classes
form here.

In particular TimerThread does not hinerits
anymore all the search related stuff from Thread.

Also some renaming while there.

Suggested by Steven Edwards

No functional change.
2013-07-31 18:35:52 +02:00
Marco Costalba
4d46d29efe Fix a race at thread creation
At thread creation start_routine() is called
and from there the virtual function idle_loop()
because we do this inside Thread c'tor, where the
virtual mechanism is disabled, it could happen that
the base class idle_loop() is called instead.

The issue happens with TimerThread and MainThread
where, at launch, start_routine calls
Thread::idle_loop instead of the derived ones.

Normally this bug is hidden because c'tor finishes
before start_routine() is actually called in the
just created execution thread, but on some platforms
and in some cases this is not guaranteed and the
engine hangs.

Reported by Ted Wong on talkchess

No functional change.
2013-07-31 18:35:32 +02:00
Marco Costalba
cc608a7aba Tidy up Position::pretty
No functional change.
2013-07-29 19:33:30 +02:00
Marco Costalba
1f40cd6d02 Small renaming
No functional change.
2013-07-29 19:32:59 +02:00
Marco Costalba
28bc8ed462 Speed up move generation
Pass the color as template parameter
to generate_all()

Speedup of 1,3% in perft and 2,5% in bench !

No functional change.
2013-07-29 19:01:50 +02:00
Eelco de Groot
5ee16a180a Increase pruning if evaluation is not improving
Add an additional set of margins to movecount pruning
to be used when static evaluation is getting worse
than previous move.

Here are the margins table with changing
depth (fm0 not improving, fm1 improving):

    d: 0, fm0: 3, fm1: 3
    d: 1, fm0: 4, fm1: 4
    d: 2, fm0: 6, fm1: 6
    d: 3, fm0: 7, fm1: 10
    d: 4, fm0: 11, fm1: 15
    d: 5, fm0: 15, fm1: 21
    d: 6, fm0: 21, fm1: 29
    d: 7, fm0: 27, fm1: 37
    d: 8, fm0: 35, fm1: 47
    d: 9, fm0: 42, fm1: 57
    d: 10, fm0: 51, fm1: 68
    d: 11, fm0: 60, fm1: 81
    d: 12, fm0: 70, fm1: 94
    d: 13, fm0: 81, fm1: 108
    d: 14, fm0: 92, fm1: 123
    d: 15, fm0: 104, fm1: 139

Good at both short TC

LLR: 2.97 (-2.94,2.94)
Total: 11502 W: 2503 L: 2361 D: 6638

And long TC

LLR: 2.98 (-2.94,2.94)
Total: 7189 W: 1421 L: 1277 D: 4491

bench: 4364793
2013-07-29 01:21:21 +02:00
Marco Costalba
d30dfc084c Annotate an unlikely condition
No functional change.
2013-07-27 11:34:15 +02:00
Marco Costalba
6373e88b5b 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
2013-07-27 08:25:45 +02:00
Tom Vijlbrief
7487eb0dca 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
2013-07-26 00:12:46 +02:00
Marco Costalba
2067a99c07 Fix a typo in bitboard.h
Introduced by previous patch.

Spotted by Joerg Oster

No functional change.
2013-07-25 07:44:27 +02:00
homoSapiensSapiens
002062ae93 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>
2013-07-24 19:49:17 +02:00
Marco Costalba
4064ee5406 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
2013-07-24 07:53:32 +02:00
Marco Costalba
b0fd2b6b98 Revert "Halve king eval margin"
This reverts commit 4b3a0fdab0.

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
2013-07-24 07:46:25 +02:00
Ryan Schmitt
d0bc951835 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>
2013-07-24 07:41:51 +02:00
Reuven Peleg
73131e7c78 Use arrow operator instead of * and .
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2013-07-22 20:22:40 +02:00
Reuven Peleg
1cc18d8a7a Better condition in is_pseudo_legal()
Simplify occupied destination condition.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2013-07-22 20:02:31 +02:00
Marco Costalba
c45c6d308f Small touches in move generation
No functional change.
2013-07-21 11:01:24 +02:00
Marco Costalba
f73bb438aa Some renaming in MovePicker
No functional change.
2013-07-21 09:55:08 +02:00
Marco Costalba
71dd8a333f 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.
2013-07-21 01:04:29 +02:00
Marco Costalba
9207baed65 Revert "Fix critical SEE bug (take 2)"
This reverts commit 3e95800814

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
2013-07-20 18:45:38 +02:00
Marco Costalba
b191df5ebe Revert "Yet another attempt at signature-build"
Still broken on OS X

No functional change.
2013-07-20 15:15:31 +02:00
Marco Costalba
3e95800814 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
2013-07-20 14:24:47 +02:00
Marco Costalba
2ed56f4d5f Revert all the SEE stuff
The speed up seems to introduce some
functionality change.

Revert to original master for now.

bench: 4769737
2013-07-20 14:20:33 +02:00
Marco Costalba
7b0b463720 Yet another attempt at signature-build
This one should work on all flavours of sed

Suggested by by Louis Zulli

No functional change.
2013-07-20 14:05:04 +02:00
Marco Costalba
a6c5b4c6fb 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 351ef5c85b of 26/6/2011 (!)
although for some reason didn't show immediately, indeed the
bougous patch was a "No functional change" (!!)

bench: 4793754
2013-07-20 13:37:12 +02:00
Marco Costalba
0504a6975d 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.
2013-07-20 12:34:35 +02:00
Marco Costalba
a5b5a91512 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.
2013-07-20 02:38:14 +02:00
Reuven Peleg
1a8f63a896 Microptimize gives_check() for castling case
Without patch we have 333198 nps, with patch 334249.

A very small +0.3%, not a lot manily becuase this is a
side path that is taken very few times.

Anyhow idea is correct becuase first 'quick' condition
has an hit rate of about 95%.

No functional change.
2013-07-19 17:07:54 +02:00
Marco Costalba
ee5514b8fd Small simplification in space eval scoring
No functional change.
2013-07-19 11:13:18 +02:00
Marco Costalba
99e547f4cb Rename MoveStack to ExtMove
Stack has no meaning here, while ExtMove (extended move),
better clarifies that we have a move + a score.

No functional change.
2013-07-19 10:27:58 +02:00
Marco Costalba
110644d918 Better document what we skip when in check
No functional change.
2013-07-19 09:37:31 +02:00
homoSapiensSapiens
4b3a0fdab0 Halve king eval margin
But still keep the same original
margin for score.

Passed both short TC test
LR: 2.95 (-2.94,2.94)
Total: 3710 W: 845 L: 726 D: 2139

And long TC
LLR: 2.95 (-2.94,2.94)
Total: 57859 W: 10939 L: 10532 D: 36388

bench: 4769737

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2013-07-19 08:16:39 +02:00
Marco Costalba
05e31c5e5f Drop grep and tr dependency in Makefile
Use only sed to get the bench signature.

No functional change.
2013-07-15 21:39:06 +02:00
Marco Costalba
46fdb14b2f Don't use __builtin_expect
Partially revert previous patch and use
unlikey() just as code annotation.

Actually it is better to rely on a profiler for branch prediction:

http://blog.man7.org/2012/10/how-much-do-builtinexpect-likely-and.html

"In fact, even when only one in ten thousand values is nonzero,
we're still at only roughly the break-even point"

No functional change,
2013-07-15 21:09:06 +02:00
Marco Costalba
cbb1a8ed31 Better annotate unlikely conditions
And in case of gcc we win also a small
speed optimization due to better branch
prediction.

No functional change.
2013-07-15 21:01:02 +02:00
Reuven Peleg
a6c5f60caa Simplify a condition in refutes()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2013-07-15 20:40:49 +02:00
Marco Costalba
9518cc3254 Update 'make help'
No functional change.
2013-07-14 12:23:28 +02:00
Marco Costalba
b0a177bc67 Add signature-profile-build make target
Extend patch 3f64a2af6a to profile builds.

here the make command is:

make signature-profile-build ARCH=xxx COMP=xxx

No functional change.
2013-07-14 11:57:06 +02:00
Marco Costalba
5b7b330616 Retire engine Tag
It is somewhat redundant and could make SF
name too long, so use just Version, in case
of a signature build Version will be set to
'sig-xxx' otherwise, if left empty, we fall
back on usual date stamp.

No functional change.
2013-07-14 11:13:13 +02:00
Marco Costalba
3f64a2af6a Add signature-build make target
When compiling with:

make signature-build ARCH=xxx COMP=xxx

After binary has been roduced, it will be run to
get the signature 'stockfish bench' and this
number will be used as Version, so that it
will be easy to track the original sources
from a binary.

No functinal change.
2013-07-14 10:59:25 +02:00
Marco Costalba
9749f1f14c Fix build on Intel compiler
Due to a strange issue (bug?) the ternary
operator does not return a BitCountType for
icc, so revert to the expression used
before bcbc9bfd1f

No functional change.
2013-07-13 23:13:30 +02:00
Marco Costalba
4ede49cd85 Fully qualify memset and memcpy
And other trivial touches.

Ispired by Lucas's DiscoCheck

No functional change.
2013-07-13 18:01:13 +02:00