1
0
Fork 0
Commit Graph

246 Commits (riscv64-cartesi)

Author SHA1 Message Date
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 ecb98a3330 Stop is not an unknown command
If GUI sends stop while we are waiting for
a command do not reply with a silly:

Unknown command: stop

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-10 15:06:28 +01:00
Marco Costalba 2617aa415e Rewrite how commands from GUI are read
Instead of polling for input use a dedicated listener
thread to read commands from the GUI independently
from other threads.

To do this properly we have to delegate to the listener
all the reading from the GUI: while searching but also
while waiting for a command, like in std::getline().

So we have two possible behaviours: in-sync mode, in which
the thread mimics std::getline() and the caller blocks until
something is read from GUI, and async mode where the listener
continuously reads and processes GUI commands while other
threads are searching.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-11-05 08:35:17 +01:00
Marco Costalba c2c185423b Better naming borrowed from Critter
In line with http://chessprogramming.wikispaces.com conventions.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-10-02 10:16:59 +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 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
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 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 e656ddcf18 Perft counts leaf nodes not generated moves.
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-04-27 23:21:46 +01:00
Marco Costalba 1d0159075e Use probe() as name for looking up into an hash table
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-04-27 07:31:51 +01:00
Marco Costalba 321320b081 Tidy up uci.cpp and siblings
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-04-26 13:23:47 +01:00
Marco Costalba 09d01ee9dc Tidy up benchmark.cpp
Node count is different just becuase now we don't log on
"bench.txt" file anymore so that we avoid some calls to
pretty_pv() that calls Position::do_move().

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-04-25 12:07:30 +01:00
Marco Costalba c9d7e99de6 Rename MOVES_MAX in MAX_MOVES
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-04-24 08:54:36 +01:00
Marco Costalba 1d368bbbdc Introduce and use SearchLimits
Pack a bit of global variables related to search limits in
a single struct.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-04-23 13:11:03 +01:00
Marco Costalba 786564068b Promote OptionsMap to a class
And add a bit of documentation too.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-04-16 10:49:20 +01:00
Marco Costalba 7f367e6019 Cleanup debug counters
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-04-13 18:51:56 +01:00
Marco Costalba 0c775fae4b Be sure to read options before to call trace_evaluate()
Otherwise in case we change an option with setoption and
then ask for "eval" command the evaluation is not updated.

Spotted by Justin Blanchard.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-03-01 13:32:42 +01:00
Marco Costalba bd33766da0 Add evaluation tracing code
This patch is based on Justin Blanchard's original
work and allows to breakdown evaluation in its sub terms and
show to the user.

Tracing code has zero speed impact when not used.

Note that tracing code is not thread-safe, but this
should not be a problem given the typical usage scenario.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-02-26 14:26:27 +01:00
Marco Costalba caa02b0e43 Small cleanup in execute_uci_command()
With a little fall out in siblings functions...

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-01-09 16:24:30 +01:00
Marco Costalba a8741bd59f Simplify set_option()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-01-09 15:15:52 +01:00
Marco Costalba 15153a1de7 Don't copy Position in pretty_pv()
Also let do_setup_move() don't reuse same StateInfo so that
we can remove the check about different StateInfo objects
before memcpy() in do_move.

Functional change due to harmless additionals
do_move() / undo_move() steps.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-01-09 12:55:22 +01:00
Marco Costalba b4acf83704 Ressurect move.cpp
Actually it is san.cpp renamed. Because now has the move
conversions functions and doesn't have any more the bulky
move_from_san(), it is better to call it move.cpp

