Package com.codingame.gameengine.runner
Class CommandLinePlayerAgent
java.lang.Object
com.codingame.gameengine.runner.CommandLinePlayerAgent
This class is used in with the
GameRunner
to add an AI as a player.-
Field Summary
-
Constructor Summary
ConstructorDescriptionCommandLinePlayerAgent
(String commandLine) Creates an Agent for your game, will run the given commandLine at game startCommandLinePlayerAgent
(String[] commandArray) Creates an Agent for your game, will run the given commandLine at game start -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
void
execute()
Compile and run an agent.int
protected InputStream
protected OutputStream
getOutput
(int nbLine, long timeout) Get the output of an agentgetOutput
(int nbLine, long timeout, boolean extraBufferSpace) protected InputStream
void
initialize
(Properties conf) Initialize an agent given global properties.boolean
isFailed()
Read all errors from standard error streamprotected void
Launch the agent.void
Write 'input' to standard input of agentvoid
setAgentId
(int agentId) void
void
setFailed
(boolean failed) void
setNickname
(String nickname)
-
Field Details
-
UTF8
-
AGENT_MAX_BUFFER_SIZE
public static final int AGENT_MAX_BUFFER_SIZE- See Also:
-
THRESHOLD_LIMIT_STDERR_SIZE
public static final int THRESHOLD_LIMIT_STDERR_SIZE- See Also:
-
-
Constructor Details
-
CommandLinePlayerAgent
Creates an Agent for your game, will run the given commandLine at game start- Parameters:
commandLine
- the command line to run
-
CommandLinePlayerAgent
Creates an Agent for your game, will run the given commandLine at game start- Parameters:
commandArray
- the command array to run
-
-
Method Details
-
getInputStream
-
getOutputStream
-
getErrorStream
-
initialize
Initialize an agent given global properties. A call to this function is needed before-all- Parameters:
conf
- Global configuration
-
getOutput
Get the output of an agent- Parameters:
nbLine
- Number of lines wantedtimeout
- Stop reading after timeout milliseconds- Returns:
- the agent output
-
runInputOutput
Launch the agent. After the call, agent is ready to process input / output- Throws:
Exception
- if an error occurs
-
destroy
public void destroy() -
execute
public void execute()Compile and run an agent. After this, agent is ready for input / output -
sendInput
Write 'input' to standard input of agent- Parameters:
input
- an input to write
-
readError
Read all errors from standard error stream- Returns:
- all errors
-
getAgentId
public int getAgentId() -
setAgentId
public void setAgentId(int agentId) -
setFailed
public void setFailed(boolean failed) -
isFailed
public boolean isFailed() -
getNickname
-
setNickname
-
getAvatar
-
setAvatar
-
getOutput
-