public final class DataSetUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
filterDraws(String sourceEpdFile,
String destinationEpdFile,
String gameResultOpCode)
Copies all the lines from the source EPD file to the destination file except for the ones representing positions from drawn games.
|
static void |
filterTacticalPositions(String sourceEpdFile,
String destinationEpdFile,
ControllerEngine engine)
Copies all the lines from the source EPD file to the destination file except the positions that allow for legal tactical moves.
|
static void |
filterUnbalancedPositions(String sourceEpdFile,
String destinationEpdFile,
short imbalance,
TunableEngine engine)
Copies all the lines from the source EPD file to the destination file except for the ones representing either too unbalanced or too
balanced positions based on the engine to tune's evaluation function.
|
static int |
generateEPDFile(ControllerEngine engine,
String pgnFilePath,
String epdFilePath,
String gameResultOpCode,
long maxNumOfGames,
Integer minElo,
Integer minHalfMoveIndex)
Generates an EPD file of positions labelled by the results of the games the positions occurred.
|
static void |
generatePGNFile(List<SelfPlayEngines<UCIEngine>> engines,
int games,
long timePerGame,
long timeIncPerMove,
String pgnFilePath)
Generates a PGN file of self-play games.
|
public static void generatePGNFile(List<SelfPlayEngines<UCIEngine>> engines, int games, long timePerGame, long timeIncPerMove, String pgnFilePath) throws IOException, InterruptedException, ExecutionException
engines
- A list of SelfPlayEngines
instances that each contain the engines needed
for playing games in the Arena
. For each non-null element in the list, a new thread will
be utilized for the optimization. E.g. if engines is a list of four non-null elements, the games in the fitness function will be
distributed and played parallel on four threads. The list's first element cannot be null or a NullPointerException
is
thrown.games
- The number of games to play.timePerGame
- The time each engine will have per game in milliseconds.timeIncPerMove
- The number of milliseconds with which the remaining time of an engine is incremented after each legal move. be
done.pgnFilePath
- The path to the output PGN file.IOException
- If the file specified by filePath doesn't exist and cannot be created.NullPointerException
- If the parameter engines is null.IllegalArgumentException
- If engines doesn't contain at least one non-null element.ExecutionException
- If an execution exception occurs in one of the threads.InterruptedException
- If the current thread is interrupted while waiting for the worker threads to finish.public static int generateEPDFile(ControllerEngine engine, String pgnFilePath, String epdFilePath, String gameResultOpCode, long maxNumOfGames, Integer minElo, Integer minHalfMoveIndex) throws Exception
engine
- A controller engine that will be responsible for parsing the PGNs and providing FEN descriptions for each position.pgnFilePath
- The path to the file containing the games in PGN.epdFilePath
- The output file path.gameResultOpCode
- The operation code of the label.maxNumOfGames
- The maximum number of games that will be parsed and converted into EPD records.minElo
- The minimum Elo rating required for each party to process the game.minHalfMoveIndex
- The half move index from which positions of a game are saved in the EPD file.Exception
- If the input file does not exist or cannot be read, if the output file path is invalid, or if the engine is not
initialized and cannot be initialized.public static void filterUnbalancedPositions(String sourceEpdFile, String destinationEpdFile, short imbalance, TunableEngine engine) throws Exception
sourceEpdFile
- The file path to the source EPD file.destinationEpdFile
- The path to the destination file. If it doesn't exist it will be created.imbalance
- The maximum allowed absolute score difference in centi-pawns. If it is negative, the minimum necessary score
difference.engine
- The engine to use for unbalanced position detection.Exception
- If the source and destination paths are the same, there is an I/O issue or the engine cannot be initialized.public static void filterDraws(String sourceEpdFile, String destinationEpdFile, String gameResultOpCode) throws IOException
sourceEpdFile
- The file path to the source EPD file.destinationEpdFile
- The path to the destination file. If it doesn't exist it will be created.gameResultOpCode
- The operation code of the label.IOException
- If the source cannot be read from and the destination cannot be created or written to.public static void filterTacticalPositions(String sourceEpdFile, String destinationEpdFile, ControllerEngine engine) throws Exception
sourceEpdFile
- The file path to the source EPD file.destinationEpdFile
- The path to the destination file. If it doesn't exist it will be created.engine
- The engine to use for tactical position detection.Exception
- If the source and destination paths are the same, there is an I/O issue or the engine cannot be initialized.Copyright © 2020. All rights reserved.