public class GaviotaTableBaseJNI extends EndGameTableBase
Modifier and Type | Class and Description |
---|---|
static class |
GaviotaTableBaseJNI.CompressionScheme
Gaviota endgame tablebase file compression schemes.
|
EndGameTableBase.DTM, EndGameTableBase.EGTBStats, EndGameTableBase.WDL
Modifier and Type | Field and Description |
---|---|
static char |
BISHOP |
static int |
BLACK_TO_MOVE |
static int |
BLONG |
static int |
BMATE |
static int |
BSHORT |
static int |
BYTES_READ |
static int |
DRAW |
static int |
DRIVE_HITS |
static int |
DRIVE_MISSES |
static int |
DTM_CACHE_SIZE |
static int |
DTM_EASY_HITS |
static int |
DTM_HARD_PROB |
static int |
DTM_OCCUPANCY |
static int |
DTM_SOFT_PROB |
static int |
FILES_OPENED |
static int |
FORBID |
static char |
KING |
static char |
KNIGHT |
static int |
MEMORY_EFFICIENCY |
static int |
MEMORY_HITS |
static int |
NO_CASTLE |
static char |
NO_PIECE |
static int |
NO_SQUARE |
static char |
PAWN |
static char |
QUEEN |
static char |
ROOK |
static int |
TOTAL_HITS |
static int |
UNKNOWN |
static int |
WDL_CACHE_SIZE |
static int |
WDL_EASY_HITS |
static int |
WDL_HARD_PROB |
static int |
WDL_OCCUPANCY |
static int |
WDL_SOFT_PROB |
static int |
WHITE_TO_MOVE |
static int |
WLONG |
static int |
WMATE |
static int |
WSHORT |
MAX_NUMBER_OF_PIECES
Modifier and Type | Method and Description |
---|---|
boolean |
areTableBasesAvailable(int piecesOnBoard)
It returns whether there are at least some tablebase files loaded for positions with the given number of pieces on the board.
|
int |
availability()
Returns an integer denoting for which numbers of pieces the library is initialized for.
|
void |
clearCache()
Flushes the probing cache.
|
void |
close() |
void |
closeCache()
Closes the cache.
|
static GaviotaTableBaseJNI |
getInstance()
Returns the only instance of the class.
|
EndGameTableBase.EGTBStats |
getStats()
Returns some basic usage stats about the endgame tablebase.
|
void |
getStats(long[] intStats,
double[] fpStats)
Sets the values of the two array parameters according to the statistics of the probing library.
|
long |
indexMemory()
Returns the amount of memory allocated for indices in bytes.
|
String |
init(boolean verbose,
int compScheme,
String paths)
Initializes the Gaviota probing library using the specified parameters.
|
void |
init(String path,
long cacheSize,
Object... args)
Initializes the probing code, potentially including the setting up of the cache.
|
boolean |
initCache(long size,
int wdlFraction)
Initializes the cache using the specified parameters.
|
boolean |
isCacheOn()
Returns whether the cache is on.
|
boolean |
isInit()
Returns whether the probing code has been initialized.
|
int[] |
probe(int sideToMove,
int enPassantSqr,
int catlingRights,
int[] wSqrs,
int[] bSqrs,
char[] wPcs,
char[] bPcs)
Probes the cache for both WDL and DTM information for the given position.
|
EndGameTableBase.DTM |
probeDTM(Position pos,
boolean soft)
It probes for the given position and if found, it returns whether it is a win, loss, or draw; and in case it is a win or loss, it also
returns the distance to mate.
|
int[] |
probeSoft(int sideToMove,
int enPassantSqr,
int catlingRights,
int[] wSqrs,
int[] bSqrs,
char[] wPcs,
char[] bPcs)
Probes the cache for both WDL and DTM information for the given position.
|
int |
probeSoftWDL(int sideToMove,
int enPassantSqr,
int catlingRights,
int[] wSqrs,
int[] bSqrs,
char[] wPcs,
char[] bPcs)
Probes the cache for WDL information for the given position.
|
int |
probeWDL(int sideToMove,
int enPassantSqr,
int catlingRights,
int[] wSqrs,
int[] bSqrs,
char[] wPcs,
char[] bPcs)
Probes the cache for WDL information for the given position.
|
EndGameTableBase.WDL |
probeWDL(Position pos,
boolean soft)
It probes for the given position and if found, it returns whether it is a winning position, a losing position, or a draw; else it
returns null.
|
void |
resetStats()
Resets the stored statistics of the probing library.
|
String |
restart(boolean verbose,
int compScheme,
String paths)
Restarts the Gaviota probing library using the specified parameters.
|
boolean |
restartCache(long size,
int wdlFraction)
Restarts the cache using the specified parameters.
|
isProbingLibLoaded, loadProbingLibrary
public static final int DRAW
public static final int WMATE
public static final int BMATE
public static final int FORBID
public static final int UNKNOWN
public static final int WDL_EASY_HITS
public static final int WDL_HARD_PROB
public static final int WDL_SOFT_PROB
public static final int WDL_CACHE_SIZE
public static final int DTM_EASY_HITS
public static final int DTM_HARD_PROB
public static final int DTM_SOFT_PROB
public static final int DTM_CACHE_SIZE
public static final int TOTAL_HITS
public static final int MEMORY_HITS
public static final int DRIVE_HITS
public static final int DRIVE_MISSES
public static final int BYTES_READ
public static final int FILES_OPENED
public static final int WDL_OCCUPANCY
public static final int DTM_OCCUPANCY
public static final int MEMORY_EFFICIENCY
public static final int WHITE_TO_MOVE
public static final int BLACK_TO_MOVE
public static final char NO_PIECE
public static final char PAWN
public static final char KNIGHT
public static final char BISHOP
public static final char ROOK
public static final char QUEEN
public static final char KING
public static final int NO_SQUARE
public static final int NO_CASTLE
public static final int WSHORT
public static final int WLONG
public static final int BSHORT
public static final int BLONG
public static GaviotaTableBaseJNI getInstance()
GaviotaTableBaseJNI
instance.public String init(boolean verbose, int compScheme, String paths)
verbose
- Whether information regarding the state of the library after initialization should be returned.compScheme
- The compression scheme to use.paths
- The paths to the folders containing the tablebase files.public String restart(boolean verbose, int compScheme, String paths)
verbose
- Whether information regarding the state of the library after initialization should be returned.compScheme
- The compression scheme to use.paths
- The paths to the folders containing the tablebase files.public int availability()
public long indexMemory()
public boolean initCache(long size, int wdlFraction)
size
- The cache size in bytes.wdlFraction
- The fraction of the cache (of a total of 128) that should be reserved for WDL information.public boolean restartCache(long size, int wdlFraction)
size
- The cache size in bytes.wdlFraction
- The fraction of the cache (of a total of 128) that should be reserved for WDL information.public boolean isCacheOn()
public void closeCache()
public void getStats(long[] intStats, double[] fpStats)
intStats
- A long array of length 14. The elements of the array after the execution of the method contain the following
statistics:[0] - WDL_EASY_HITS
[1] - WDL_HARD_PROB
[2] - WDL_SOFT_PROB
[3] - WDL_CACHE_SIZE
[4] - DTM_EASY_HITS
[5] - DTM_HARD_PROB
[6] - DTM_SOFT_PROB
[7] - DTM_CACHE_SIZE
[8] - TOTAL_HITS
[9] - MEMORY_HITS
[10] - DRIVE_HITS
[11] - DRIVE_MISSES
[12] - BYTES_READ
[13] - FILES_OPENED
fpStats
- A double array of length 3. The elements of the array after the execution of the method contain the following
statistics:[0] - WDL_OCCUPANCY
[1] - DTM_OCCUPANCY
[2] - MEMORY_EFFICIENCY
public void resetStats()
resetStats
in class EndGameTableBase
public int[] probe(int sideToMove, int enPassantSqr, int catlingRights, int[] wSqrs, int[] bSqrs, char[] wPcs, char[] bPcs)
sideToMove
- An integer denoting the side to move. 0
stands for white, 1
stands for black.enPassantSqr
- The index of the destination square of a potential en passant or NO_SQUARE
if none.catlingRights
- An integer representing the castling rights in the given position. It is the union of the appropriate castles
represented by NO_CASTLE
, WSHORT
, WLONG
, BSHORT
, and BLONG
.wSqrs
- An array of the square indices of all the white pieces and a final entry containing NO_SQUARE
.bSqrs
- An array of the square indices of all the black pieces and a final entry containing NO_SQUARE
.wPcs
- An array of the pieces as defined by the constants PAWN
, KNIGHT
, BISHOP
, ROOK
, QUEEN
, and KING
. Each element of the array denotes the piece on the square the element at the same index in the
wSqrs
array represents. The array also contains a final element denoting the end of the array with the value NO_PIECE
.bPcs
- An array of the pieces as defined by the constants PAWN
, KNIGHT
, BISHOP
, ROOK
, QUEEN
, and KING
. Each element of the array denotes the piece on the square the element at the same index in the
bSqrs
array represents. The array also contains a final element denoting the end of the array with the value NO_PIECE
.null
if the position was not found. The first element of the array contains the
WDL information while the second one contains the distance to mate.public int[] probeSoft(int sideToMove, int enPassantSqr, int catlingRights, int[] wSqrs, int[] bSqrs, char[] wPcs, char[] bPcs)
null
.sideToMove
- An integer denoting the side to move. 0
stands for white, 1
stands for black.enPassantSqr
- The index of the destination square of a potential en passant or NO_SQUARE
if none.catlingRights
- An integer representing the castling rights in the given position. It is the union of the appropriate castles
represented by NO_CASTLE
, WSHORT
, WLONG
, BSHORT
, and BLONG
.wSqrs
- An array of the square indices of all the white pieces and a final entry containing NO_SQUARE
.bSqrs
- An array of the square indices of all the black pieces and a final entry containing NO_SQUARE
.wPcs
- An array of the pieces as defined by the constants PAWN
, KNIGHT
, BISHOP
, ROOK
, QUEEN
, and KING
. Each element of the array denotes the piece on the square the element at the same index in the
wSqrs
array represents. The array also contains a final element denoting the end of the array with the value NO_PIECE
.bPcs
- An array of the pieces as defined by the constants PAWN
, KNIGHT
, BISHOP
, ROOK
, QUEEN
, and KING
. Each element of the array denotes the piece on the square the element at the same index in the
bSqrs
array represents. The array also contains a final element denoting the end of the array with the value NO_PIECE
.public int probeWDL(int sideToMove, int enPassantSqr, int catlingRights, int[] wSqrs, int[] bSqrs, char[] wPcs, char[] bPcs)
sideToMove
- An integer denoting the side to move. 0
stands for white, 1
stands for black.enPassantSqr
- The index of the destination square of a potential en passant or NO_SQUARE
if none.catlingRights
- An integer representing the castling rights in the given position. It is the union of the appropriate castles
represented by NO_CASTLE
, WSHORT
, WLONG
, BSHORT
, and BLONG
.wSqrs
- An array of the square indices of all the white pieces and a final entry containing NO_SQUARE
.bSqrs
- An array of the square indices of all the black pieces and a final entry containing NO_SQUARE
.wPcs
- An array of the pieces as defined by the constants PAWN
, KNIGHT
, BISHOP
, ROOK
, QUEEN
, and KING
. Each element of the array denotes the piece on the square the element at the same index in the
wSqrs
array represents. The array also contains a final element denoting the end of the array with the value NO_PIECE
.bPcs
- An array of the pieces as defined by the constants PAWN
, KNIGHT
, BISHOP
, ROOK
, QUEEN
, and KING
. Each element of the array denotes the piece on the square the element at the same index in the
bSqrs
array represents. The array also contains a final element denoting the end of the array with the value NO_PIECE
.WMATE
, BMATE
, DRAW
, FORBID
, and UNKNOWN
.public int probeSoftWDL(int sideToMove, int enPassantSqr, int catlingRights, int[] wSqrs, int[] bSqrs, char[] wPcs, char[] bPcs)
UNKNOWN
.sideToMove
- An integer denoting the side to move. 0
stands for white, 1
stands for black.enPassantSqr
- The index of the destination square of a potential en passant or NO_SQUARE
if none.catlingRights
- An integer representing the castling rights in the given position. It is the union of the appropriate castles
represented by NO_CASTLE
, WSHORT
, WLONG
, BSHORT
, and BLONG
.wSqrs
- An array of the square indices of all the white pieces and a final entry containing NO_SQUARE
.bSqrs
- An array of the square indices of all the black pieces and a final entry containing NO_SQUARE
.wPcs
- An array of the pieces as defined by the constants PAWN
, KNIGHT
, BISHOP
, ROOK
, QUEEN
, and KING
. Each element of the array denotes the piece on the square the element at the same index in the
wSqrs
array represents. The array also contains a final element denoting the end of the array with the value NO_PIECE
.bPcs
- An array of the pieces as defined by the constants PAWN
, KNIGHT
, BISHOP
, ROOK
, QUEEN
, and KING
. Each element of the array denotes the piece on the square the element at the same index in the
bSqrs
array represents. The array also contains a final element denoting the end of the array with the value NO_PIECE
.WMATE
, BMATE
, DRAW
, FORBID
, and UNKNOWN
.public boolean isInit()
EndGameTableBase
isInit
in class EndGameTableBase
public void clearCache()
EndGameTableBase
clearCache
in class EndGameTableBase
public void close()
public boolean areTableBasesAvailable(int piecesOnBoard)
EndGameTableBase
areTableBasesAvailable
in class EndGameTableBase
piecesOnBoard
- The total number of pieces on the board.public EndGameTableBase.EGTBStats getStats()
EndGameTableBase
getStats
in class EndGameTableBase
public void init(String path, long cacheSize, Object... args)
EndGameTableBase
init
in class EndGameTableBase
path
- The path to the folders containing the endgame tablebase files.cacheSize
- The size of the probing cache in bytes.args
- Optional arguments.public EndGameTableBase.WDL probeWDL(Position pos, boolean soft)
EndGameTableBase
probeWDL
in class EndGameTableBase
pos
- The chess position to look for.soft
- Whether only the cache should be probed.public EndGameTableBase.DTM probeDTM(Position pos, boolean soft)
EndGameTableBase
probeDTM
in class EndGameTableBase
pos
- The chess position to look for.soft
- Whether only the cache should be probed.Copyright © 2020. All rights reserved.