Skip to content

Commit

Permalink
Change the reported score units to 1/100 of a seed
Browse files Browse the repository at this point in the history
  • Loading branch information
joansalasoler committed May 14, 2020
1 parent 0d07a59 commit f3d18f0
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 31 deletions.
67 changes: 37 additions & 30 deletions src/com/joansala/engine/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://www.gnu.org/licenses/>.
*/
Expand All @@ -23,7 +23,7 @@
* <p>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.</p>
*
*
* <p>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
Expand All @@ -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.
*
Expand All @@ -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.
*
Expand All @@ -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();


}


}
3 changes: 2 additions & 1 deletion src/com/joansala/engine/UCIService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/com/joansala/oware/OwareCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit f3d18f0

Please sign in to comment.