Package benchmark.simulation
Class ConnectionSimulation
java.lang.Object
benchmark.simulation.ConnectionSimulation
ConnectionSimulation of full games between two AIs.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass to represent the result of a game, including the winning AI and the color. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbytesToGigabytes(long bytes) static voidMain method to run a simulation between two AIs using predefined configurations and an initial board state.playGame(AI firstAI, SearchConfig firstConfig, AI secondAI, SearchConfig secondConfig, String fen, boolean showGame, ConnectionSimulationConfig timeConfigFirst, ConnectionSimulationConfig timeConfigSecond) Plays a full game between two AIs using the provided configurations and initial board state.readFileAndFillBib(String fileLocation, int player, HashMap<String, String> openingLib) Fills the startingBib HashMap with precalculated starting moves.voidsimulate(AI firstAI, SearchConfig firstConfig, AI secondAI, SearchConfig secondConfig, String fen, int iterations, boolean showGame, ConnectionSimulationConfig timeConfigFirst, ConnectionSimulationConfig timeConfigSecond) Simulates a series of games between two AIs using the provided configurations and initial board state.
-
Constructor Details
-
ConnectionSimulation
public ConnectionSimulation()
-
-
Method Details
-
playGame
public static ConnectionSimulation.GameResult playGame(AI firstAI, SearchConfig firstConfig, AI secondAI, SearchConfig secondConfig, String fen, boolean showGame, ConnectionSimulationConfig timeConfigFirst, ConnectionSimulationConfig timeConfigSecond) throws IOException Plays a full game between two AIs using the provided configurations and initial board state.- Parameters:
firstAI- The first AI that will play.firstConfig- The configuration for the first AI's search algorithm.secondAI- The second AI that will play.secondConfig- The configuration for the second AI's search algorithm.fen- The initial board state in FEN format.showGame- Whether to show the game play.timeConfigFirst- Time configuration of firstAI.timeConfigSecond- Time configuration of secondAI.- Returns:
- An integer indicating the winner of the game. Returns 1 if the first AI wins, 2 if the second AI wins.
- Throws:
IOException
-
simulate
public void simulate(AI firstAI, SearchConfig firstConfig, AI secondAI, SearchConfig secondConfig, String fen, int iterations, boolean showGame, ConnectionSimulationConfig timeConfigFirst, ConnectionSimulationConfig timeConfigSecond) throws IOException Simulates a series of games between two AIs using the provided configurations and initial board state. The results of each game and the overall win counts for each AI are printed to the console.- Parameters:
firstAI- The first AI that will play.firstConfig- The configuration for the first AI's search algorithm.secondAI- The second AI that will play.secondConfig- The configuration for the second AI's search algorithm.fen- The initial board state in FEN format.iterations- The number of iterations (games) to simulate. Must be an even number.showGame- Whether to show the game play.timeConfigFirst- Time configuration of firstAI.timeConfigSecond- Time configuration of secondAI.- Throws:
IOException
-
bytesToGigabytes
-
readFileAndFillBib
public static HashMap<String,String> readFileAndFillBib(String fileLocation, int player, HashMap<String, String> openingLib) throws IOExceptionFills the startingBib HashMap with precalculated starting moves.- Parameters:
fileLocation- Path to the File- Throws:
IOException
-
main
Main method to run a simulation between two AIs using predefined configurations and an initial board state. Prints results to a file.- Parameters:
args- Command line arguments (not used).
-