Implemented 'currline' command in UCI protocol
This commit is contained in:
parent
ae9abded19
commit
05299e3a05
@ -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;
|
||||
|
||||
@ -17,7 +19,8 @@ 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 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;
|
||||
@ -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; }
|
||||
|
||||
|
Reference in New Issue
Block a user