1
0
Fork 0
Commit Graph

2688 Commits (8df17204f4469977604695e4ae5d63ae47a575ff)

Author SHA1 Message Date
Marco Costalba 0901e12102 Revert "Simplify Evaluation"
This reverts commit 496c7497cb
2013-02-02 06:44:04 +01:00
Marco Costalba 58c9fbacc7 Revert "Extend full 3 fold detection to PvNodes" 2013-02-02 06:41:05 +01:00
Marco Costalba 483c98a69e Rewrite do_castle_move()
And handle the castle directly in do/undo_move().
This allow to greatly simplify the code.

Here the beast is the nasty Chess960 that is
really tricky to get it right because could be
that 'from' and 'to' squares are the same or
that king's 'to' square is rook's 'from' square.

Anyhow should work: verified on all Chess960
starting positions.

No functional and no speed change also in Chess960.
2013-01-28 13:40:47 +01:00
Marco Costalba 2218a5836a Rewrite do_null_move()
Use a more traditional approach, along the same lines
of do_move().

It is true that we copy more in do_null_move(), but we
save the work in undo_null_move(). Speed test shows the
new code to be even a bit faster.

No functional change.
2013-01-27 12:15:02 +01:00
Marco Costalba 76a0d3c05a Get rid of some locals in do_castle_move()
Rewrite the logic to get rid of kBefore and rBefore.

No functional change.
2013-01-27 11:03:55 +01:00
Marco Costalba 52cab06fff Don't prefetch if not needed
Prefetch access to hash tables only in case we
have changed pawn or material hash keys.

No functional change.
2013-01-27 10:19:11 +01:00
Marco Costalba bd87ab9ff5 Retire generate_king_moves()
We have only one call place so inline its content.
BTW, function is already declared as FORCE_INLINE.

Also some small refactoring while there.

No functional change.
2013-01-26 22:43:58 +01:00
Gary Linscott 57797822f8 Bring back just bishop pins 2013-01-26 15:35:00 -05:00
Marco Costalba 7062db7cb2 Clarify slavesMask usage
When a thread is allocated a bit is set in slavesMask.
This bit corresponds to the thread's index field that,
because it happens to be the position in the threads
array, eventually it is equal to the loop index 'i'.

But instead of relying on this 'coincidence', explicitly
use the 'idx' field so to clarify slavesMask usage.

Backported from c++11 branch.

No functional change.
2013-01-26 14:38:51 +01:00
Marco Costalba 166cc0292c Revert "Further push singular extension"
This reverts commit 4c91dbc28e

Seems a regression on extended test by both Gary and me.
2013-01-26 10:20:46 +01:00
Marco Costalba 496c7497cb Merge branch 'simplify_eval' of https://github.com/glinscott/Stockfish
Test results are looking good after 12500 games.

ELO: 6.55 +- 99%: 8.02 95%: 6.09
LOS: 99.99%
Wins: 1968 Losses: 1732 Draws: 8813

Also, here are the noise.py results, which seem to have stabilized:
Games: 12526 , result: [1969, 1734, 8823]
Estimated ELO: 6.94963842777
Noise as function of number of games:
['81.89', '565.26', '110.87', '104.39', '38.22', '49.98', '18.56', '16.76',
'11.02', '8.90', '17.36', '9.84', '10.81', '5.13', '6.22', '3.32', '5.83',
'7.21', '15.27', '1.63', '4.04', '9.51', '0.54', '0.75', '1.06', '2.93',
'4.59', '6.85', '13.62', '9.87', '14.74', '20.46', '22.18', '24.33', '31.02',
'34.99', '35.22', '33.22', '32.46', '37.02', '29.10', '36.34', '42.11', '39.33',
'26.16', '28.25', '35.42', '31.04', '29.26', '23.91', '22.52', '23.49', '20.00',
'24.39', '17.22', '16.50', '10.69', '9.15', '9.57', '4.77', '6.67', '3.87', '2.57',
'2.84', '2.60', '3.32', '2.08', '2.93', '4.47', '4.41', '4.83', '4.86', '6.40',
'5.98', '6.10', '6.83', '5.83', '6.22', '5.71', '8.52', '9.25', '5.98', '7.52',
'7.76', '8.76', '8.55', '8.64', '7.19', '5.83', '4.59', '4.77', '4.26', '4.98',
'5.29', '5.41', '4.92', '5.59']

