diff --git a/pom.xml b/pom.xml
index bd4d01f..4ccf9ca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
1.0.8
jchess-uci
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
UTF-8
diff --git a/src/main/java/com/fathzer/jchess/uci/ClassicalOptions.java b/src/main/java/com/fathzer/jchess/uci/ClassicalOptions.java
index 724c9f9..9067e69 100644
--- a/src/main/java/com/fathzer/jchess/uci/ClassicalOptions.java
+++ b/src/main/java/com/fathzer/jchess/uci/ClassicalOptions.java
@@ -42,8 +42,8 @@ public static CheckOption limitStrength(Consumer trigger) {
return new CheckOption(LIMIT_STRENGTH_NAME, trigger, false);
}
- public static SpinOption multiPV(Consumer trigger, int maxValue) {
- return new IntegerSpinOption(MULTI_PV_NAME, trigger, 1, 1, maxValue);
+ public static SpinOption multiPV(Consumer trigger) {
+ return new IntegerSpinOption(MULTI_PV_NAME, trigger, 1, 1, 256);
}
public static CheckOption ownBook(Consumer trigger, boolean defaultValue) {
diff --git a/src/main/java/com/fathzer/jchess/uci/GoReply.java b/src/main/java/com/fathzer/jchess/uci/GoReply.java
index f1fb659..0a72467 100644
--- a/src/main/java/com/fathzer/jchess/uci/GoReply.java
+++ b/src/main/java/com/fathzer/jchess/uci/GoReply.java
@@ -154,14 +154,20 @@ public String toString() {
* @return The line or an empty optional if no information is available
*/
public Optional getMainInfoString() {
- if (info==null) {
- return Optional.empty();
- }
+ return getInfoString(0);
+ }
+
+ /** Gets the uci info line to return just before sending the reply.
+ * @param index The move index (0 for the best move or the index or the extra moves passed to {@code Info#setExtraMoves(List)} +1
+ * @return The line or an empty optional if no information is available
+ */
+ public Optional getInfoString(int index) {
final StringBuilder builder = new StringBuilder();
if (info.depth>0) {
builder.append("depth ").append(info.depth);
}
- final Optional score = info.scoreBuilder.apply(bestMove);
+ final UCIMove move = index==0 ? bestMove : info.extraMoves.get(index-1);
+ final Optional score = info.scoreBuilder.apply(move);
if (score.isPresent()) {
if (!builder.isEmpty()) {
builder.append(' ');
@@ -174,13 +180,13 @@ public Optional getMainInfoString() {
}
builder.append("hashfull ").append(info.hashFull);
}
- final Optional> pv = info.pvBuilder.apply(bestMove);
+ final Optional> pv = info.pvBuilder.apply(move);
if (pv.isPresent()) {
if (!builder.isEmpty()) {
builder.append(' ');
}
final String moves = String.join(" ", pv.get().stream().map(UCIMove::toString).toList());
- builder.append("multipv 1 pv ").append(moves);
+ builder.append("multipv ").append(index+1).append(" pv ").append(moves);
}
return builder.isEmpty() ? Optional.empty() : Optional.of("info "+builder);
}
diff --git a/src/main/java/com/fathzer/jchess/uci/UCI.java b/src/main/java/com/fathzer/jchess/uci/UCI.java
index 8d03c46..30ccde5 100644
--- a/src/main/java/com/fathzer/jchess/uci/UCI.java
+++ b/src/main/java/com/fathzer/jchess/uci/UCI.java
@@ -210,7 +210,12 @@ protected void doGo(Deque tokens) {
final boolean started = doBackground(() -> {
final GoReply goReply = task.get();
final Optional mainInfo = goReply.getMainInfoString();
- mainInfo.ifPresent(this::out);
+ if (mainInfo.isPresent()) {
+ this.out(mainInfo.get());
+ for (int i = 1; i <= goReply.getInfo().get().getExtraMoves().size(); i++) {
+ this.out(goReply.getInfoString(i).get());
+ }
+ }
out(goReply.toString());
}, task::stop, e -> err(GO_CMD, e));
if (!started) {
diff --git a/src/main/java/com/fathzer/jchess/uci/extended/SpeedTest.java b/src/main/java/com/fathzer/jchess/uci/extended/SpeedTest.java
index 9c66e60..9a0786e 100644
--- a/src/main/java/com/fathzer/jchess/uci/extended/SpeedTest.java
+++ b/src/main/java/com/fathzer/jchess/uci/extended/SpeedTest.java
@@ -59,7 +59,7 @@ public SpeedTest(AbstractEngine engine) {
private Result fill(String fen) {
uciEngine.newGame();
uciEngine.setStartPosition(fen);
- return new Result<>(fen, uciEngine.getEngine().getBestMoves(uciEngine.get()));
+ return new Result<>(fen, uciEngine.getEngine().getBestMoves(uciEngine.get()).getBestMoves());
}
/** Launches the test.
diff --git a/src/main/java/com/fathzer/jchess/uci/helper/AbstractEngine.java b/src/main/java/com/fathzer/jchess/uci/helper/AbstractEngine.java
index e9e1ec3..e65f838 100644
--- a/src/main/java/com/fathzer/jchess/uci/helper/AbstractEngine.java
+++ b/src/main/java/com/fathzer/jchess/uci/helper/AbstractEngine.java
@@ -6,6 +6,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.function.Supplier;
+import java.util.stream.Collectors;
import com.fathzer.games.MoveGenerator;
import com.fathzer.games.MoveGenerator.MoveConfidence;
@@ -14,7 +15,7 @@
import com.fathzer.games.ai.evaluation.Evaluation.Type;
import com.fathzer.games.ai.evaluation.Evaluator;
import com.fathzer.games.ai.iterativedeepening.IterativeDeepeningEngine;
-import com.fathzer.games.ai.iterativedeepening.IterativeDeepeningEngine.BestMove;
+import com.fathzer.games.ai.iterativedeepening.SearchHistory;
import com.fathzer.games.ai.time.TimeManager;
import com.fathzer.games.ai.transposition.TranspositionTable;
import com.fathzer.jchess.uci.GoReply;
@@ -98,6 +99,7 @@ public List