forked from TheTrueRandom/JavaChessUCI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIUCIEngine.java
160 lines (139 loc) · 4.3 KB
/
IUCIEngine.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import exception.JuciException;
import input.GoCommand;
import output.CalculationResult;
import output.Option;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
public interface IUCIEngine {
/**
* Start the engine and block the current thread until the engine is started
* (for a correct executable this method usually only blocks for a few ms).
* When the method returns successfully the engine is successfully set to UCI mode
* and properties can be accessed (e.g. {@link #getName()} {@link #getAuthor()}, {@link #getOptions()}
*
* @throws JuciException If the engine (executable) is not able to speak the UCI protocol
* @throws IOException If an I/O error occurs
*/
void start() throws JuciException, IOException;
/**
* Start the engine asynchronously.
*
* @return a future which will complete once the engine is started or
* complete exceptionally when the engine failed to start (see {@link #start()})
* @see #start()
*/
CompletableFuture<Void> startAsync();
/**
* Send 'setoption' command to the engine.
*
* @param name Option name (e.g. Threads)
* @param value Option value (e.g. 8)
*/
void setOption(String name, Object value);
/**
* Send 'stop' to the engine which indicates ongoing calculation should be stopped.
* Results in the engine to respond with 'bestmove'
* and calls to {@link #go(GoCommand)} or {@link #goAsync(GoCommand)} to complete.
*/
void stop();
/**
* Send 'position fen' to the engine.
*
* @param fen the fen position
* @param moves optional moves
*/
void fen(String fen, String... moves);
/**
* Send 'position startpos' to the engine.
*
* @param moves optional moves
*/
void startPos(String... moves);
/**
* Send 'ucinewgame' to the engine.
* Usually {@link #isReady()} should be called afterwards.
*/
void uciNewGame();
/**
* Send UCI 'isready' to the engine.
* Blocks the current thread until the engine responds with 'readyok'
*/
void isReady();
/**
* Send UCI 'isready' to the engine asynchronously.
*
* @return a future which will complete once the engine responds with 'readyok'
* @see #isReady()
*/
CompletableFuture<Void> isReadyAsync();
/**
* Send UCI 'go' command to the engine
*
* @param goCommand allows to set every possible UCI go parameter
* @return {@link output.CalculationResult}
*/
CalculationResult go(GoCommand goCommand);
/**
* Convenience method for UCI 'go infinite'
*
* @see #go(GoCommand)
*/
CalculationResult goInfinite();
/**
* Convenience method for UCI 'go movetime X'
*
* @param movetime movetime in ms
* @see #go(GoCommand)
*/
CalculationResult goMovetime(int movetime);
/**
* Send UCI 'go' command to the engine asynchronously
*
* @return a future which will complete when the engine finishes calculating
* @see #go(GoCommand)
*/
CompletableFuture<CalculationResult> goAsync(GoCommand goCommand);
/**
* Convenience method for UCI 'go infinite' asynchronously
*
* @see #goAsync(GoCommand)
*/
CompletableFuture<CalculationResult> goInfiniteAsync();
/**
* Convenience method for UCI 'go movetime X' asynchronously
*
* @see #goAsync(GoCommand)
*/
CompletableFuture<CalculationResult> goMovetimeAsync(int movetime);
/**
* Send 'ponderhit' to the engine
*/
void ponderhit();
/**
* Shutdown the engine by destroying the process.
* {@link #start()} could be called again afterwards
*/
void shutdown();
/**
* Get the name of the engine.
* Note: this method can only be called after {@link #start()}
*
* @return name
*/
String getName();
/**
* Get the author of the engine.
* Note: this method can only be called after {@link #start()}
*
* @return author
*/
String getAuthor();
/**
* Get the options of the engine
* Note: this method can only be called after {@link #start()}
*
* @return a map with optionName: {@link output.Option}
*/
Map<String, Option> getOptions();
}