|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectklaus.engine.Engine
klaus.engine.UCIEngine
public class UCIEngine
This class is used for binding an UCI engine (e. g. Toga, Fruit) to Klaus.
Field Summary | |
---|---|
private boolean |
blocked
Check if anything can be sent to the engine |
private int |
btime
|
private int |
bTimeUsed
|
private Process |
connection
|
private Thread |
engineThread
|
private int |
increment
|
private BufferedReader |
input
|
private long |
lastUpdateTime
System time at last update |
private Vector<String> |
messageStack
|
private int |
movesToGo
|
private PrintWriter |
output
|
private boolean |
running
Flag for shutting down the engine |
private int |
wtime
|
private int |
wtimeUsed
|
Fields inherited from class klaus.engine.Engine |
---|
debuggingListeners, moveListeners, party |
Constructor Summary | |
---|---|
UCIEngine(String commandLine)
Create and start a new UCI engine. |
Method Summary | |
---|---|
void |
addMove(Move m)
|
void |
cancel()
|
void |
forceMove()
|
private void |
handle(String message)
Handle an engine command |
private void |
lockEngine()
|
void |
run()
|
void |
sendMessage(String message,
boolean force)
Send a string to the engine. |
void |
setTimeModel(int timeInMinutes,
int moves,
int increment)
Set the time model, equivalent to XBoards "level" command. |
void |
startCalculation()
|
void |
unload()
|
private void |
unlockEngine()
|
private void |
updateTime()
Updates clocks, needs to be called exactly once a second. |
Methods inherited from class klaus.engine.Engine |
---|
addDebuggingListener, addMoveListener, clearDebuggingListeners, fireDebuggingListeners, fireMoveListeners, removeAllMoveListeners, removeDebuggingListener, removeMoveListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Process connection
private BufferedReader input
private PrintWriter output
private Thread engineThread
private boolean running
private boolean blocked
private int wtime
private int btime
private int wtimeUsed
private int bTimeUsed
private int increment
private int movesToGo
private Vector<String> messageStack
private long lastUpdateTime
Constructor Detail |
---|
public UCIEngine(String commandLine) throws IOException
Create and start a new UCI engine. This method is almost the same as in WinBoardXBoardEngine since actually both are started the same way.
Still, there are some differences: Unlike XBoard engines, UCI engines require some initialization stuff, this is done in the run() method.
commandLine
- the command line (consisting of an executable's path and (optionally) arguments
passed to the engine). Note: If there are spaces or some special characters in the path, "" will be
required.
IOException
- if the engine could not be started correctly for some reason (file not found,
crash during startup)Method Detail |
---|
public void addMove(Move m)
addMove
in class Engine
public void startCalculation()
startCalculation
in class Engine
public void cancel()
cancel
in class Engine
public void unload()
unload
in class Engine
public void forceMove()
forceMove
in class Engine
public void setTimeModel(int timeInMinutes, int moves, int increment)
Engine
Set the time model, equivalent to XBoards "level" command.
This method should be called in two situations:
setTimeModel
in class Engine
timeInMinutes
- the time for this periodmoves
- the number of moves to the next periodincrement
- the increment per move (Fischer clock) (in seconds)private void updateTime()
public void sendMessage(String message, boolean force)
message
- the message, command, whatsoeverforce
- force sending the message if blocked is true? This should only be set to true by run()!private void lockEngine()
private void unlockEngine()
private void handle(String message)
message
- a string sent by the enginepublic void run()
run
in interface Runnable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |