Modifier and Type | Field and Description |
---|---|
static int |
MAX_CAPACITY
Maximum possible capacity in number of slots
|
static int |
MIN_CAPACITY
Minimum possible capacity in number of slots
|
static int |
SLOT_SIZE
Size of a table slot in bytes
|
Constructor and Description |
---|
OwareCache(long memory)
Creates a new empty transposition table with the specified
capacity in bytes.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears all the information stored in this transposition table.
|
void |
discharge()
Asks the cache to make room for new entries.
|
boolean |
find(Game game)
Search a position provided by a
Game object and sets it
as the current position on the transposition table. |
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 this transposition table clearing 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 the current position in the
Game
object on this transposition table. |
public static final int SLOT_SIZE
public static final int MIN_CAPACITY
public static final int MAX_CAPACITY
public OwareCache(long memory)
The capacity of the table must be a power of two greater or equal to 2 ^ 12. If size is not a power of two the table capacity is set to the lowest near power of two.
memory
- The capacity of the table in bytespublic int getScore()
public int getMove()
public int getDepth()
public byte getFlag()
public boolean find(Game game)
Game
object and sets it
as the current position on the transposition table.
When a position is found subsequent calls to the getter methods of this object will return the values stored for the position.
public void store(Game game, int score, int move, int depth, byte flag)
Game
object on this transposition table.
For each parameter value only the lower bits are stored: score (11 bits), depth (7 bits), flag (2 bits), move (4 bits), game (44 bits, hash code of the current position).
For the hash code of the position bits 44 to 12 (32 bits) are stored explicitly on the corresponding table slot and the lower 12 bits implicitly as part of the slot index.
store
in interface Cache
game
- The game for which the information about its current
state must be storedscore
- The evaluated score for the positiondepth
- The search depth with which the score was evaluatedflag
- The score type as a lower bound, an upper bound,
an exact value or empty.move
- The best move found so far for the positionpublic void discharge()
This implementation does not clear old entries immediately. Instead, it increments an internal clock that marks stored positions as old entries. Must be called periodically to make room for new entries to be stored.
public void resize(long memory)
public void clear()