From f3d18f06f24cf399e0b8955be2a5ceaf517bb5a5 Mon Sep 17 00:00:00 2001 From: Joan Sala Soler Date: Thu, 14 May 2020 17:36:03 +0200 Subject: [PATCH] Change the reported score units to 1/100 of a seed --- src/com/joansala/engine/Cache.java | 67 ++++++++++++++----------- src/com/joansala/engine/UCIService.java | 3 +- src/com/joansala/oware/OwareCache.java | 8 +++ 3 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/com/joansala/engine/Cache.java b/src/com/joansala/engine/Cache.java index 8f1be53..58f723b 100644 --- a/src/com/joansala/engine/Cache.java +++ b/src/com/joansala/engine/Cache.java @@ -7,12 +7,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -23,7 +23,7 @@ *

A cache object may be used by an engine as a temporary memory space * to store and retrieve information about searched game states. This is * usually known as transposition tables.

- * + * *

The method {@code store} is used to ask the cache to remember the * relevant information for a position. Then this information may be * retrieved calling the method {@code find}. After this is called the @@ -42,52 +42,60 @@ * @version 1.0.0 */ public interface Cache { - + /** Flag of an unknown score */ byte EMPTY = 0; - + /** Flag of a lower bound score */ byte LOWER = 1; - + /** Flag of an upper bound score */ byte UPPER = 2; - + /** Flag of an exact score */ byte EXACT = 3; - - + + + /** + * Returns the score for the last position found in centipawns. + * + * @return Stored score value in centipawns + */ + int getOutcome(); + + /** * Returns the stored score value for the last position found. * * @return Stored score value or zero */ int getScore(); - - + + /** * Returns the stored move value for the last position found. * * @return Stored move value */ int getMove(); - - + + /** * Returns the stored depth value for the last position found. * * @return Stored depth value or zero */ int getDepth(); - - + + /** * Returns the stored flag value for the last position found. * * @return Stored flag value */ byte getFlag(); - - + + /** * Search the current game state provided by a {@code Game} object. * @@ -98,8 +106,8 @@ public interface Cache { * could be found; {@code false} otherwise. */ boolean find(Game game); - - + + /** * Stores information about a game state on the cache. * @@ -111,37 +119,36 @@ public interface Cache { * @param move The best move found for the game state */ void store(Game game, int score, int move, int depth, byte flag); - - + + /** * Asks the cache to make room for new entries. This method requests * that old cache entries be discarded so new entries may be stored * on the cache. */ void discharge(); - - + + /** * Resizes the cache and clears all the stored data. * * @param memory Memory request in bytes */ void resize(long memory); - - + + /** * Removes all the data stored on the cache. */ void clear(); - - + + /** * Returns the current capacity of this cache in bytes. * * @return Allocated bytes for the cache */ long size(); - - -} + +} diff --git a/src/com/joansala/engine/UCIService.java b/src/com/joansala/engine/UCIService.java index fe74bdc..4eb78dd 100644 --- a/src/com/joansala/engine/UCIService.java +++ b/src/com/joansala/engine/UCIService.java @@ -359,6 +359,7 @@ private String collectSearchInfo(Game game, int bestMove) { int winner = Game.DRAW; int depth = cache.getDepth() + 1; int score = cache.getScore(); + int outcome = cache.getOutcome(); byte flag = cache.getFlag(); int[] variation = null; @@ -417,7 +418,7 @@ private String collectSearchInfo(Game game, int bestMove) { response.append(" depth "); response.append(depth); response.append(" score cp "); - response.append(-score); + response.append(-outcome); if (winner != Game.DRAW) { int numMoves = (int) (length / 2.0D + .5D); diff --git a/src/com/joansala/oware/OwareCache.java b/src/com/joansala/oware/OwareCache.java index ac328bf..d5628a8 100644 --- a/src/com/joansala/oware/OwareCache.java +++ b/src/com/joansala/oware/OwareCache.java @@ -95,6 +95,14 @@ public OwareCache(long memory) { } + /** + * {@inheritDoc} + */ + public int getOutcome() { + return (int) (2.5 * this.score); + } + + /** * Returns the stored score value for the last position found. *