1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00
Commit graph

2096 commits

Author SHA1 Message Date
Marco Costalba
b5f6c2241b Restore std::cout instead of printf()
I am not able to reproduce the speed regression anymore,
and also we were using cout even before speed regression
so probably the reason is not there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-25 09:29:51 +01:00
Marco Costalba
e89a8e0913 Correctly define operators in types.h
Be consistent with the way these operators are defined
in plain C (and in C++).

Spotted by Lucas Braesch.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-24 09:58:46 +01:00
Marco Costalba
d543a64cc7 Don't update killers for evasions
We don't use killers to order evasions, so it
seems natural do not consider an evasion cut-off
move as a possible killer. Test shows almost no
change, as it should be becuase this is a really
tiny change, but neverthless seems the correct
thing to do.

After 11893 games
Mod vs Orig 1773 - 1696 - 8424 ELO +2 (+-3.4)

Idea from Critter.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-24 09:25:20 +01:00
Marco Costalba
939b621e5c Use ADL to skip std:: qualifier
Take advantage of argument-dependent lookup (ADL) to
avoid specifying std:: qualifier in some STL functions.
When a function argument refers to a namespace (in this
case std) then the compiler will search the unqualified
function in that namespace too.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-18 21:18:51 +01:00
Marco Costalba
a77a3b723f Disable again buffering at startup
Partially revert efd2167998
Without this patch SF does not send "bestmove" to GUI.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-17 16:59:32 +01:00
Marco Costalba
976270916b Headers cleanup in ucioption.cpp
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-17 15:58:19 +01:00
Marco Costalba
87f7e99bc4 Use printf() instead of std::cout()
Seems sensibly faster: On a

./stockfish bench > /dev/null

We have +2% on mingw and even +5% on MSVC !

Also removed the nice but complex enum set960 machinery,
use directly the underlying move_to_uci() function.

Speed regression reported by Heinz van Saanen.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-17 15:50:06 +01:00
Marco Costalba
72d8d27234 Retire update_history() Inline the only caller site
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-16 19:17:47 +01:00
Marco Costalba
1ae6ae9b60 Fix book move with searchmoves compatibility
Do not return the book move if is not among the
RootMoves,in particular if we have been asked to
search on a move subset with "searchmoves" then
return book move only if it is among this subset.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-16 07:23:24 +01:00
Marco Costalba
af4fadebda Simplify id_loop() signature
And related assorted cleanup of this
very important function.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-14 21:56:37 +01:00
Marco Costalba
0af3af5d25 Reformat sending of PV information
Introduce pv_info_to_log() and pv_info_to_uci() and
greatly cleanup this stuff.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-14 19:22:22 +01:00
Marco Costalba
852d45a600 Further simplify aspiration code
Actually after last patch it happens that delta
starts always with the fixed value of 16.

So further remove useless code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-14 06:18:33 +01:00
Marco Costalba
96213689e4 Simplify aspiration window calculation
It seems that we just need to look at previous score to
compute aspiration window size.

After 5350 games:
Mod vs Orig 800 - 803  - 3647 ELO +0 (+- 5.2)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-14 05:56:53 +01:00
Marco Costalba
4e59c5c274 Retire RootMoveList
Diretcly use the underlying std::vector<Move> and the
STL algorithms. Also a bit of cleanup while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-12 20:13:24 +01:00
Marco Costalba
7d97ebfe7f Fix another crash triggered by previous patch
It is ok to redirect st pointer to startState, but the latter
should be updated with the content pointed by the st of the
original position. The bug is hidden when startState and *st
are the same as is the case of searching from start position,
but as soon as moves are made (as is the case when splitting)
the bug leads to a crash.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-11 11:44:09 +01:00
Marco Costalba
377c406c74 Fix a crash when quitting while searching
The Position object used by UI thread is a local variable in
uci_loop(), so after receiving "quit" command the function
returns and the position is freed from the stack.

This should not be a problem becuase in start_thinking() we copy
the position to RootPosition that is the one used by main search
thread. Unfortunatly we blindly copy also StateInfo pointer that
still points to the startState struct inside UI position. So the
pointer becomes stale as soon as UI thread leaves uci_loop() and
because this happens while main search thread is still recovering
after the 'stop' signal we have a crash.

The fix is to update the pointer to the correct startState after
the copy.

