uci2wb.git
5 years agoUpdate changelog
H.G.Muller [Sat, 8 Dec 2018 22:50:49 +0000]
Update changelog

5 years agoFix periodic updates
H.G.Muller [Sat, 8 Dec 2018 22:36:34 +0000]
Fix periodic updates

The move and move number were not available for the stat01 commands,
because the code to collect the moves for the go-searchmoves command
would prevent parsing of the entire info command. So this collection
is now done last, and also made responsible for extracting the
current move.

5 years agoUpdate change log
H.G.Muller [Sat, 8 Dec 2018 22:03:40 +0000]
Update change log

5 years agoPrint compliant error message on invalid command
H.G.Muller [Sat, 8 Dec 2018 21:13:29 +0000]
Print compliant error message on invalid command

UCI2WB now prints the compliant eror message when it gets an unrecognized
command. To prevent spurious error messages it now recognizes some more
ignored commands too.

5 years agoExercise UCCI option 'newgame' also after 'isready' handshake
H.G.Muller [Sat, 8 Dec 2018 20:58:46 +0000]
Exercise UCCI option 'newgame' also after 'isready' handshake

The patch that moved the sending of 'ucinewgame' to after the initial
'isready' handshake overlooked that this was actually the else-clause
of an if-statement that emitted 'option newgame' for UCCI. Now it is not
really clear when the latter should be emitted, as it seems to be ignored
even in Elephant Eye, but treating it as a variant of 'ucinewgame' seems
best. Accidentally the statement behind it did not suffer from being
in the else-clause, as it processed the UCI_Variant option, which does
not exist in UCCI anyway.

5 years agoDo not queue ignored commands
H.G.Muller [Sat, 8 Dec 2018 16:26:01 +0000]
Do not queue ignored commands

Commands that will be ignored (such as 'xboard') are now recognized
with the easy commands, as it makes little sense to send them to the
engine thread just to be ignored. The 'accepted' and 'rejected' commands
are now also recognized and treated this way. In addition, commands are
now only echoed when they are queued, in debug mode: as the GUI thread
can only block on reading from the GUI we can be sure that all commands are
read as soon as they arrive, and echoing them just clutters the debug logs.

5 years agoDebug recent changes
H.G.Muller [Sat, 8 Dec 2018 14:44:48 +0000]
Debug recent changes

Bugs with respect to flushing output to the GUI and resetting 'searching'
after an engine move were fixed. Some new debug print statements were left
in. Playing with and without pondering against another engine now seems to
work. As does the move-now command, and switching off pondering while it
is doing it. Analysis also works, even with move exclusion.

5 years agoFix pondering with incremental TC
H.G.Muller [Sat, 8 Dec 2018 13:29:28 +0000]
Fix pondering with incremental TC

To calculate the time left on our clock after giving a move, for the
purpose of starting a ponder search for the next one, we subtracted the
increment instead of adding it.

5 years agoRefrain from starting analysis search if all moves excluded
H.G.Muller [Sat, 8 Dec 2018 13:24:10 +0000]
Refrain from starting analysis search if all moves excluded