Remove san.h while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-01-08 17:52:02 +01:00
Marco Costalba 82d5386435 Move uci move parsing under san.cpp
This partially reverts 1e7aaed8bc keeping the conversion
functions from/to move to uci string in the same file.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-01-08 15:53:49 +01:00
Marco Costalba 1e7aaed8bc Retire move.cpp
Move its functions where they belong.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-01-07 13:40:13 +01:00
Joona Kiiski b08ba446f6 Clean up position setup code
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-01-06 13:54:03 +01:00
Joona Kiiski d4ded09e17 Fix variable naming in prototypes at uci.cpp
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-01-05 23:41:08 +01:00
Marco Costalba 55b16593a4 Perft should return an int64_t not an int
Found by Louis Zulli with his super fast
hardware: 65M nodes/sec at perft !

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-01-05 21:13:21 +01:00
Marco Costalba f200f3ccd2 Another attempt at fixing Chess960
Keep the isChess960 flag inside Position so that is
copied with the Position, but esplicitly highlight the
fact that a FEN string has not enough information to detect
Chess960 in general case. To do this add a boolean argument
isChess960 to from_fen() function so to self document this
shortcoming of FEN notation.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2011-01-03 22:50:38 +01:00
Marco Costalba 6afcfd00f2 Retire uci_main_loop()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-12-13 20:38:41 +01:00
Marco Costalba 2d63f2157e Small cleanup in uci.cpp
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-12-13 20:29:40 +01:00
Marco Costalba 56de5ae561 Retire square_from_string()
And rename move_from/to_string() in a more specific
move_from/to_uci() that is a simple coordinate notation.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-12-13 20:29:38 +01:00
Marco Costalba f44aea7508 Retire "New Game" UCI option
Was introduced by 403db5a6e9
on 1/12/2009 to correctly handle "loose on time"
LSN filtering functionality, but is now unused.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-11-21 14:25:30 +01:00
Marco Costalba b06f0460a2 Retire uci.h and benchmark.h
Moved the single prototipes where are needed.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-11-07 13:31:33 +01:00
Marco Costalba d2ad5acddd Object OpeningBook doen't need to be global
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-11-07 13:12:48 +01:00
Marco Costalba bacb645939 Rewrite options handling in an object oriented fashion
Big rewrite and about 100 lines removed.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-11-05 06:10:05 +01:00
Marco Costalba fb50e16cdd Retire push_button() and button_was_pressed()
Directly access the underlying bool option.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-11-03 13:19:55 +01:00
Marco Costalba d607febb38 Fix MinGW warnings
I finally got SF to compile under MinGW (after adding pthread libraries)
and here are the fixed warnings.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-11-01 11:44:46 +01:00
Marco Costalba 19cf779629 Allocate RootPosition on the stack
And pass it as an argument.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-10-31 11:53:49 +01:00
Marco Costalba d74025a34e Update nodes after a do_move()
And also store the node counter in Position and not in Thread.
This will allow to properly count nodes also in sub trees with
SMP active.

This requires a surprisingly high number of changes
in a lot of places to make it work properly.

No functional change but node count changed for obvious reasons.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-10-31 11:22:40 +01:00
Marco Costalba debc815352 We need just one eval margin in search
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-09-14 18:06:10 +01:00
Marco Costalba 15d265cc66 Change evaluate() signature
Hide EvalInfo and return just the score and the margin.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-08-26 13:41:26 +01:00
Marco Costalba 79a28841f9 Move StartPositionFEN out of the header
It is not needed to have global visibility.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-08-19 18:22:48 +01:00
Marco Costalba 4aeffc8c9a Rename OnePly in ONE_PLY
Use enum values standard naming policy also for this one.

No fuctional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-08-19 13:48:20 +01:00
Joona Kiiski c0616d773d New Time management system
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-08-02 11:48:03 +01:00
Joona Kiiski 098ac5e44e Don't initialize psqt-tables when 'ucinewgame' is received
After 'Randomness' is retired, this is no longer necessary.

NOTE: Possibly some extra care is needed when tuning branch is synced

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-07-23 12:21:54 +01:00
Marco Costalba b6ab610e2f Remove redundant argument in think()
We don't need to pass side_to_move because we can get
it directly from the position object.

Note that in benchmark we always used to pass '0' and
it was a bug, but with no effect because was used only
in time[] and increment[], set always to 0 for both
colors.

Also additional small cleanup while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-07-15 17:14:30 +01:00
Marco Costalba a8b9c11f56 Revert "Use ply counter in Position object"
Search ply and game ply are rwo different things !

Revert bogus commit.

No functional change on bench, but it changes in real games
when engine sends all the moves up to current one.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-06-13 02:38:16 +01:00
Marco Costalba ab127028ed Do not pass threadID as argument of search() and evaluate()
Get it from the position instead.

A good semplification of function calling and a speedup too.

No functional change also with faked split.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-06-02 20:48:40 +01:00
Marco Costalba 2f6927ac08 Save threadID info in Position
This is the best place because when we split we do a
copy of the position and also threadID, once set in a
given position, never changes anymore.

Forbid use of Position's default and copy c'tor to avoid
nasty bugs in case a position is created without explicitly
setting the threadID.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-06-02 20:19:43 +01:00
Marco Costalba 6716337f40 Use ply counter in Position object
And avoid a redundant one passed as argument in
search calls.

