From 36597ac6f1cb6a7c78e1a893000543c3107898b9 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R 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;