bench: 5229106
2013-01-26 10:18:36 +01:00
Gary Linscott e83b9075ff Simplify evaluation 2013-01-24 08:54:13 -05:00
Marco Costalba 6950d07bf4 Small reformat of split()
No functional chhange.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2013-01-21 23:31:33 +01:00
Marco Costalba 054d117d25 Fix an idiotic icc warning
Intel Compiler has 'invented' this pearl:

warning #1476: field uses tail padding of a base class

Just becuase we have subclassed MainThread and added
the field 'bool thinking'.

Pure nosense. Silence the warning.

No functional change.
2013-01-20 17:36:24 +01:00
Marco Costalba 62b32a4737 Futher renaming in thread.cpp
No functional change.
2013-01-20 17:35:55 +01:00
Marco Costalba 588670e8d2 Big renaming in thread stuff
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2013-01-16 20:00:05 +01:00
Marco Costalba c465f4c4df Fix race while exiting
Fix again TimerThread::idle_loop() to prevent a
theoretical race with 'exit' flag in ~Thread().

Indeed in Thread d'tor we raise 'exit' and then
call notify() that is lock protected, so we
have to check again for 'exit' before going to
sleep in idle_loop().

Also same change in Thread::idle_loop() where we
now check for 'exit' before to go to sleep.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2013-01-16 19:58:55 +01:00
Lucas Braesch 8737b26a23 Remove Threat Extension
Great code simplification: - instead do not futility
prune threat refutations. allows_move() is therefore removed.

4000 games at 50,000 nodes/move:
1085-989-1926 [51.2%] LOS=98.3%

4000 games in 10"+0.1"
756-751-2493 [50.1%] LOS=55.1%

EDIT: I have retested the patch of Lucas in a slightly different form
(without pruning in PvNode) and test mre or less confirms that
60 lines of code are totally unuseful:

After 6195 games at 15"+0.05"
1333 - 1325 - 3537 ELO 0

bench 5140990
2013-01-15 17:03:56 +01:00
Marco Costalba 78a9531773 Fix a bug in timer loop
Silly logic bug introduced in dda7de17e7

Timer thread, when msec = 0, instead of going
to sleep, calls check_time() in an endless loop.

Spotted and reported by snino64 due to abnormally
high CPU usage.

No functional change.
2013-01-14 19:32:30 +01:00
Marco Costalba d1143794a0 Polymorphic Thread hierarchy
Subclass MainThread and TimerThread and declare
idle_loop() virtual. This allow us to cleanly
remove a good bunch of hacks, relying on C++
polymorphism to do the job.

No functional change.
2013-01-14 02:01:37 +01:00
Marco Costalba e70eae2c91 Don't use do_sleep flag
Rename it is_finished and use it only in main
thread to signal search is finished. This allows
us to simplify the complex SMP logic.

Ultra tricky patch: deep test is required under
wide conditions like pondering on and option
"Use Sleeping Threads" set to false.

No functional change.
2013-01-14 00:02:32 +01:00
Marco Costalba 99ae47716a Re-add the hack
This reverts commit 869c924410

I misunderstood here. Actually it can happen that
thread is created but still not entered idle_loop
and at the same time start_searching() is called.

Becuase 'do_sleep' is set start_searching() will
set it to false and start the search, but when,
at last, the thread enters idle_loop(), resets
the flag and goes to sleep: not what we want.

Revert the hack waiting for a better solution
in the next patches.

No functional change.
2013-01-13 23:56:04 +01:00
Marco Costalba dda7de17e7 Retire set_timer()
Also assure in Thread::timer_loop() that when
timer interval is 0 (timer is disabled) we
never call check_time()

No functional change.
2013-01-13 18:24:43 +01:00
Marco Costalba 869c924410 Retire obsolete race hack
This hack was introduced in d282cf6964
to workaround a race with start_searching(),
but these days is no more needed.

No functional change.
2013-01-13 17:05:30 +01:00
Marco Costalba ea6c1f7a17 Retire Threads wake_up() and sleep()
These functions are used in just one place.
And generalize wait_for_stop()

No functional change.
2013-01-13 16:57:40 +01:00
Marco Costalba 81cd7d787e Rename wake_up() to notify_one()
To align to C++ std::thread conventions.

