From 7610745dc5c47743108dfc0cf556cb6a196cd5f9 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Mon, 13 Apr 2020 10:32:05 +0200 Subject: [PATCH] Reduce maxNPS when UCI_LimitStrength is enabled --- .../src/main/java/uci/EngineControl.java | 17 ++++++++++++++++- .../engine/cuckoochess/DroidEngineControl.java | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CuckooChess/src/main/java/uci/EngineControl.java b/CuckooChess/src/main/java/uci/EngineControl.java index dc3b085..f3c2969 100644 --- a/CuckooChess/src/main/java/uci/EngineControl.java +++ b/CuckooChess/src/main/java/uci/EngineControl.java @@ -229,7 +229,7 @@ public class EngineControl { sc = new Search(pos, posHashList, posHashListSize, tt, ht); sc.timeLimit(minTimeLimit, maxTimeLimit); sc.setListener(new SearchListener(os)); - sc.setStrength(getStrength(), randomSeed, maxNPS); + sc.setStrength(getStrength(), randomSeed, getMaxNPS()); MoveGen.MoveList moves = moveGen.pseudoLegalMoves(pos); MoveGen.removeIllegal(pos, moves); if ((searchMoves != null) && (searchMoves.size() > 0)) @@ -483,4 +483,19 @@ public class EngineControl { } return eloToStrength[n-1][1]; } + + /** Return adjusted maxNPS value if UCI_LimitStrength is enabled. */ + private int getMaxNPS() { + int intMax = Integer.MAX_VALUE; + int nps1 = maxNPS == 0 ? intMax : maxNPS; + int nps2 = nps1; + if (limitStrength) { + if (elo < 1350) + nps2 = Math.min(10000, nps2); + else + nps2 = Math.min(100000, nps2); + } + int nps = Math.min(nps1, nps2); + return nps == intMax ? 0 : nps; + } } diff --git a/DroidFishApp/src/main/java/org/petero/droidfish/engine/cuckoochess/DroidEngineControl.java b/DroidFishApp/src/main/java/org/petero/droidfish/engine/cuckoochess/DroidEngineControl.java index 5cd46ab..6691ad8 100644 --- a/DroidFishApp/src/main/java/org/petero/droidfish/engine/cuckoochess/DroidEngineControl.java +++ b/DroidFishApp/src/main/java/org/petero/droidfish/engine/cuckoochess/DroidEngineControl.java @@ -227,7 +227,7 @@ public class DroidEngineControl { sc = new Search(pos, posHashList, posHashListSize, tt, ht); sc.timeLimit(minTimeLimit, maxTimeLimit); sc.setListener(new SearchListener(os)); - sc.setStrength(getStrength(), randomSeed, maxNPS); + sc.setStrength(getStrength(), randomSeed, getMaxNPS()); sc.nodesBetweenTimeCheck = Math.min(500, sc.nodesBetweenTimeCheck); MoveGen.MoveList moves = moveGen.pseudoLegalMoves(pos); MoveGen.removeIllegal(pos, moves); @@ -442,4 +442,19 @@ public class DroidEngineControl { } return eloToStrength[n-1][1]; } + + /** Return adjusted maxNPS value if UCI_LimitStrength is enabled. */ + private int getMaxNPS() { + int intMax = Integer.MAX_VALUE; + int nps1 = maxNPS == 0 ? intMax : maxNPS; + int nps2 = nps1; + if (limitStrength) { + if (elo < 1350) + nps2 = Math.min(10000, nps2); + else + nps2 = Math.min(100000, nps2); + } + int nps = Math.min(nps1, nps2); + return nps == intMax ? 0 : nps; + } }