From c8b0b8a1d31258b866cc9d7e668895edfdee3823 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Sat, 26 Nov 2011 13:50:15 +0000 Subject: [PATCH] CuckooChess: Changed node counters to long to avoid wraparound on long searches. --- CuckooChess/src/uci/EngineControl.java | 4 +-- .../src/chess/ComputerPlayer.java | 2 +- CuckooChessEngine/src/chess/Search.java | 34 +++++++++++-------- .../src/guibase/ChessController.java | 6 ++-- .../cuckoochess/DroidEngineControl.java | 4 +-- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/CuckooChess/src/uci/EngineControl.java b/CuckooChess/src/uci/EngineControl.java index b38461e..01edbcb 100644 --- a/CuckooChess/src/uci/EngineControl.java +++ b/CuckooChess/src/uci/EngineControl.java @@ -95,7 +95,7 @@ public class EngineControl { os.printf("info currmove %s currmovenumber %d%n", moveToString(m), moveNr); } - public void notifyPV(int depth, int score, int time, int nodes, int nps, boolean isMate, + public void notifyPV(int depth, int score, int time, long nodes, int nps, boolean isMate, boolean upperBound, boolean lowerBound, ArrayList pv) { StringBuilder pvBuf = new StringBuilder(); for (Move m : pv) { @@ -112,7 +112,7 @@ public class EngineControl { depth, isMate ? "mate" : "cp", score, bound, time, nodes, nps, pvBuf.toString()); } - public void notifyStats(int nodes, int nps, int time) { + public void notifyStats(long nodes, int nps, int time) { os.printf("info nodes %d nps %d time %d%n", nodes, nps, time); } } diff --git a/CuckooChessEngine/src/chess/ComputerPlayer.java b/CuckooChessEngine/src/chess/ComputerPlayer.java index 2216396..17ff15e 100644 --- a/CuckooChessEngine/src/chess/ComputerPlayer.java +++ b/CuckooChessEngine/src/chess/ComputerPlayer.java @@ -30,7 +30,7 @@ public class ComputerPlayer implements Player { public static final String engineName; static { - String name = "CuckooChess 1.13a3"; + String name = "CuckooChess 1.13a4"; String m = System.getProperty("sun.arch.data.model"); if ("32".equals(m)) name += " 32-bit"; diff --git a/CuckooChessEngine/src/chess/Search.java b/CuckooChessEngine/src/chess/Search.java index d7d6f80..781a9e3 100644 --- a/CuckooChessEngine/src/chess/Search.java +++ b/CuckooChessEngine/src/chess/Search.java @@ -64,7 +64,7 @@ public class Search { long minTimeMillis; // Minimum recommended thinking time long maxTimeMillis; // Maximum allowed thinking time boolean searchNeedMoreTime; // True if negaScout should use up to maxTimeMillis time. - private int maxNodes; // Maximum number of nodes to search (approximately) + private long maxNodes; // Maximum number of nodes to search (approximately) int nodesToGo; // Number of nodes until next time check public int nodesBetweenTimeCheck = 5000; // How often to check remaining time @@ -74,11 +74,11 @@ public class Search { long randomSeed = 0; // Search statistics stuff - int nodes; - int qNodes; + long nodes; + long qNodes; int[] nodesPlyVec; int[] nodesDepthVec; - int totalNodes; + long totalNodes; long tLastStats; // Time when notifyStats was last called boolean verbose; @@ -124,9 +124,9 @@ public class Search { public interface Listener { public void notifyDepth(int depth); public void notifyCurrMove(Move m, int moveNr); - public void notifyPV(int depth, int score, int time, int nodes, int nps, + public void notifyPV(int depth, int score, int time, long nodes, int nps, boolean isMate, boolean upperBound, boolean lowerBound, ArrayList pv); - public void notifyStats(int nodes, int nps, int time); + public void notifyStats(long nodes, int nps, int time); } Listener listener; @@ -136,7 +136,7 @@ public class Search { private final static class MoveInfo { Move move; - int nodes; + long nodes; MoveInfo(Move m, int n) { move = m; nodes = n; } public static final class SortByScore implements Comparator { public int compare(MoveInfo mi1, MoveInfo mi2) { @@ -157,7 +157,13 @@ public class Search { return 1; if (mi2 == null) return -1; - return mi2.nodes - mi1.nodes; + long d = mi2.nodes - mi1.nodes; + if (d < 0) + return -1; + else if (d > 0) + return 1; + else + return 0; } } } @@ -176,7 +182,7 @@ public class Search { } final public Move iterativeDeepening(MoveGen.MoveList scMovesIn, - int maxDepth, int initialMaxNodes, boolean verbose) { + int maxDepth, long initialMaxNodes, boolean verbose) { tStart = System.currentTimeMillis(); // log = TreeLogger.getWriter("/home/petero/treelog.dmp", pos); totalNodes = 0; @@ -234,8 +240,8 @@ public class Search { lmrS = plyScale; } } -/* int nodes0 = nodes; - int qNodes0 = qNodes; +/* long nodes0 = nodes; + long qNodes0 = qNodes; System.out.printf("%2d %5s %5d %5d %6s %6s ", mi, "-", alpha, beta, "-", "-"); System.out.printf("%-6s...\n", TextIO.moveToUCIString(m)); */ @@ -249,7 +255,7 @@ public class Search { sti.lmr = 0; score = -negaScout(-beta, -alpha, 1, depthS - plyScale, -1, givesCheck); } - int nodesThisMove = nodes + qNodes; + long nodesThisMove = nodes + qNodes; posHashListSize--; pos.unMakeMove(m, ui); { @@ -749,8 +755,8 @@ public class Search { nodes++; totalNodes++; sti.currentMove = m; -/* int nodes0 = nodes; - int qNodes0 = qNodes; +/* long nodes0 = nodes; + long qNodes0 = qNodes; if ((ply < 3) && (newDepth > plyScale)) { System.out.printf("%2d %5s %5d %5d %6s %6s ", mi, "-", alpha, beta, "-", "-"); diff --git a/CuckooChessEngine/src/guibase/ChessController.java b/CuckooChessEngine/src/guibase/ChessController.java index 5748560..7e6b089 100644 --- a/CuckooChessEngine/src/guibase/ChessController.java +++ b/CuckooChessEngine/src/guibase/ChessController.java @@ -58,7 +58,7 @@ public class ChessController { int currDepth = 0; int currMoveNr = 0; String currMove = ""; - int currNodes = 0; + long currNodes = 0; int currNps = 0; int currTime = 0; @@ -106,7 +106,7 @@ public class ChessController { setSearchInfo(); } - public void notifyPV(int depth, int score, int time, int nodes, int nps, boolean isMate, + public void notifyPV(int depth, int score, int time, long nodes, int nps, boolean isMate, boolean upperBound, boolean lowerBound, ArrayList pv) { pvDepth = depth; pvScore = score; @@ -128,7 +128,7 @@ public class ChessController { setSearchInfo(); } - public void notifyStats(int nodes, int nps, int time) { + public void notifyStats(long nodes, int nps, int time) { currNodes = nodes; currNps = nps; currTime = time; diff --git a/DroidFish/src/org/petero/droidfish/engine/cuckoochess/DroidEngineControl.java b/DroidFish/src/org/petero/droidfish/engine/cuckoochess/DroidEngineControl.java index f3b2e45..0b03074 100644 --- a/DroidFish/src/org/petero/droidfish/engine/cuckoochess/DroidEngineControl.java +++ b/DroidFish/src/org/petero/droidfish/engine/cuckoochess/DroidEngineControl.java @@ -90,7 +90,7 @@ public class DroidEngineControl { os.printf("info currmove %s currmovenumber %d%n", moveToString(m), moveNr); } - public void notifyPV(int depth, int score, int time, int nodes, int nps, boolean isMate, + public void notifyPV(int depth, int score, int time, long nodes, int nps, boolean isMate, boolean upperBound, boolean lowerBound, ArrayList pv) { StringBuilder pvBuf = new StringBuilder(); for (Move m : pv) { @@ -107,7 +107,7 @@ public class DroidEngineControl { depth, isMate ? "mate" : "cp", score, bound, time, nodes, nps, pvBuf.toString()); } - public void notifyStats(int nodes, int nps, int time) { + public void notifyStats(long nodes, int nps, int time) { os.printf("info nodes %d nps %d time %d%n", nodes, nps, time); } }