public class Solver
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static int |
MAX_DEPTH
Maximum search depth
|
static int |
MAX_SEEDS
Maximum number of seeds in a position
|
static int |
SIZE
Number of possible endgame positions
|
Constructor and Description |
---|
Solver()
Instantiates a new endgame solver.
|
Modifier and Type | Method and Description |
---|---|
int |
exactCount()
Returns the total number of known positions.
|
int |
exactCount(int numSeeds)
Returns the number of known positions with exactly the number
of specified seeds.
|
void |
expand(byte numSeeds)
Expands all the positions with exactly
numSeeds seeds
with all their children and marks all the terminal nodes as known. |
void |
exportToBook(java.lang.String path,
int numSeeds)
Exports the generated endgame database to a suitable book file.
|
boolean |
isCapture(byte[] position,
byte move)
Checks if the move is a capturing move for the given position
|
static void |
main(java.lang.String[] argv)
Builds an endgame tablebase in a progressive manner.
|
int |
markComponents(int numSeeds)
Finds all the unknown nodes with N seeds that are part of a
strongly-connected component and flags them appropiately.
|
int |
numPositions()
Returns the total number of positions that exist.
|
int |
numPositions(int numSeeds)
Returns the number of positions that exist with exactly the number
of specified seeds.
|
int |
previousFlag()
Returns the latest used cycle flag.
|
void |
propagate(byte numSeeds)
Performs an iterative minimax propagation of the nodes until no
more nodes can obtain it's value.
|
static Solver |
readGraph(java.lang.String path)
Unserializes this object from a file.
|
void |
solveComponent(int numSeeds,
int flag)
Individually solves each node pertaining to the flagged strongly
connected component.
|
void |
writeGraph(java.lang.String path)
Serializes this object to a file.
|
public static final int SIZE
public static final int MAX_DEPTH
public static final int MAX_SEEDS
public void expand(byte numSeeds)
numSeeds
seeds
with all their children and marks all the terminal nodes as known.numSeeds
- number of seedspublic void propagate(byte numSeeds)
numSeeds
- number of seeds for the nodespublic int markComponents(int numSeeds)
numSeeds
- number of seedspublic void solveComponent(int numSeeds, int flag)
numSeeds
- number of seedsflag
- component flagpublic boolean isCapture(byte[] position, byte move)
position
- position representationmove
- the move to determine if it's a capturetrue
if the move is a legal capturepublic int exactCount(int numSeeds)
numSeeds
- number of seedspublic int exactCount()
public int numPositions(int numSeeds)
numSeeds
- number of seedspublic int numPositions()
public int previousFlag()
public void exportToBook(java.lang.String path, int numSeeds) throws java.io.IOException
path
- file pathjava.io.IOException
public void writeGraph(java.lang.String path) throws java.io.IOException
path
- file pathjava.io.IOException
public static Solver readGraph(java.lang.String path) throws java.lang.Exception
path
- file pathjava.lang.Exception
public static void main(java.lang.String[] argv) throws java.lang.Exception
argv
- Command line arguments.java.lang.Exception