From 3a76ddc617474dd992aeae79e047d3870bf9970e Mon Sep 17 00:00:00 2001 From: kske Date: Thu, 1 Aug 2019 19:01:17 +0200 Subject: [PATCH] Fixed parsing score and after score --- src/dev/kske/chess/uci/UCIInfo.java | 58 ++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/src/dev/kske/chess/uci/UCIInfo.java b/src/dev/kske/chess/uci/UCIInfo.java index 4606874..23ed319 100644 --- a/src/dev/kske/chess/uci/UCIInfo.java +++ b/src/dev/kske/chess/uci/UCIInfo.java @@ -30,29 +30,51 @@ public class UCIInfo { switch (tokens[i]) { // Single parameter info case "depth": - case "seldepth": - case "time": - case "nodes": - case "multipv": - case "currmove": - case "currmovenumber": - case "hashfull": - case "nps": - case "tbhits": - case "sbhits": - case "cpuload": - case "string": - try { - getClass().getField(tokens[i]).set(this, tokens[++i]); - } catch (Exception ex) {} + depth = Integer.parseInt(tokens[++i]); break; + case "seldepth": + seldepth = Integer.parseInt(tokens[++i]); + break; + case "time": + time = Integer.parseInt(tokens[++i]); + break; + case "nodes": + nodes = Integer.parseInt(tokens[++i]); + break; + case "multipv": + multipv = Integer.parseInt(tokens[++i]); + break; + case "currmove": + currmove = Move.fromSAN(tokens[++i]); + break; + case "currmovenumber": + currmovenumber = Integer.parseInt(tokens[++i]); + break; + case "hashfull": + hashfull = Integer.parseInt(tokens[++i]); + break; + case "nps": + nps = Integer.parseInt(tokens[++i]); + break; + case "tbhits": + tbhits = Integer.parseInt(tokens[++i]); + break; + case "sbhits": + sbhits = Integer.parseInt(tokens[++i]); + break; + case "cpuload": + cpuload = Integer.parseInt(tokens[++i]); + break; + case "string": + displayString = tokens[++i]; + break; + case "score": + score = new Score(line.substring(line.indexOf("score") + tokens[i].length() + 1)); + i += score.isLowerbound() || score.isUpperbound() ? 1 : 2; // TODO: pv // TODO: refutation // TODO: currline case "pv": - // TODO: parse infos after score - case "score": - score = new Score(line.substring(tokens[i].length() + 1)); case "refutation": case "currline": break;