Also renamed gamePly in ply to better clarify this
is used as search ply and is set to zero at the
beginning of the search.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-05-31 22:03:22 +01:00
Marco Costalba 9fc602bae7 Updated copyright year to 2010
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-03-20 11:27:07 +01:00
Joona Kiiski 2360c8aa2f Standardize set_option function
Previously input like "setoption name Use Search Log value true "
(note space at the end of the line) didn't work.

Now parse value same way as option name. This way we implicitly
left- and right-trim value.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-01-27 20:03:44 +01:00
Joona Kiiski 32bd6e44f0 Do not initialize RootPosition at startup
Initializing high-level object at startup is very dangerous,
because low-level snippets are not yet initialized.

For example Position's constructor calls find_checkers() which
calls attackers_to() which depends on various global bitboard arrays
which are not yet initialized. I think we are lucky not to crash.

RootPosition.from_fen(StartPosition); is called immediately after
all initializations are made at uci_main_loop() which is the
correct behaviour

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-01-27 20:00:28 +01:00
Joona Kiiski d0daa16769 Remove InfiniteSearch hack
With current search control system, I can see absolutely no
reason to classify fixed time search as infinite search.

So remove old dated hack

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-01-27 09:52:47 +01:00
Joona Kiiski 87303d7ed3 Remove last use of uip.eof()
Value of uip.eof() should not be trusted.
input like "go infinite searchmoves " (note space in the end of line)
causes problems.

Check the return value of (uip >> token) instead

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-01-27 09:52:15 +01:00
Marco Costalba 0ff91e16da Do not copy master position in split()
A pointer is enough because after a split point has been
setup master and slaves thread end up calling sp_search() or
sp_search_pv() and here a full copy of split point position is
done again, note that even master does another copy (of itself)
and this is done before any do_move() call so that master Position
is never updated between split() and sp_search().

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-01-25 12:46:08 +01:00
Marco Costalba 84ec1f7331 Better document how Position c'tor works
Renamed a bit the functions to be more clear what
we actually are doing when we craete a Position object
and explained how StateInfo works.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-01-25 12:04:00 +01:00
Marco Costalba 7c0679ad61 Fix 'position ..... moves ' parsing bug
If after 'moves' there is a space then we crash.

The problem is that operator>>() trims whitespaces so that
after 'moves' has been extract we are still not at eof()
but remaining string contains only spaces. So that the next
extarction operation uip >> token ends up with unchanged token
value that remains 'moves', this garbage value is then feeded
to RootPosition.do_move() through move_from_string() that does
not detect the invalid move value leading to a crash.

This bug is triggered by Shredder 12 interface under Mac that
puts a space after 'moves' without any actual move list.

Bug fixed by Justin Blanchard

After reviewing UCI parsing code I spotted other possible weak
points due to the fact that we don't test if the last extract
operation has been succesful. So I have extended Justing patch
to fix the remaining possible holes in uci.cpp

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2010-01-07 11:59:32 +01:00
Marco Costalba 403db5a6e9 Don't clear hash at the beginning of a new game
After 900 games at 1+0
Mod vs Orig +217 =480 -196 +8 ELO

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-12-02 15:13:13 +01:00
Marco Costalba a530fc2b60 Use a more standard perft UCI interface
Call directly 'perft 6' to search up to depth 6*OnePly
instead of the old 'perft depth 6'.

It is more in line to what other engines do. Also a bit
of cleanup while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-11-13 10:35:56 +01:00
Marco Costalba ef6fca98a0 Define Score as an enum
Increases performance because now we use one integer
for both midgame and endgame scores.

Unfortunatly the latest patches seem to have reduced a bit
the speed so at the end we are more or less at the same
performance level of the beginning. But this patch series
introduced also some code cleanup so it is the main reason
we commit anyway.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-11-09 08:43:34 +01:00
Marco Costalba 1ae8c59c0b Convert Position to use Score struct
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-11-07 12:40:48 +01:00
Joona Kiiski fa49311b36 Implemented perft
Patch from Joona with extension to benchmark and inclusion
of Depth(0) moves generation by me.