No functional change.
2013-01-13 16:43:26 +01:00
Marco Costalba a523cea772 Unify 'ponderhit' handling
Finally we can now merge the 'ponderhit' case with
'stop' and 'quit'.

The patches have been done step by step to help debugging
becuase this is really tricky code.

No functional change.
2013-01-13 14:39:41 +01:00
Marco Costalba a66a7c3870 Small change to "ponderhit" handling
Reset Limits.ponder only if search continue, but if
we are going to stop the search there is no need
(and is also confusing) to clear the 'ponder' flag.

This mimics the behaviour upon rceiving 'stop' when
pondering.

No functional change.
2013-01-13 14:32:30 +01:00
Marco Costalba 89a89eb605 Simplify and rename wait_for_stop_or_ponderhit()
Setting stopOnPonderhit is now done by the caller.

No functional change.
2013-01-13 14:15:19 +01:00
Marco Costalba 3b14b17664 Simplify a condition in search()
And rearrange best value update in case of SpNode.

No functional change.
2013-01-13 13:17:16 +01:00
Marco Costalba 3a836dab59 Clarify SAN disambiguation in case of a pinned piece
In SAN notation when two pieces of the same type can
move to a given destination square, a disambiguation
additional info (like starting file) shall be added
to the SAN move.

If one of the two pieces is pinned, the corresponding
move _could_ be illegal and in this case disambiguation
is not needed. But to be pinned alone it is not enough
to deduce that the move is illegal, for instance in this
position:

R3rk2/2r6/8/8/8/8/8/K7 b - - 0 1

The move Rc8 is ambiguous although the rook in e8 is pinned
and the correct SAN notation should be Rcc8.

No functional change.
2013-01-12 13:21:14 +01:00
Marco Costalba e1191b35e8 Async 'stop' command
Don't wait for the search to finish after a 'stop'
command, but keep processing the GUI input if any.

Also explicitly wake up the main thread (that could be
sleeping) after a 'stop' or 'quit' command and do not
rely on wait_for_search_finished() doing it for us.

This patch cleans up the code and functions's definitions,
but it is risky and needs a good test under different
conditions to be sure it does not introduces hungs up.

No functional change.
2013-01-12 12:06:55 +01:00
Marco Costalba edce2a8448 Revert so called "fromNull patch"
Revert patch c581b7ea36

Seems a regression after testing from Gary:
ELO: 7.24 +- 99%: 17.03 95%: 12.93
LOS: 97.86%
Wins: 439 Losses: 381 Draws: 1962

And mine:
After 5410 games at 15"+0.05
Wins: 936 Losses: 1141 Draws: 3333  ELO -13

Moreover we know that there is a regression in the range
of patches which include the fromNull patch.

Probably this is not the only regression since 2.3.1 and
perhaps the idea under fromNull is good, but at the moment,
while in deep regression hunting, better to be on the safe
side and revert it entirely.

My guess on why this is a regression is that using the
negated evaluation of previous ply in case of null search
fails to take in account the king safety asymmetry between
the two colors. This is of course just a guess.

bench 5503830
2013-01-06 23:06:20 +01:00
Marco Costalba 9b1cf3cf43 Have fun with union in book.cpp
Fancy way to use an union to map polyglot
zobrist keys in one go.

Also some renaming while there.

No functional change.
2013-01-06 12:06:19 +01:00
Marco Costalba bff65a211f Retire 'Cowardice' and 'Aggressiveness' UCI options
They are not self-describing and create a lot of user
requests about them.

Given that the values are already well tuned there
is no need to expose them as UCI options.

No functional change.
2013-01-04 17:11:24 +01:00
Marco Costalba 2d60995c00 Retire 'mate in x' hack
Sometimes is faster, but not always and on very long mates
produces strange scores probably due to truncation of PV
artifacts.

So simply perform normal search also in case of UCI 'mate x'
command, with the only difference that when a mate in x is
found search returns immediately.

No functional change.
2013-01-04 16:30:46 +01:00
Marco Costalba 0454bbc54f Don't exit if unable to find bench file
Now that we can call 'bench' command also from
interactive terminal it makes no more sense to
exit the application if the user types a wrong
file name.

No functional change.
2013-01-04 14:52:21 +01:00
Marco Costalba 900e2d4e1e Teach file_to_char() about upper/lower case
This allows to further simplify Position::fen()

