Implemented 'currline' command in UCI protocol

This commit is contained in:
Kai S. K. Engelbart 2019-10-28 18:24:26 +01:00
parent a41a2819da
commit 1d78b8f071

View File

@ -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<Move> 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<Move> pv = new ArrayList<>(), refutation = new ArrayList<>();
private Map<Integer, List<Move>> 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<Move> 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<Move> getRefutation() { return refutation; }
public List<Move> getCurrline() { return currline; }
public Map<Integer, List<Move>> getCurrline() { return currline; }
public Move getCurrmove() { return currmove; }