Note that to test also qsearch and in particulary checks
generations a change in the end condition is needed.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-11-01 17:05:00 +01:00
Marco Costalba 7622793080 Small tidy up of previous patch
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-07-10 18:50:43 +01:00
Tord Romstad 174b40c28d Strip whitespace from beginning of string sent to set_option_value().
It turned out that the input sent to set_option_value() when it is called by
set_option() in uci.cpp always started with at least one whitespace. In most
cases, this is not a problem, because the majority of UCI options have numeric
values. It did, however, cause a problem for UCI options with non-numerical
values, like options of type CHECK and COMBO. In particular, changing the
value of an option of type CHECK didn't work, because the comparisons with
"true" and "false" would always return false. This means that the "Ponder"
and "UCI_Chess960" options haven't been working for a while.
2009-07-10 18:34:56 +02:00
Marco Costalba 8225fdd5bb Give proper credit to Joona
Stockfish would not be as where is now without his
contributions.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-06-18 07:35:23 +01:00
Marco Costalba d2c2af9e1c Remove global variables from search.h
Globals are not really needed, so redefine as locals.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-06-12 13:10:40 +02:00
Marco Costalba 5b1316f7bb Detach the state when copying a position
In Position we store a pointer to a StateInfo record
kept outside of the Position object.

When copying a position we copy also that pointer so
after the copy we have two Position objects pointing
to the same StateInfo record. This can be dangerous
so fix by copying also the StateInfo record inside
the new Position object and let the new st pointer
point to it. This completely detach the copied
Position from the original one.

Also rename setStartState() as saveState() and clean up
the API to state more clearly what the function does.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-29 17:23:21 +02:00
Marco Costalba 3b1e64ab72 Small code style massage in uci.cpp
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-20 12:40:07 +02:00
Marco Costalba 5c81602d14 Update copyright year
We are well in 2009 already.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-07 14:54:40 +02:00
Marco Costalba a88e762b4e Rewrite the way application exits
Centralize in a single object all the global resources
management and avoid a bunch of sparse exit() calls.

This is more reliable and clean and more stick to C++ coding
practices.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-07 12:59:19 +02:00
Marco Costalba 2155fb7825 Be sure book file is closed before we leave
Move closing of file in Book destructor. This
guarantees us against leaving the file open under
any case and simplifies also Book use.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-07 09:27:38 +02:00
Marco Costalba aa5c375ca9 Fix a very old UCI option parsing bug
We currently fail on an option with a sapece in the name,
as example

setoption name Clear Hash

returns error message "Option Clear not found". This
patch fixes this off-by-one type bug.

Thanks to Joona for spotting this.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-02 11:52:49 +01:00
Marco Costalba 72af519e7f When asked for position key print it as an hex value
Merged from Glaurung current development snapshot.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-03-24 10:50:13 +01:00
Marco Costalba 55f9afee2a Fix a subtle bug due to the StateInfo pointer became stale
There was one occurence when the StateInfo variable went
out of scope before the corresponding Position object.

This yelds to a crash. Bug was not hit before because occurs
only when using an UCI interface and not the usual benchmark.

The fix consists in copying internally the content of the
about to stale StateInfo.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-23 21:45:12 +01:00
Marco Costalba 8f59de48f5 Introduce StateInfo instead of UndoInfo
We don't backup anymore but use the renamed StateInfo
argument passed in do_move() to store the new position
state when doing a move.

Backup is now just revert to previous StateInfo that we know
because we store a pointer to it.
Note that now backing store is up to the caller, Position is
stateless in that regard, state is accessed through a pointer.

This patch will let us remove all the backup/restore copying,
just a pointer switch is now necessary.

Note that do_null_move() still uses StateInfo as backup.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-22 21:18:50 +01:00
Marco Costalba 5dc2312121 Update copyright info
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:20 +02:00
Marco Costalba 18860cce40 Improve time managment
If we need some more and we are in time
advantage take it.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-09-18 12:27:09 +02:00
Marco Costalba d583176baf Pass also opponent time to think()
This patch modifies think() signature to accept
also opponent time. This is needed for future
changes to time managment.

Still no functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-09-18 12:27:09 +02:00
Marco Costalba 6c64f68ccf Rewrite ucioptions.cpp to use C++
Instead of old-style C string functions use standard
library to greatly streamline the implementation.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-09-01 14:05:02 +02:00
Marco Costalba 6ef44d4c4e Finally remove UCIInputParser class altogether
Class UCIInputParser is now a typedef of a std::istringstream,
this greatly simplifies the code, especially the many conversions
from string to integer are now handled automatically by the
stream instead of relying on a chunk of C-style atoi() calls.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-09-01 08:16:17 +02:00
Marco Costalba d22aeb1cc0 Use a string stream in UCIInputParser
Use a std::istringstream instead of an home
grown string tokenizer code.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-09-01 08:06:34 +02:00
Marco Costalba b8e487ff9c Avoid casts to handle isspace() arguments
Use proper standard conversion to deal
with negative values of a char.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-09-01 08:03:21 +02:00
Marco Costalba bb751d6c89 Initial import of Glaurung 2.1 2008-09-01 07:59:13 +02:00