From 708660958c5193158b8c1ead43694ac3d240bacb Mon Sep 17 00:00:00 2001 From: Hamidreza Bayat Date: Sun, 28 Apr 2019 19:48:44 +0430 Subject: [PATCH] Replace anonymous classes with lambda in CuckooChessEngine --- .../main/java/guibase/ChessController.java | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/CuckooChessEngine/src/main/java/guibase/ChessController.java b/CuckooChessEngine/src/main/java/guibase/ChessController.java index 939b93b..4dc3f98 100644 --- a/CuckooChessEngine/src/main/java/guibase/ChessController.java +++ b/CuckooChessEngine/src/main/java/guibase/ChessController.java @@ -85,11 +85,9 @@ public class ChessController { buf.append(String.format(Locale.US, "d:%d %d:%s t:%.2f n:%d nps:%d", currDepth, currMoveNr, currMove, currTime / 1000.0, currNodes, currNps)); final String newPV = buf.toString(); - gui.runOnUIThread(new Runnable() { - public void run() { - thinkingPV = newPV; - setThinkingPV(); - } + gui.runOnUIThread(() -> { + thinkingPV = newPV; + setThinkingPV(); }); } @@ -496,21 +494,17 @@ public class ChessController { private void startComputerThinking() { if (game.pos.whiteMove != humanIsWhite) { if (computerThread == null) { - Runnable run = new Runnable() { - public void run() { - computerPlayer.timeLimit(gui.timeLimit(), gui.timeLimit(), gui.randomMode()); - final String cmd = computerPlayer.getCommand(new Position(game.pos), - game.haveDrawOffer(), game.getHistory()); - gui.runOnUIThread(new Runnable() { - public void run() { - game.processString(cmd); - thinkingPV = ""; - updateGUI(); - setSelection(); - stopComputerThinking(); - } - }); - } + Runnable run = () -> { + computerPlayer.timeLimit(gui.timeLimit(), gui.timeLimit(), gui.randomMode()); + final String cmd = computerPlayer.getCommand(new Position(game.pos), + game.haveDrawOffer(), game.getHistory()); + gui.runOnUIThread(() -> { + game.processString(cmd); + thinkingPV = ""; + updateGUI(); + setSelection(); + stopComputerThinking(); + }); }; if (threadStack > 0) { ThreadGroup tg = new ThreadGroup("searcher");