No functional change.
2013-01-04 14:45:04 +01:00
Marco Costalba 9d1151575d Reformat FEN construction
Simplify and shrink code.

No functional change.
2013-01-04 13:38:14 +01:00
Marco Costalba 193741218c Remove some obsolete asserts on TT values
Now that insert_pv_in_tt() stores VALUE_NONE in
TT's position evaluation those 2 asserts are
obselete.

No functional change.
2012-12-31 17:20:39 +01:00
Marco Costalba 896420b166 Allow to pass a 'seed' to RKISS
This somewhat simplifies the code.

Suggested by Lucas Braesch.

No functional change.
2012-12-31 11:59:53 +01:00
Marco Costalba 009a0f88e0 Micro-optimization in evaluate_space()
Since &-ing with SpaceMask restricts the set to the home
half of the board, it is possible to use just one popcount
instead of 2 by shifting "safe" to the other half of the
board. This gives a small speedup especially on systems
where hardware popcount is not available.

Patch kindly sent by Richard Vida.

No functional change.
2012-12-31 11:34:18 +01:00
Marco Costalba e1d681458e Add 'mate' limit to 'bench' command
It is now possible to run SF on a 'mate in x' testsuite.

For instance in case of a file with fen strings of
positions with mate in 10 we can now 'bench' on it:

stockfish bench 128 1 10 mate_in_10.epd mate

No functional change.
2012-12-30 15:49:02 +01:00
Marco Costalba ce063f59cd Handle UCI command "mate in x moves"
Following a user request I added the handling of UCI:

go mate x

Currently we just return from a PV node if x moves have been
done. Probably not the best approach. I have looked at Fruit/Toga
sources and there is even simpler: engine falls back on a fixed
depth search.

No functional change.
2012-12-30 14:43:23 +01:00
Marco Costalba 3cf6471738 Revert evaluation cache
And return on using TT as backing store for position
evaluations.

Tests (even on single thread) show eval cache was a regression.
In multi thread result should be even worst because eval cache
is a per-thread struct, while TT is shared.

After 4957 games at 15"+0.05 (single thread)
eval cache vs master 969 - 1093 - 2895  -9 ELO

So previous reported result of +18 ELO was probably due to an
issue in the testing framework (a bug in cutechess-cli) that
has been fixed in the meanwhile.

bench: 5386711
2012-12-27 13:57:17 +01:00
Marco Costalba f78b68b7ff Add list of legal moves to Position::pretty()
Along the same lines of previous patch now we add
the list of the legal moves in the given position.

No functional change.
2012-12-27 11:34:48 +01:00
Marco Costalba e9ab7353de Add checkers info to Position::pretty()
In case current position is under check, list the
squares of the checker(s) pieces.

This should satisfy a specific user request.

No functional change.
2012-12-26 18:28:45 +01:00
Marco Costalba 9d1978e217 Remove two obsolete asserts in prevents_move
Now that this function is called also to calculate
move's extensions the asserts are no more valid.

No functional change.
2012-12-26 12:27:41 +01:00
Marco Costalba db097921bc Rename yields_to_threat and prevents_threat
Follow Lucas suggestions and better name these
two functions.

No functional change.
2012-12-26 12:21:59 +01:00
Marco Costalba 894c43a1d6 Introduce Null Threat extension
In case of null search at low depths returns a fail low
due to a threat then, rather than return beta-1 (to cause
a re-search at full depth in the parent node), we set a flag
threatExtension = true (false by default) that will cause
moves that prevent the threat to be extended of one ply
in the following search.

Idea and patch is by Lucas Braesch.

Lucas also did the tests:
1500 games in 5"+0.05":
SF_threatExtension vs SF_20121222: 366 - 331 - 803 [51.2%] LOS=90.8%

3000 games in 10"+0.1":
SF_threatExtension vs SF_20121222: 610 - 559 - 1831 [50.8%] LOS=93.2%

Tests confirmed by Gary after 10570 games,
ELO: 2.79 +- 99%: 8.72 95%: 6.63
LOS: 94.08%
Wins: 1523 Losses: 1438 Draws: 7607

And finally by me at 15"+0.05, single thread, 3824 games
threatExtension vs master 768 - 692 - 2364  +7 ELO

bench 4918443
2012-12-25 19:17:27 +01:00