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

2120 commits

Author SHA1 Message Date
Marco Costalba
b9f8cb7837 Fix an assert when stopping the search
When StopRequest is raised we cannot immediately exit the
move loop but first we need to update bestValue so to avoid
assert:

assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-07 10:36:13 +01:00
Joona Kiiski
ffa150bec3 Split at root!
Another great success by Joona !

After 5876 games at 10"+0.1
Mod vs Orig: 1073 - 849 - 3954 ELO +13 (+- 5.2)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-07 10:35:56 +01:00
Joona Kiiski
13bc6ba2c6 Preparations for splitting at root
No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-06 10:31:30 +01:00
Marco Costalba
30b3edf328 Simplify MovePickerExt<>
Now that we don't special case the root moves anymore
we don't need to pass NodeType anymore as template parameter,
a simple bool to detect a SpNode will be enough.

Spotted by Joona.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-05 07:23:54 +01:00
Marco Costalba
7902d6089e Fix silly bug in uci loop
After issuing "go"-command, at the end of the search
SF shows: "Unknown command: ...".

Spotted by Joona.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-05 07:15:45 +01:00
Marco Costalba
b6b0878da8 Fix a (silly) warning under icc compiler
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-04 10:10:03 +01:00
Marco Costalba
3a76163aba Use std::lexicographical_compare() in UCI options
Instead of our home grown function to perform a case
insensitive compare on option names as required by UCI
protocol.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-03 15:00:23 +01:00
Marco Costalba
1e7c6fc761 Consistently set ttMove to Rml.pv[0] in root node
No functional change, but reduce risks of subtle aliasing bugs.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-02 22:28:03 +01:00
Marco Costalba
c50ad85c3c Fix an off-by-one error in UCI print loop
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-02 21:47:31 +01:00
Marco Costalba
bb6a6e159a Rename ok_to_use_TT() in can_return_tt()
Seems more appropiate. From Lucas Braesch's DoubleCheck.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-02 18:49:06 +01:00
Marco Costalba
1036cadcec Send PV only for updated lines
It seems FritzGUI already remembers the old lines, so
we just need to update PV info only for the new lines.

Also introduced prevScore field in RootMove to avoid
a bulk copy of Rml.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-02 18:00:47 +01:00
Marco Costalba
c71ae794df Sort PV moves always in two steps
This should fix following issue:

Suppose the search with MultiPVIteration == 0 returns an exact score

move = Nxf4, score = 100

Now search with MultiPVIteration == 1 and get two scores

move = Qg8, score = 150
move = Ra1, score = 180

If we now reorder all the moves in one step we end up with

pv[0] = Ra1, pv[1] = Qg8

Instead reordering as the current patch we end up in:

pv[0] = Ra1, pv[1] = Nxf4

preserving the first searched move.

No functional change in single PV.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-02 18:00:47 +01:00
Marco Costalba
409930e98c Small cleanup of previous patches
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-02 18:00:22 +01:00
Joona Kiiski
b88f7df387 Reimplement MultiPV mode
No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-02 06:47:33 +01:00
Joona Kiiski
adcfffceeb Reimplement support for "searchmoves" option
No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-02 06:47:22 +01:00
Joona Kiiski
a3c1d64a5f Remove now unused RootMove.non_pv_score
No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-02 06:47:06 +01:00
Joona Kiiski
ce24a229df Make root search to use standard MovePicker.
This patch temporarily breaks MultiPV and searchmove
features, but they will be re-implemented in future
patches.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-08-02 06:46:50 +01:00
Joona Kiiski
ce619b3b6c Don't probe TT at RootNode
In that case we should also update RootMoveList to avoid
bogus output

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-29 12:42:22 +01:00
Marco Costalba
2e2a4b4ea3 Fix pretty_pv() output in Chess960
And move it to search.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-26 12:39:15 +01:00
Joona Kiiski
7f519a2463 Fix PV output in Chess960
We missed to set chess960 flag into the std::stringstream used to
setup the PV line.

Bug introduced with commit f803f33e63
of 30/12/2010 when we started to print PV line into a std::stringstream
instead of directly into cout, where the chess960 flag is correctly set.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-24 18:27:29 +01:00
Marco Costalba
ff1ecb5d6c Tidy up benchmark.cpp
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-24 08:53:36 +01:00
Marco Costalba
dab1cd8af9 Rename execute_uci_command() to uci_loop()
As a side effect now root position can be directly
allocated on the stack and doesn't need to be defined
static anymore.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-24 08:12:07 +01:00
Marco Costalba
5b0c6b9bc0 Unhide the istringstream behind UCIParser
It is misnamed because it is not a parser, perhaps a
tokenizer, anyhow better call it for what it is, an
input string stream.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-24 07:39:07 +01:00
Marco Costalba
fc290dc30b Fix startpos_ply_counter() regression
Return the correct number of played plies at the end
of the setup moves. Currently it always returns 0 when
starting from start position, like in real games.

We fix this adding st->pliesFromNull that starts from 0
and is incremented after each setup move and is never
reset in the setup phase but only once search is started.

It is an hack because startpos_ply_counter() will return
different values during the search and is correct only
at the beginning of the search.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-24 06:59:14 +01:00
Marco Costalba
5f7eb20090 Use a circular buffer to keep track of setup states
This fixes a regression on real games due to the fact that
we have some mismatches:

    history[st->gamePly - i] != stp->key

when st->gamePly - i == 0,this is due to a nasty bug I have
introduced when using std::vector<> as StateInfo backup. The
point is that StateInfo keeps inside a pointer to the previous
StateInfo in a kind of linked list. But when std::vector<> is
resized reallocates a larger chunk of memory and moves the
data there so these pointers became stale.