LaunchSearch() now tests for any moves being still enabled before
starting an analysis search. (If there aren't sm == 1.) This means the
last reason to skip LaunchSearch() after DoCommand() has disappeared.

5 years agoHandle periodic updates with easy commands
H.G.Muller [Sat, 8 Dec 2018 12:50:18 +0000]
Handle periodic updates with easy commands

The poll for periodic updates should not cause the analysis search to abort,
which queued commands would do.

5 years agoChange StopPonder() into more general StopSearch()
H.G.Muller [Sat, 8 Dec 2018 12:42:53 +0000]
Change StopPonder() into more general StopSearch()

As StopPonder was only still used to unconditionally abort searches of
any kind, it is changed into a general StopSearch() routine that handles
the tasks that otherwise were performed before calling it. In particular
it refrains from stopping a search if none is going on, and conditionally
(based on its argument) sets 'searching' to idle if the move the search
will come up with has to be ignored.

5 years agoFix pause/resume
H.G.Muller [Sat, 8 Dec 2018 11:59:02 +0000]
Fix pause/resume

Tne 'pause' and 'resume' commands are executed in the GUI thread for
instant obedience. But they have to take care that a move produced by
an aborted think is ignored (by setting searching = 0 before stopping it),
and that the engine thread has to be signalled to restart it.

5 years agoAbandon backlogging of options
H.G.Muller [Sat, 8 Dec 2018 11:26:21 +0000]
Abandon backlogging of options

Now that there is a general command queue to backlog commands that
arrive during thinking, there is no need to do this separately for
engine options. Instead these are now treated with other 'difficult'
commands by the engine thread, in DoComand(). The adapter options
still count as easy commands.

5 years agoLet engine thread parse difficult commands
H.G.Muller [Sat, 8 Dec 2018 11:00:48 +0000]
Let engine thread parse difficult commands

The design of the adapter is completely changed: the engine thread is
made responsible for parsing and execution of all commands that cannot
be processed during a search. To this end it alternates between reading
from the engine (while the engine is searching, or should respond to a
'uci' or 'isready' query) and from the command queue (which is emptied
before we dedicate to relaying ponder output). Searches are terminated
by the GUI thread when a command arrives that would interrupt the search,
so that the engine thread will start looking at the command queue again.
  Syncing threads to wait for an engine reply is replaced by just doing
a (blocking) read for engine output in the same threat, and having the
processing routine return once the answer has arrived (and is processed).
Instead the Sync pipe is now used to block reading of the command queue
when this is empty.
  This change breaks several of the less elementary commands.

Fix command queue

5 years agoMove Engine2GUI to a more convenient place
H.G.Muller [Sat, 8 Dec 2018 09:27:20 +0000]
Move Engine2GUI to a more convenient place

The main loop of the engine thread is moved to a place in the code
where future changes would require fewer forward calls to other routines.

5 years agoLaunch searches at end of GUI loop
H.G.Muller [Sat, 8 Dec 2018 09:21:03 +0000]
Launch searches at end of GUI loop

The loop for interpreting GUI commands is restructured by launching
searches at the bottom of it rather than at the top. As it was an
infinite loop anyway this only eliminates the first call to LaunchSearch(),
which is OK as the engine would never have to search before any commands
were received.
  As this change brought the 'nomove' label to the top of the loop,
the 'goto's to it could be replaced by 'continue's, and the label deleted.
That for engines that cannot ponder the 'easy' and 'hard' commands now
skip LaunchSearch() is OK, as LaunchSearch() would not do anything in
that case.

5 years agoEliminate continues from GUI loop
H.G.Muller [Sat, 8 Dec 2018 09:12:13 +0000]
Eliminate continues from GUI loop

The 'continue' statements at the end of the code sections for handling
specific commands, which caused matching for the remaining commands after
it to be skipped, are now deleted, and the code to be skipped is placed
in an 'else' clause. This to make restructuring of the GUI loop easier.
  The 'continue' statements for 'easy' and 'hard' commands were left,
as these were harmless: it doesn't matter whether we call LaunchSearch()
after them or not.

5 years agoPut launching of searches in a separate routine
H.G.Muller [Sat, 8 Dec 2018 09:02:49 +0000]
Put launching of searches in a separate routine

The code section that tested if the engine should search, and would
start the required search if this was the case, is now put in a routine
LaunchSearch(). This is then called from the infinite loop that handles
the GUI commands (where it was located before).

5 years agoLet 'searching' also indicate thinking state
H.G.Muller [Sat, 8 Dec 2018 08:54:37 +0000]
Let 'searching' also indicate thinking state

The flag 'think'  is eliminated, and its function is now indicated by
giving 'searching' the value 3. This makes 'searching' now a complete
state indicator, which indicates if we are idle, pondering, analysing
or thinking.

5 years agoCombine function of 'searching' and 'pondering' flags
H.G.Muller [Fri, 7 Dec 2018 22:20:36 +0000]
Combine function of 'searching' and 'pondering' flags

The vaiable 'searching', formerly used only to indicate if the engine was
doing an analysis search, now indicates pondering if it has value 1, and
analysis if it has value 2. This to simplify the state logic.

5 years agoPass command to DoCommand through global command queue
H.G.Muller [Fri, 7 Dec 2018 22:02:48 +0000]
Pass command to DoCommand through global command queue

Rather than passing the command to process as a parameter to DoCommand,
we now append it to a global 'command queue', from which DoCommand() then
reads the first line. This in preparation for letting the engine thread
handle the difficult commands.

5 years agoParse 'difficult' commands in separate routine
H.G.Muller [Fri, 7 Dec 2018 21:35:01 +0000]
Parse 'difficult' commands in separate routine

The parsing of (most) commands that can only be executed when not searching
is now put in a separate routine DoCommand(). This in preparation for
having the engine thread do this.

5 years agoPut handling of engine output in separate routine
H.G.Muller [Fri, 7 Dec 2018 14:02:14 +0000]
Put handling of engine output in separate routine

The reading, decoding and handling of the engine output is now put in
a routine HandleEngineOutput(), which is still an infinite loop that
wakes up a blocked GUI thread after a 'uciok', 'readyok' or 'bestmove'
command. This in preparation of a new design, where it would break out
of the loop and return after these commands, to let its caller process
any queued GUI commands.

5 years agoDo all input through one ReadLine() routine
H.G.Muller [Thu, 6 Dec 2018 20:23:49 +0000]
Do all input through one ReadLine() routine

Some duplicate code now is made into a subroutine, to which we pass
the stream from which it should read a line, and the buffer to hold
the result. It returns whether the read was succesful (i.e. no EOF).
As this can also easily fake engine output from a file, the special
routine GetChar()we had for this could be abolished.

5 years agoImplement option ' ponder always'
H.G.Muller [Sun, 2 Dec 2018 10:40:18 +0000]
Implement option ' ponder always'

UCI2WB can now also be configured to let the UCI engine ponder even
in force mode. This is useful during OTB tournaments, when the GUI
is still in book (and thus keeps the engine in force mode). Because
there is no ponder move at this stage, the engine will be set pondering
on the opponent's position, and the ponder move is set to an empty
string to force a ponder miss afterwards.

5 years agoImplement extended UCI info string variant option
H.G.Muller [Thu, 4 Oct 2018 09:06:52 +0000]
Implement extended UCI info string variant option

To allow UCI engines to also define variants with different board size
and parent variant, an extended version of the info-string-variant command
is recognized. This can also incluse 'files', 'ranks', 'pocket' and
'template' fields. The default values for these are 8, 8, 0 and "fairy",
so that we remain compatible with the old info-string-variant command when
the new fields are absent.

6 years agoSupport Scorpio bitbases
H.G.Muller [Wed, 31 Jan 2018 13:37:10 +0000]
Support Scorpio bitbases

The CECP EGT flavor 'scorpio' is now translated to the UCI option
'bitbases path'. This is a bit awkward because, unlike all other flavors,
the UCI option name does not start with the flavor name. So new code had
to be added to recognize this as an exception. In addition, the UCI option
is not universally used by engines supporting Scorpio EGBB.

6 years agoAdd support for robbobases
H.G.Muller [Mon, 29 Jan 2018 10:43:02 +0000]
Add support for robbobases

The UCI options RobboTripleBaseDirectory and RobboTotalBaseDirectory are
now recogized as defining the egtpath for flavors 'robbtripple' and
'robbototal', respectively. For this the general EGT-handling code had to
be adapted to be able to append 'BaseDirectory' instead of '(Tb)Path' to
the flavor for setting the option, and clipping this off for extracting
the flavor name. This is achieved by using the part of the standard option
in the list of EGT formats up to the first capital as CECP flavor name,
and match the flavor name in the egtpath command with the list, to retrieve
the full name from there.

6 years agoChange UCI_Variant name from threecheck to 3check
H.G.Muller [Fri, 27 Oct 2017 20:17:10 +0000]
Change UCI_Variant name from threecheck to 3check

This to stay in sync with a similar change in multi-variant Stockfish,
which now makes the UCI and CECP names equal.

7 years agoSuppress setup command also in Suicide ad Losers
H.G.Muller [Wed, 1 Feb 2017 16:47:29 +0000]
Suppress setup command also in Suicide ad Losers

Variants suicide and losers are added to the list of exceptions for which
the UCI 'info string variant' command should not result in a CECP 'setup'
command.

7 years agoBump version to 3.0
H.G.Muller [Sat, 24 Dec 2016 21:17:00 +0000]
Bump version to 3.0

7 years agoDisarm printing of 'uci' to the GUI in debug mode
H.G.Muller [Wed, 4 Jan 2017 17:06:29 +0000]
Disarm printing of 'uci' to the GUI in debug mode

A '#' sign is now printed when UCI2WB reports it sent the 'uci' command.

7 years agoFix egtpath for Gaviota EGT
H.G.Muller [Wed, 4 Jan 2017 17:04:10 +0000]
Fix egtpath for Gaviota EGT

The standard option name for the Gaviota path in UCI is GaviotaTbPath,
ot GaviotaPath. So we have to strip off the 'Tb' part, and add it again,
when converting to and from the CECP name.

7 years agoSuppress printing duplicat PVs (for multi-PV)
H.G.Muller [Tue, 3 Jan 2017 15:27:50 +0000]
Suppress printing duplicat PVs (for multi-PV)

UCI resends all PVs if one new PV arrives,possibly with different depths.
ow any PV of a depth less than the best depth seen from the current search
so far will be ignored. Duplicats of the same depth and score will also
be ignored.

7 years agoDiversify UCI string options into -string, -path and -file
H.G.Muller [Tue, 3 Jan 2017 11:59:46 +0000]
Diversify UCI string options into -string, -path and -file

Heuristics is applied to the option name, in order to guess whether UCI
string options are filenames or directory paths. In which case they are
translated into CECP -file and -path options, so XBoard will give them
the appropriate browse button.

7 years agoFix strcasestr for Windows
H.G.Muller [Sat, 31 Dec 2016 19:37:53 +0000]
Fix strcasestr for Windows

The strcasestr definition, which we have to supply ourselves to make
the Windows version compilable, was not upto the task of having a
string constant as first argument, and a string that needs decapitalization
as the second argument.

7 years agoPrint egt feature
H.G.Muller [Sat, 24 Dec 2016 18:39:57 +0000]
Print egt feature

Options of the form xxxPath for xxx = Nalimov, Gaviota of Syzygy are now
intercepted, and the EGT type name 'xxx' collected, for printing as a
single egt feature when 'uciok' is received.

7 years agoFix string options with empty default
H.G.Muller [Sat, 24 Dec 2016 18:41:11 +0000]
Fix string options with empty default

When sscanf finds nothing after 'default', it does not touch the target
array at all, rather than putting an empty string in it. So the target
is now initialized to an empty string before the sscanf.

7 years agoProcess CECP egtpath command
H.G.Muller [Sat, 24 Dec 2016 14:47:13 +0000]
Process CECP egtpath command

The 'egtpath TYPE PATH' command causes the UCI option TYPEPath to be set
to VALUE.

7 years agoFix -var option with UCI_Chess960
H.G.Muller [Fri, 23 Dec 2016 15:17:58 +0000]
Fix -var option with UCI_Chess960

The variant specified in the -var option would be overruled by the
"normal,fischerandom" emitted later under the influence of a UCI_Chess960
option. This is now solved by always sending the variants feature on 'uciok'.
The varList is now initialized to the -var string, and overwritten by the
protocol defaults before sending 'uci' only when it is still empty.
A UCI_Variants option then gets the chance to overwrite this, while
a UCI_Chess960 option will append "normal,fischeradom" to the list.

7 years agoMake sure we resign when engine reports we are checkmated
H.G.Muller [Mon, 5 Dec 2016 18:47:05 +0000]
Make sure we resign when engine reports we are checkmated

When a UCI engine is set thinking in a checkmated position, the PV
necessarily is empty, and instead of printing an empty 'pv' field in
as pv info, it might omit it alltogether. So we even accept a 'mate 0'
score when there is no PV, so that a following 'bestmove 0000' will
be interpreted as a loss (sending 'resign'), rather than a draw
(sending 1/2-1/2).

7 years agoDisplay error message when engine dies
H.G.Muller [Mon, 5 Dec 2016 08:29:13 +0000]
Display error message when engine dies

UCI2WB used to exit silently when reading from the engine produced an EOF
response (indicating the engine process died). This then evoked the standard
XBoard fatal error "... engine exited uexpectedly". Now it sends a
'tellusererror' command to the GUI to suppress the standard popup, and
to clearly indicate that it was because of a crash in the engine rather
than in the adapter.

7 years agoImprove efficiency
H.G.Muller [Sat, 3 Dec 2016 10:42:41 +0000]
Improve efficiency

The commands usermove, time and otim are now matched first, because
these are the commands used during game play, when response time and
CPU usage are relevant concerns.

7 years agoBuffer 'setoption' commands until engine done thinking
H.G.Muller [Thu, 1 Dec 2016 20:17:11 +0000]
Buffer 'setoption' commands until engine done thinking

UCI does not allow setting of options during search after all. So all
'setoption' commands are now first collected in a memory buffer. During
ponder or analysis the search is then stopped immediately to flush that
buffer to the engine, in a new routine Release(). This routine will
also (re)start a ponder search if one is called for. During thinking,
finishing the search has priority. So only Release() the buffer contents
when a search finishes (immediately after receiving 'bestmove').
To deal with race conditions we also flush the buffer in the GUI thread,
after waiting for thinking to finish, just in case.
  The WB 'easy' and 'hard' command implicitly set the Ponder option,
and this is treated by the hack of injecting fake 'option' commands in the
input stream, which then are subjected to the same buffering scheme.
  Because waiting for thinking termination might now not happen at all
(if we only receive commands that can be handled instantly), a test for
search termination was added immediately after reading the command,
so that every command can now be aware whether thinking is in progress.

7 years agoFix instant commands during think after ponder hit
H.G.Muller [Thu, 1 Dec 2016 13:53:48 +0000]
Fix instant commands during think after ponder hit

The new method of suspending command processing only after peeking at
the next command to see if it should terminate the search was not
yet working after a ponder hit turned a ponder search into thinking.

7 years agoProcess all innocent commands immediately (fixes pause/resume)
H.G.Muller [Thu, 1 Dec 2016 13:41:05 +0000]
Process all innocent commands immediately (fixes pause/resume)

To prevent that commands received during thinking will halt command
processing,eclipsing later instant commands, all commands that merely
alter a settings value in adapter or engine are now immediately executed.
UCI engines should be able to handle 'setoption' commands even during
thinking, so explicit or implicit (easy/hard) settings changes are
immediately relayed to the engine as well.
 The 'pause' and 'resume' commands are now also treated immediately;
waiting with that until the engine is done thinking subverted the
intention of the 'pause' command.
 Commands that would never be sent when an engine is thinking are still
left with the commands that require thinking to complete, as for those
thisdoes not matter.

7 years agoAlso treat 'result' command immediately
H.G.Muller [Wed, 30 Nov 2016 13:17:55 +0000]
Also treat 'result' command immediately

WinBoard has the nasty habit of sending a 'result' command just before
'quit' when it is closed while the engine is thinking, without putting
the engine in force mode first. So this command has to abort thinking too.
To prevent this will start a ponder search, 'result' now puts us in
force mode.

7 years agoImplement UCI_AnalyseMode option
H.G.Muller [Wed, 30 Nov 2016 11:09:00 +0000]
Implement UCI_AnalyseMode option

An engine option of the form "??I_AnalyseMode" is now assumed to be the
standard check option UCI_... or USI_... (OK, that is a bit flaky).
It will not be reported as option feature, and will be automatically set
during analysis.

7 years agoTreat EOF same as quit command
H.G.Muller [Wed, 30 Nov 2016 08:22:55 +0000]
Treat EOF same as quit command

A EOF during reading from the GUI caused UCI2WB to exit through a different
path as a 'quit' command. Now the EOF detection just fakes a 'quit -1'
command was received, and then processes that as usual. This means it
also causes proper termination of the engine when it occurs during thinking
(sending 'stop'). The '-1' appendage to the command allows the 'quit'
handling to return an error code.

7 years agoTreat 'quit', 'force' and '?' commands immediately
H.G.Muller [Wed, 30 Nov 2016 08:02:50 +0000]
Treat 'quit', 'force' and '?' commands immediately

The blocking of input during thinking made it also insensitive to 'quit'.
This would cause hanging engine processes when the GUI was closed and would
kill the adapter because it did not respond to 'quit' in time. The Sync()
call that waits for the engine's 'bestmove' is now deferred until after
reading input (executed conditionally through a 'think' flag, so that
it only happens during thinking), so that we can peek at the first command
that arrives during thinking. If it is one of the 'immediate' commands
(?, quit or force), a 'stop' command is sent to the engine before we
start waiting for the 'bestmove', which then never should take long.
 Draw offers could potentially arrive during thinking as well, interefering
with this mechanism by eclipsing a following ?/quit/force. As these would
just set the drawOffer flag for processing during the next move, these
are now fully processed immediately.

7 years agoPrint everything sent to engine in debug mode v2.3
H.G.Muller [Thu, 10 Nov 2016 10:38:08 +0000]
Print everything sent to engine in debug mode

Now the macro EPRINT makes this easy we make sure that everything sent to
the engine is also reported in a comment to the GUI, when the debug
option is on.

7 years agoSimplify debug printing
H.G.Muller [Thu, 10 Nov 2016 10:13:19 +0000]
Simplify debug printing

The duplicats of each print statement to the engine to (optionally) print
debug information are now generated automatically by a single macro EPRINT.

7 years agoPrint newline after 'position moves' instead of before 'go'
H.G.Muller [Thu, 10 Nov 2016 09:55:41 +0000]
Print newline after 'position moves' instead of before 'go'

The '\n' between position-moves and go was printed with the latter
to avoid a separate printf for it after the move list, but this obfuscated
the code, and was a show stopper for more elegant printing of debug info.

7 years agoFix commands during analysis (MultiPV option!)
H.G.Muller [Thu, 10 Nov 2016 09:12:11 +0000]
Fix commands during analysis (MultiPV option!)

UCI2WB could not handle spurious commands while analyzing: these would
start a new search without first terminating the old one. Only the commands
allowed in analysis mode (exit, usermove, and in/exclude) were handled
correctly. Unfortunately XBoard sometimes sends spurious 'accepted' commands
during analysis, in violation of the CECP specs. All such non-compliant
commands are now ignored. And the 'option' command will also abort an
ongoing analysis search, to allow altering the MultiPV setting during
analysis. (Something XBoard also does.)

7 years agoSuppress 'setup' command for some standard variants
H.G.Muller [Thu, 10 Nov 2016 08:55:40 +0000]
Suppress 'setup' command for some standard variants

Receiving an 'info string variant' from the engine now not automatically
leads to emission of a 'setup' command to the GUI. Because currently such
a setup command contains defaults for info not supplied in the 'info'
command, such as holdings size and pieceToChar, we suppress this in some
standard variants where this would be harmful (such as crazyhouse).
Such that the GUI does not get wrongly configured when playing these
variants with legality testing off. Before, the setup command was
only suppressed in variant normal.

7 years agoBump version to 2.3
H.G.Muller [Tue, 8 Nov 2016 21:29:32 +0000]
Bump version to 2.3

7 years agoDefine strcasestr for Windows
H.G.Muller [Tue, 8 Nov 2016 21:27:45 +0000]
Define strcasestr for Windows

The MinGW compiler apparently does not have this function.

7 years agoUpdate README file (changelog) and man page
H.G.Muller [Tue, 8 Nov 2016 21:01:16 +0000]
Update README file (changelog) and man page

7 years agoImplement CECP 'setup' command
H.G.Muller [Sun, 6 Nov 2016 13:29:08 +0000]
Implement CECP 'setup' command

On reception of an "info string variant NAME startpos FEN" from the engine
UCI2WB will now send "setup (-) 8x8+0_fairy FEN" to the GUI, to make
engine-defined variants also work with UCI engines. Correct operation
required sending of an 'isready' command to the engine after setting
the UCI_Variant option (which evokes the 'info string' response),
and stalling processing of GUI commands until the 'readyok' response,
to prevent early processing of a following 'ping' before the engine
got time to submit the reply. This way the 'info string' response
can be optional. When variant ="chess" the 'info string' is ignored,
as such a setting of UCI_Variant only occurs in response to 'new',
and never to 'variant'.

7 years agoConfigure XBoard to use UCI2WB as uxiAdapter in make-install
H.G.Muller [Sun, 6 Nov 2016 11:29:42 +0000]
Configure XBoard to use UCI2WB as uxiAdapter in make-install

The install target of the Makefile now invokes XBoard to set its
-uxiAdapter option for the current user to a value suitable for
usig UCI2WB.

7 years agoImplement CECP 'computer' command
H.G.Muller [Sun, 6 Nov 2016 11:15:31 +0000]
Implement CECP 'computer' command

Remember if the 'computer' command was received from the GUI, and use
this info when setting the UCI_Opponent option to distinguish 'human'
and 'computer' as first word, instead of the uniformative 'none'.
The implemntation assumes 'computer' would be sent before 'name', which
XBoard does (but the CECP specs do not guarantee).

7 years agoSupport UCI_Opponent option
H.G.Muller [Sun, 6 Nov 2016 10:54:30 +0000]
Support UCI_Opponent option

The UCI_Opponent option is now recognized, and its option feature is
suppressed. Instead its presence is remembered, and will lead to its
setting on reception of a CECP 'name' command. The feature name=1
is emitted at startuptosolicitsuch a command.

7 years agoDo not transform FEN when UCI_Variant option is supported
H.G.Muller [Sat, 5 Nov 2016 12:54:10 +0000]
Do not transform FEN when UCI_Variant option is supported

For USI FENs have to be translated to SFEN by putting the holdings
after the side-to-move indicator. This was done for any FEN that specified
holdings (probably to accomodate the Seirawan Chess version of Komodo).
But in Crazyhouse for Stockfish this wrecks things. The announcement
of a UCI_Variant option now suppresses this transformation.

7 years agoImplement UCI_Variant option
H.G.Muller [Sat, 5 Nov 2016 12:45:51 +0000]
Implement UCI_Variant option

A UCI combo option UCI_Variant is now recognized as special, and translated
to 'feature variant=...' rather than 'feature option="UCI_Variant ..."'.
The CECP 'variant' command now leads to setting of this option, while on
the 'new' command the option is reset to 'chess'.
  The variant names are transmitted as given, except for 'chess',
which is traslated to 'normal', and 'threecheck' (CECP: 3check).

7 years agoBump version to 2.2
H.G.Muller [Wed, 21 Sep 2016 21:41:52 +0000]
Bump version to 2.2

7 years agoUpdate README file
H.G.Muller [Wed, 21 Sep 2016 21:41:19 +0000]
Update README file

7 years agoAdd description of -var option to man page
H.G.Muller [Wed, 21 Sep 2016 21:20:02 +0000]
Add description of -var option to man page

7 years agoUpdate man page
H.G.Muller [Wed, 21 Sep 2016 21:03:39 +0000]
Update man page

The manual page is updated with
- mentioning of the Arena960 dialect and -f flag to trigger it
- discussion of byoyomi TC, and the options to force it
- replacing the defunct USI specs URL by a valid one on my own website

7 years agoSubtract byoyomi from wtime and btime
H.G.Muller [Wed, 21 Sep 2016 13:05:13 +0000]
Subtract byoyomi from wtime and btime

USI engines think byoyomi comes in addition to their time on the clock,
so the time passed from the GUI in CECP must be decreased by the byoyomi
to let the engine know how close it is to forfeit.

7 years agoSend game result to USI engines
H.G.Muller [Wed, 21 Sep 2016 12:42:20 +0000]
Send game result to USI engines

The USI 'gameover' command is now used as translation of the CECP
'result' command, to relay the result to the engine. To decide how
the absolute game result (white/black) is translated to a relative one
(win/lose), the side last moved for is used as indication, and remembered
whenever the engine is set thinking on a move (as it could already be
switched to force mode at the time the 'result' command is received).

7 years agoHandle USI win claims
H.G.Muller [Wed, 21 Sep 2016 12:26:07 +0000]
Handle USI win claims

USI engines can emit 'bestmove win' to claim a win, e.g. because
of the point count in an impasse situation. This is traslated to
a CECP result claim in favor of the side to move, with REASON "claim".

7 years agoSplit byoyomi options over lines
H.G.Muller [Wed, 21 Sep 2016 12:22:36 +0000]
Split byoyomi options over lines

7 years agoBump version to 2.1
H.G.Muller [Wed, 7 Sep 2016 18:56:54 +0000]
Bump version to 2.1

7 years agoAdd option Byoyomi
H.G.Muller [Wed, 7 Sep 2016 18:44:25 +0000]
Add option Byoyomi

In USI (-s) mode, UCI2WB now announces an option Byoyomi, which can
be used to define a hard byoyomi when the the option Floating Byoyomi
is off. Setting it to N is equivalent to a third argument " byoyomi N".
With N < 0 the option is switched off.

7 years agoAdd option 'Floating Byoyomi'
H.G.Muller [Mon, 5 Sep 2016 19:48:22 +0000]
Add option 'Floating Byoyomi'

In USI (-s) mode an option 'Floating Byoyomi' will be announced, which
will force the 'suffix' to the 'go' command to specify a byoyomi equal
to a reasonable time to think (timeLeft/40 + inc). This can be used as
a work-around to let engines that ignore the time left and always think
they are playing in byoyomi (a common misery in USI engines) work reasonably
well under incrementalor sudden-death TC. This then removes the need to
specify the suffix on the UCI2WB command line.

7 years agoMake suffix an array
H.G.Muller [Wed, 7 Sep 2016 18:52:48 +0000]
Make suffix an array

The suffix to the 'go' command is now declared as array rather than
pointer, so that it can be easily printed in. (Before it could be made
to point to argv[3] if needed, and be NULL otherwise, but we want to
add some options that would create a suffix dynamically.)

7 years agoPut LDFLAGS at end of compile command
H.G.Muller [Mon, 5 Sep 2016 19:33:03 +0000]
Put LDFLAGS at end of compile command

Pointed out by Logan Rosen.

7 years agoSupply time and node count for engines that do not give it
H.G.Muller [Tue, 14 Jun 2016 09:07:29 +0000]
Supply time and node count for engines that do not give it

By default thinking time and nodecount were set to 0, but this made
XBoard interpret Thinking Output with score 0 as an info string, which
was undesirable. So the node count is now 1 by default, while the time
could be measured by UCI2WB itself (as it was already recoding startTime
of all searches).

7 years agoJoin name and version when in separate 'id' commands
H.G.Muller [Sat, 21 May 2016 16:38:58 +0000]
Join name and version when in separate 'id' commands

If an engine issues an "id version" command when an "id name" was already
received, a new 'myname' feature is emitted that contains both name and
version number. This is supposed to overrule the bare name in the myname
feature emitted because of the "id name" command.

8 years agoSet suspected non-standard Chess960 check options
H.G.Muller [Tue, 12 Apr 2016 18:38:24 +0000]
Set suspected non-standard Chess960 check options

Any check-type option containing the substring "960" or "frc" in their
name will be set automatically when UCI2WB is run with the -f option.
They will also be reported to the GUI, but always as having default
setting 'true', no matter what their original default setting was,
to reflect the new reality. So the potential damage this heuristic can
do is limited to altereing the default.

8 years agoFix setting hash-table size in UCCI
H.G.Muller [Mon, 4 Apr 2016 15:46:34 +0000]
Fix setting hash-table size in UCCI

The keyword 'name' in "setoption name Hash ..." was hard-coded, but in
UCCI it needs to be left out. So the variable nameWord is now used instead.

8 years agoSupport Chess960
H.G.Muller [Mon, 4 Apr 2016 11:32:06 +0000]
Support Chess960

AIf an engine annunces an option UCI_Chess960 UCI2WB will report to
the GUI it supports variant fischerandom. In addition it will request
the GUI to encode castling moves as KxR through feature oocastle=0.
A flag argument -f will make UCI2WB support FRC even when the engine
does not have the option. In that case the GUI is set to deliver castling
moves as O-O[-O] (feature oocastle=1), and any castling field in a
received FEN will be overwritten with KQkq. (This is the obsolete
'Arena standard' for FRC.)

9 years agoFix blocking of input in ponder games
H.G.Muller [Wed, 7 Jan 2015 16:50:20 +0000]
Fix blocking of input in ponder games

The blocking of input during thinking did break pondering, as a ponder
miss also used pause = 2 to schedule ignoring of the 'bestmove' reply
to 'stop'. This now uses pause = 1 again, while after a ponder hit the
input thread is blocked after turning pause into 2, indicating the
'bestmove' is for real.

9 years agoSend ucinewgame after isready/readyok handshake
H.G.Muller [Tue, 23 Dec 2014 21:13:50 +0000]
Send ucinewgame after isready/readyok handshake

9 years agoBlock processing of CECP commands during thinking
H.G.Muller [Tue, 23 Dec 2014 20:32:36 +0000]
Block processing of CECP commands during thinking

The GUI thread is blocked during thinking until a move is printed,
so that ping can be instantly replied to when it is processed,
without any need for isready/readyok.

9 years agoSpecify license and include GPL text v2.0
H.G.Muller [Fri, 21 Nov 2014 08:06:38 +0000]
Specify license and include GPL text

9 years agoAlso use new start FEN in UCCI after Pawn push
H.G.Muller [Thu, 30 Oct 2014 14:52:29 +0000]
Also use new start FEN in UCCI after Pawn push

Irreversible (= forward) Pawn moves now also are recognized as
irreversible moves, next to captures.

9 years agoPack Windows icon with distro tar ball
H.G.Muller [Thu, 30 Oct 2014 14:16:49 +0000]
Pack Windows icon with distro tar ball

9 years agoAdd Linux Makefile
H.G.Muller [Thu, 30 Oct 2014 11:46:51 +0000]
Add Linux Makefile

9 years agoAdd Linux manual page
H.G.Muller [Thu, 30 Oct 2014 11:46:19 +0000]
Add Linux manual page

9 years agoPrint feature sigint=0 sigterm=0
H.G.Muller [Thu, 30 Oct 2014 09:13:18 +0000]
Print feature sigint=0 sigterm=0

Better to not even let XBoard send the signals we are going to ignore,
as this would just waste system resources.

9 years agoDon't forget to quit engine when GUI dies unexpectedly
H.G.Muller [Wed, 29 Oct 2014 21:46:59 +0000]
Don't forget to quit engine when GUI dies unexpectedly

When we get an EOF signal from the GUI pipe, meaning that the GUI
died without sending a 'quit' command, we'd better shutdown the engine
before exiting ourself.

9 years agoMake UCI2WB resistent to SIGTERM in Linux
H.G.Muller [Wed, 29 Oct 2014 21:43:46 +0000]
Make UCI2WB resistent to SIGTERM in Linux

UCI2WB was already resistant to SIGINT, which XBoard sends with every
usermove, but must also ignore the SIGTERM that is sent with the quit
command in order to reliably relay this quit to the engine.

9 years agoBump version to 2.0
H.G.Muller [Tue, 28 Oct 2014 20:02:56 +0000]
Bump version to 2.0

9 years agoWork-around for move during ponder
H.G.Muller [Tue, 28 Oct 2014 19:45:23 +0000]
Work-around for move during ponder

When engines, in violation of UCI specs, moved during ponder without
waiting for 'stop' or 'ponderhit', UCI2WB would pass their move out
of turn to the GUI, and hang when the opponent would move, waiting
for an engine move that had already come. We now ignore such a
premature ending of the ponder search, like no ponder search was
made at all. And we give an error message in the engine output.

9 years agoFix UCCI draw offers
H.G.Muller [Tue, 28 Oct 2014 11:57:14 +0000]
Fix UCCI draw offers

The offer must not be sent with the 'go ponder' command, but with 'ponderhit'.

9 years agoUpdate README file
H.G.Muller [Tue, 28 Oct 2014 08:22:20 +0000]
Update README file

9 years agoSuppress isready for first ping
H.G.Muller [Tue, 28 Oct 2014 08:08:54 +0000]
Suppress isready for first ping

The first ping sent by the XBoard should not probe the engine with
the isready/readyok dialog, but be answered with 'pong' immediately,
as the 'uciok' already issued an 'isready'.

9 years agoRemove possible deadlock
H.G.Muller [Tue, 28 Oct 2014 07:44:34 +0000]
Remove possible deadlock

Add some flush() calls to make sure we are not waiting for a
response to something we still have buffered.

9 years agoImplement UCCI draw offers
H.G.Muller [Mon, 27 Oct 2014 23:21:20 +0000]
Implement UCCI draw offers

The XBoard "offer draw" command is recognized, and leads to sending of
a 'draw' keyword with the 'go'. The other way a 'draw' in 'bestmove'
will lead to sending of an "offer draw" command.