Package com.codingame.gameengine.runner
Class SoloGameRunner
java.lang.Object
com.codingame.gameengine.runner.SoloGameRunner
The class to use to run local games and display the replay in a webpage on a temporary local server.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOnce this runner is instantiated, the system property game.mode is set to "solo" -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbuildInitCommand(com.codingame.gameengine.runner.Command initCommand) voidSets an AI to the next game to run.voidSets an AI to the next game to run.voidSets an AI to the next game to run.voidSets an AI to the next game to run.voidsetTestCase(File testCaseFile) Sets a test case file which testIn value will be sent to the Game Manager as a test case input.voidsetTestCase(String testCaseFileName) Sets a test case file by file path which testIn value will be sent to the Game Manager as a test case input.voidsetTestCaseInput(String testCaseInput) Sets aStringas a test case input that will be sent to the Game Manager.voidsetTestCaseInput(List<String> testCaseInput) Sets a list ofStringas a test case input that will be sent to the Game Manager.simulate()Runs the game without a server and returns computed game resultsvoidstart()Runs the game and attempts to start a server on the port 8888.voidstart(int port) Runs the game and attempts to start a server on the given port.
-
Field Details
-
log
protected static org.apache.commons.logging.Log log -
players
-
-
Constructor Details
-
SoloGameRunner
public SoloGameRunner()Once this runner is instantiated, the system property game.mode is set to "solo"
-
-
Method Details
-
setTestCase
Sets a test case file by file path which testIn value will be sent to the Game Manager as a test case input.The file path must be relative considering the root directory is config.
- Parameters:
testCaseFileName- the test case file path (JSON or YAML)
-
setTestCase
Sets a test case file which testIn value will be sent to the Game Manager as a test case input.- Parameters:
testCaseFile- the test case file (JSON or YAML)
-
setTestCaseInput
Sets a list ofStringas a test case input that will be sent to the Game Manager.- Parameters:
testCaseInput- the list ofStringof the test case input
-
setTestCaseInput
Sets aStringas a test case input that will be sent to the Game Manager.The input will be split in several lines by \n.
- Parameters:
testCaseInput- theStringof the test case input
-
setAgent
Sets an AI to the next game to run.- Parameters:
playerClass- the Java class of an AI for your game.
-
setAgent
Sets an AI to the next game to run.The given command will be executed with
Runtime.getRuntime().exec().- Parameters:
commandLine- the system command line to run the AI.
-
setAgent
Sets an AI to the next game to run.- Parameters:
playerClass- the Java class of an AI for your game.nickname- the player's nicknameavatarUrl- the url of the player's avatar
-
setAgent
Sets an AI to the next game to run.The given command will be executed with
Runtime.getRuntime().exec().- Parameters:
commandLine- the system command line to run the AI.nickname- the player's nicknameavatarUrl- the url of the player's avatar
-
buildInitCommand
protected void buildInitCommand(com.codingame.gameengine.runner.Command initCommand) -
start
public void start()Runs the game and attempts to start a server on the port 8888.Open a webpage to the server to watch the game's replay.
-
start
public void start(int port) Runs the game and attempts to start a server on the given port.Open a webpage to the server to watch the game's replay.
- Parameters:
port- the port on which to attempt to start the a server for the game's replay.
-
simulate
Runs the game without a server and returns computed game results- Returns:
- game result of the game
-