Found with Valgrind.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-11 10:31:46 +01:00
Marco Costalba
91601d7f95 Prune silly comments in search()
Comments should be informative but not pedantic / obvious.
The only exception is the function description where we
indulge a bit on the "chatty" side, but has always been like
this since Glaurung times, so we continue with this tradition.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-10 19:14:49 +01:00
Marco Costalba
f3728e66f8 Allow to prune also first move
Tested togheter with previous patch; shows no regression and
is a semplification.

After 5817 games:
Mod vs Orig 939 - 892 - 3986 ELO +2 (+- 5.1)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-10 17:35:37 +01:00
Marco Costalba
3f14ed6602 Don't update bestValue when pruning
Simply return a fail-low score

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-10 17:35:36 +01:00
Marco Costalba
14df99130f Fix description of endgame scaling functions
Triggered by a comment of Eelco on talkchess. Also
a bit of cleanup while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-10 12:40:05 +01:00
Marco Costalba
47bcb892af Fix compile for 64 bits
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-08 13:55:27 +01:00
Marco Costalba
6e05055f06 Set captureThreshold according to static evaluation
Consider negative captures as good if
still enough to reach beta.

After 7502 games:
Mod vs Orig 1225 - 1158 - 5119 ELO +3 (+- 4.5)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-08 13:48:18 +01:00
Marco Costalba
da6e53a436 Remove some (int) casts
A cast rarely is the right solution. In this case was enough
to redifine 3 variables with type size_t instead of int

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-07 17:30:28 +01:00
Marco Costalba
56774fff20 Retire all extensions (but checks) for non-PV nodes
It seems we don't have any added value. Note that the
moves that were used to be extended are still flagged
as dangerous so to avoid at least pruning them.

After 9555 games
Mod vs Orig 1562 - 1540 - 6453 ELO +0 (+- 4)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-07 07:49:24 +01:00
Marco Costalba
3527a42063 Prefer empty() to size()
As Heinz says:

"Function empty() should have a constant run-time even
 on lousy compilers and you spare the not.

The change is even measurable: + 100-150 nodes/sec. Wow:-)"

Patch from Heinz van Saanen

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-06 19:41:48 +01:00
Marco Costalba
98352a5e84 Use operator() instead of apply() in endgames
It is more idiomatic for a functor (a function object) as are
the endgames.

Suggested by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-05 21:04:32 +01:00
Marco Costalba
11a7980976 Fix disambiguation bug in move_to_san()
A pinned piece cannot move and so does not play any role
in SAN disambiguation.

Reported by Steven Edwards.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-04 12:24:15 +01:00
Marco Costalba
5b8ca1eee7 Move SearchStack under Search namespace
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-04 12:03:59 +01:00
Marco Costalba
81cd417b45 Retire move.h
Also some assorted comments fixes and other trivia.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-04 11:36:03 +01:00
Marco Costalba
a44c5cf4f7 Prefer 0 to EmptyBoardBB
Easier and even faster or at least easier to optimize.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-03 12:02:13 +01:00
Marco Costalba
5c5af4fa65 Retire neighboring_files_bb() overload
Rarely used and we prefer to not hide the complexity.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-03 11:58:55 +01:00
Marco Costalba
efd2167998 Don't disable IO buffering at startup
It was never clear to me why we needed this trick, and now
that we rely only on C++ std::getline() and std::cout for
input / output it is even more a mistery what this code does.

So disable it and wait to see if someone screams ;-)

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-03 10:54:44 +01:00
Marco Costalba
348f824104 Tidy up comments in uci.cpp
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-03 10:48:31 +01:00
Marco Costalba
0f7cbaca75 Tidy up comments in thread.cpp
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-12-03 09:58:46 +01:00
Marco Costalba
e870afa5d5 Include <cstring> in search.h
Now we use memset() directly there.

Spotted by Justin Blanchard.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-28 07:30:31 +01:00
Marco Costalba
9bacd921fa Little reformat of elapsed_search_time()
Change name and argument type.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-27 22:36:13 +01:00
Marco Costalba
bb3427ca85 Detach search arguments from UI thread
Detach from the UI thread the input arguments used by
the search threads so that the UI thread is able to receive
and process any command sent by the GUI while other threads
keep searching.

