public interface Cache
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 store
is used to ask the cache to remember the
relevant information for a position. Then this information may be
retrieved calling the method find
. After this is called the
object getters may be used to retrieve the game state information.
Therefore, performing a look up for a game position consists on first searching the position and then retrieving its values:
if (cache.find(game)) { int score = cache.getScore(); int move = cache.getMove(); }
Modifier and Type | Field and Description |
---|---|
static byte |
EMPTY
Flag of an unknown score
|
static byte |
EXACT
Flag of an exact score
|
static byte |
LOWER
Flag of a lower bound score
|
static byte |
UPPER
Flag of an upper bound score
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all the data stored on the cache.
|
void |
discharge()
Asks the cache to make room for new entries.
|
boolean |
find(Game game)
Search the current game state provided by a
Game object. |
int |
getDepth()
Returns the stored depth value for the last position found.
|
byte |
getFlag()
Returns the stored flag value for the last position found.
|
int |
getMove()
Returns the stored move value for the last position found.
|
int |
getScore()
Returns the stored score value for the last position found.
|
void |
resize(long memory)
Resizes the cache and clears all the stored data.
|
long |
size()
Returns the current capacity of this cache in bytes.
|
void |
store(Game game,
int score,
int move,
int depth,
byte flag)
Stores information about a game state on the cache.
|
static final byte EMPTY
static final byte LOWER
static final byte UPPER
static final byte EXACT
int getScore()
int getMove()
int getDepth()
byte getFlag()
boolean find(Game game)
Game
object.
When a position is found subsequent calls to the getter methods of this object must return the values stored for the position.
true
if valid information for the position
could be found; false
otherwise.void store(Game game, int score, int move, int depth, byte flag)
game
- The game for which the information about its current
state must be storedscore
- Score value for the game statedepth
- Search depth to which the score was evaluatedflag
- Flag for the game statemove
- The best move found for the game statevoid discharge()
void resize(long memory)
memory
- Memory request in bytesvoid clear()
long size()