Public method isReadyCommand
This function sends an isready command. It returns a promise which is resolved once the engine responds with readyok.
Public method uciCommand
This function sends a uci command to the engine. It returns a promise which is resolved once the engine responds with uciok.
TODO:parse options
Not all commands produce an output. Two examples are the position and the ucinewgame commands. For such commands how do you know if the engine is working on your command or has an infinite loop and is hung forever? You don't. As a workaround these commands send an isready command at the end which fortunately produces the readyok output.
Public method setOptionCommand
This function sends a setoption name NAME value VALUE command to the engine and returns a promise. After this command it also sends a isready command and the promise is resolved when the engine produces the readyok string.
Parameters:
optionName must be a String.
(The name of the option)
optionValue must be a String.
(The value of the option)
TODO:parse options from uci command and if option type is button, call the setoption on if optionValue is true
Public method uciNewGameCommand
This function sends a ucinewgame command to the engine and returns a promise. After this command it also sends a isready command and the promise is resolved when the engine produces the readyok string.
Public method positionCommand
This function sends a position fen FenString command and returns a promise. After this command it also sends a isready command and the promise is resolved when the engine produces the readyok string.
Parameters:
fen must be a String.
(The fen string of the position or the value startpos. startpos will set the starting position.)
moves must be a String.
(The moves to play after the position with fen is set.)
Public method timeLimitedGoCommand
This function sends a go wtime whiteTime btime blackTime command and returns a promise. The promise is resolved when the engine outputs a bestmove.
Parameters:
infoHandler must be a Function.
(A callback taking a string. This will be called for each info line output by the engine.)
whiteMillisRemaining must be a Number.
(The remaining time for white in milliseconds)
blackMillisRemaining must be a Number.
(The remaining time for black in milliseconds)
TODO:Parse info and bestmove
Public method goCommand
This function sends the go command and returns a promise. After this command it also sends a isready command and the promise is resolved when the engine produces the readyok string.
Parameters:
commands must be an Object.
(Key-value pairs of commands that can follow the main go command (e.g. searchmoves, infinite, etc.).)
infoHandler must be a Function.
(A callback taking a string. This will be called for each info line output by the engine.)
TODO:Parse info and bestmove
create input command
e.g. { 'infinite': null, ... }
Public method goInfiniteCommand
This function sends the go infinite command and returns a promise. After this command it also sends a isready command and the promise is resolved when the engine produces the readyok string.
Parameters:
TODO:Parse info and bestmove
Public method stopCommand
This function sends the stop command and returns a promise. The promise is resolved when the engine outputs a bestmove.
TODO:Parse info and bestmove
Public method quitCommand
This function sends a quit command. It returns a promise which is resolved once the engine process is terminated.
Public method runProcess
This function starts the engine process and returns a promise which is resolved or rejected later depending upon whether the process is running or not