With this patch there is no more need to block the UI
thread after a "stop", so it is a more reliable and
robust solution than the previous patch.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-27 17:46:18 +01:00
Marco Costalba
6809b57cfc After a "stop" do not read new input until search finishes
Unfortunatly xboard sends immediately the new position to
search after sending "stop" when we have a ponder miss.

Becuase main thread position is not copied but is referenced
directly from root position and the latter is modified by
the "position.." UCI command we end up with the working position
that changes under our feet while the search is still recovering
after the "stop" and this causes a crash.

This happens only with the (broken) xboard, native UCI does not
have this problem.

Reported by otello1984

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-27 12:19:33 +01:00
Marco Costalba
ffa75215cc Fix a race in pondering mode
Fixes an hang when playing with ponder ON. Perhaps there is still
a very small race but now it seems engine does not hang anymore.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-26 18:29:40 +01:00
Marco Costalba
c4517c013c Introduce Search namespace
Move global search-related variables under "Search" namespace.

As a side effect we can move uci_async_command() and
wait_for_stop_or_ponderhit() away from search.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-26 13:43:22 +01:00
Marco Costalba
ed04c010eb Rewrite async I/O
Use the starting thread to wait for GUI input and instead use
the other threads to search. The consequence is that now think()
is alwasy started on a differnt thread than the caller that
returns immediately waiting for input. This reformat greatly
simplifies the code and is more in line with the common way
to implement this feature.

As a side effect now we don't need anymore Makefile tricks
with sleep() to allow profile builds.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-26 11:51:12 +01:00
Marco Costalba
e9dc2e9e1e Reformat search dispatch code
Reduce indentation level and lines of code and tidy up
some comment.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-20 00:02:13 +01:00
Marco Costalba
9c7d72739c Fix regression with printing of debug info
Output of debug info each second was disabled
due to recent patches.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-19 14:37:57 +01:00
Marco Costalba
3fc08f8ab6 Don't check for early stop when StopOnPonderhit is set
If we are pondering we will stop the search only when
GUI sends "ponderhit" or "stop" commands or when we reach
maximum depth. In all the other cases we continue to search
so there is no need to verify for available time.

Also better clarify why wait_for_stop_or_ponderhit() before
to exit in some cases.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-19 12:04:42 +01:00
Marco Costalba
c56a7ee803 Early stop: retire redundant Rml.size() == 1 case
In case there is only 1 legal move we will stop the
search at depth 10 anyway because the exclusion search
probe will fail low.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-19 11:19:12 +01:00
Marco Costalba
35fa4fc71f Rewrite early stop logic
In the "easy move" paradigm we verify if the best move has
ever changed over a good number of iterations and if the
biggest part of the searched nodes are consumed on it.
This is a kind of hacky ad indirect heuristic to deduce
if one move is much better than others.

Rewrite the early stop condition to verify directly if one
move is much better than others performing an exclusion
search.

Idea to use exclusion search for time management if form Critter.

After 12245 games at 30"+0.1
Mod vs Orig 1776 - 1775 - 8694 ELO +0 (+-3.4)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-18 21:01:34 +01:00
Marco Costalba
b56a098cfb CLOP: Passed pawns weights tuning
Tuned with CLOP against a pool of 3 engines. Result
verified with a direct match:

After 11720 games at 10"+0.1
Mod vs Orig 1922 - 1832 - 7966 ELO +2 (+-3.6)

So no change in self match but if CLOP is right it should
be a bit better against an engine pool.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-14 09:05:20 +01:00
Marco Costalba
4cc272cb94 Rename value in bestValue in id_loop()
The value returned by root search it is actually
our best value, so rename the variable to reflect this.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-13 10:54:30 +01:00
Marco Costalba
c4fc82c6b7 Rewrite link time optimization in Makefile
Instead of binding link time optimization to the choice of
popcount support, do the right thing and add -flto option
when gcc 4.5 or later is detected.

Although it should be supported also under mingw, it happens
that it doesn't, at least on my 4.6.1 due to some known bugs.

Thanks to Mike for helping me with this patch.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-12 11:55:45 +01:00
Marco Costalba
a40ded2884 Simplify passed pawns logic
Remove the bonus for no *friendly* pieces in the pawn's path and
reduce a bit the bonus based on kings proximity.

This patch is part of to the ongoing effort to remove form evaluation
all the terms that do not add value.

After 16284 games:

Mod vs Orig 2728 - 2651 - 10911 ELO +1 (+- 3.1)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-12 09:09:41 +01:00