diff --git a/src/dev/kske/chess/uci/UCIInfo.java b/src/dev/kske/chess/uci/UCIInfo.java index 8909c7d..074b09a 100644 --- a/src/dev/kske/chess/uci/UCIInfo.java +++ b/src/dev/kske/chess/uci/UCIInfo.java @@ -2,7 +2,9 @@ package dev.kske.chess.uci; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import dev.kske.chess.board.Move; @@ -16,11 +18,12 @@ import dev.kske.chess.board.Move; */ public class UCIInfo { - private int depth, seldepth, time, nodes, multipv, currmovenumber, hashfull, nps, tbhits, sbhits, cpuload, cpunr; - private List pv, refutation, currline; - private Move currmove; - private Score score; - private String displayString; + private int depth, seldepth, time, nodes, multipv, currmovenumber, hashfull, nps, tbhits, sbhits, cpuload, cpunr; + private List pv = new ArrayList<>(), refutation = new ArrayList<>(); + private Map> currline = new HashMap<>(); + private Move currmove; + private Score score; + private String displayString; /** * Contains every parameter for the UCI info command. Helpful for parsing @@ -45,9 +48,6 @@ public class UCIInfo { "currline"); public UCIInfo(String line) { - pv = new ArrayList<>(); - refutation = new ArrayList<>(); - currline = new ArrayList<>(); String[] tokens = line.split(" "); for (int i = 0; i < tokens.length; i++) @@ -104,10 +104,13 @@ public class UCIInfo { while (++i < tokens.length && !params.contains(tokens[i])) refutation.add(Move.fromLAN(tokens[i])); break; - // TODO: currline case "currline": - while (++i < tokens.length && !params.contains(tokens[i])) - ; + // A CPU number of 1 can be omitted + final Integer cpu = tokens[i].matches("\\d+") ? Integer.valueOf(tokens[i++]) : 1; + final ArrayList moves = new ArrayList<>(); + while (i < tokens.length && !params.contains(tokens[i])) + moves.add(Move.fromLAN(tokens[i++])); + currline.put(cpu, moves); System.err.println("The parameter 'currline' for command 'info' is not yet implemented"); break; default: @@ -143,7 +146,7 @@ public class UCIInfo { public List getRefutation() { return refutation; } - public List getCurrline() { return currline; } + public Map> getCurrline() { return currline; } public Move getCurrmove() { return currmove; }