This patch fixes the issue.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-24 06:15:40 +01:00
Marco Costalba
03ad183384 Don't update gamePly after each move
We just need startup value to calculate available
thinking time. So remove from state.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-24 06:15:39 +01:00
Marco Costalba
527a2ec541 Use std::vector<Move> to store UCI search moves
Avoid the ugly and anyhow incorrect hard limit on the
maximum number of moves and allow to handle an arbitrary
number of moves to search.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-24 06:15:38 +01:00
Marco Costalba
3185c36a65 Use st->gamePly to store fullMoves
This allow to retire do_setup_move() and also to simplify
draw detection logic becuase now we always have:

Min(st->rule50, st->gamePly) = st->rule50

This was already true when starting from starting position,
but now is true even when starting from a FEN string because
now we take in account fullmove number in counting gamePly so
that it is always.

st->rule50 <= st->gamePly

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-24 06:15:36 +01:00
Marco Costalba
3d8140a541 Retire history[]
Use key saved in state instead.

No functional change (in real games) and no speed regression.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-24 06:15:35 +01:00
Joona Kiiski
a6fc3d6ee5 Do not exit early even when seeing mate
Fixes the reported KNNK ending problem:

http://talkchess.com/forum/viewtopic.php?t=39347

Joona says:

Now I finally had a time to take a look at on this issue.

I've reproduced the problem starting from this position:
1B6/1B2k3/P7/1P3p2/1K6/8/4b3/4b3 w - - 6 85

I made Stockfish play as white and Fruit as black.
I repeated test ten times and once SF was not able to deliver mate.

But I observed several times that SF had reported on last something like mate in 10.
However next time it played move with score mate in 15.

Easiest way to solve the problem is attached as a patch. I tested it several times and SF always
ended up playing the optimal move. Of course the downside is that now delivering mate
takes a bit longer, but IMO it's better to lose once in a while by time in sudden death
game than not being able to deliver simple mate with long time controls.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-24 06:13:29 +01:00
Marco Costalba
a1f9bf19d9 Revert previous patches due to bug
We have a bug (possibly because of returning draw from
root move list), it is possible to see when looking at
games with a GUI, we can see rarely but consistently the
score return as #0 for many depths until it comes back to
normal values.

Revert patches until it is not fixed.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-20 03:34:39 +01:00
Joona Kiiski
4ad6a3496b Move the draw check also for qsearch
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-19 17:36:22 +01:00
Joona Kiiski
969ad8001c Move draw checks right after doing the move
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-19 17:36:14 +01:00
Marco Costalba
07e0dd27fb Small touches in set_option()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-17 12:55:26 +01:00
Marco Costalba
b8eb699db7 Validate input UCI moves
Running following command:

  position startpos moves e1e8

Makes SF to assert in debug mode in do_move() but to accept
bad input and continue in release mode where probably it is
going to crash little later.

So validate input before to feed do_move().

Suggestion by Yakovlev Vadim.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-17 10:22:55 +01:00
Marco Costalba
ad1f28bc1c Remove some useless include
Spotted by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-16 22:59:14 +01:00
Marco Costalba
67686b7684 Don't need to assert for pos.is_ok() when position is constant
It's only necessary to do the checking at the end of every non-const
member (including the constructors and from_fen()) of class Position.
Once the post-condition of every modifier guarantees the class invariant,
we don't need to verify sanity of the position as preconditions for outside
callers such as movegen, search etc. For non-class types such as Move and
Square we still need to assert of course.

Suggested by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-16 10:53:34 +01:00
Marco Costalba
69f4954df1 Change hidden checkers API
After previous patch is no more needed to pass
the color, becuase it is always the side to move.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-16 10:12:46 +01:00
Marco Costalba
4894231ff7 Simplified discovered check connected_moves()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-16 09:50:35 +01:00
Marco Costalba
36bb57a47e Simplify and micro-optimize hidden_checkers()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-16 08:53:21 +01:00
Marco Costalba
a042449f5d No need to declare default Position c'tor
Pointed out by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-15 21:53:47 +01:00
Marco Costalba
f5e434c2d9 Fix a warning under MSVC
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-15 12:20:31 +01:00
Marco Costalba
37d551fb39 Fix parametrized direction in pawns generation
It worked by accident because we always called both directions,
but definition was wrong.

Functional change due to different generation order, but
perft numbers are the correct ones.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-15 12:13:55 +01:00
Marco Costalba
9c8c0de538 Cleanup handling of Delta enums
Ispired by Rein's code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-15 12:13:48 +01:00
Marco Costalba
fbdabe2975 Use std library to sort moves
Functional change due to the fact that now pick_best() is
stable, but should be no change in strenght.

Example code and ideas by Rein Halbersma.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-14 12:43:13 +01:00
Marco Costalba
0cfb30e5be Fix icc's "unreachable code" warning
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-11 11:17:50 +01:00
Marco Costalba
c081a81daf Teach to_fen() about Halfmove and Fullmove number
And also fix the last '/' at the end of the piece placement field.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-03 12:08:02 +01:00
Marco Costalba
155bed18f5 Use MoveList also in Position::move_is_pl_slow()
And rename it in Position::move_is_legal()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-03 11:00:28 +01:00
Marco Costalba
95d9687d95 Retire move_is_short_castle() and move_is_long_castle()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-03 10:27:15 +01:00
Marco Costalba
ff41b8df76 Restore startpos_ply_counter() instead of full_moves()
And pass correct currentPly to TimeManager::init().

This restores old behaviour, in particular now black has
a different timing than white becuase is no more:

currentPly = 2 * fullMoveNumber;

but becomes

2 * (fullMoves - 1) + int(sideToMove == BLACK)

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-07-03 06:54:46 +01:00