Package com.codingame.gameengine.runner
Class JavaPlayerAgent
java.lang.Object
com.codingame.gameengine.runner.JavaPlayerAgent
A participating AI written as a Java class.
-
Field Summary
-
Constructor Summary
-
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
-
JavaPlayerAgent
- Parameters:
className
- The name of the class to use as a participating AI.
-
-
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
-
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
-
getOutput
Get the output of an agent- Parameters:
nbLine
- Number of lines wantedtimeout
- Stop reading after timeout milliseconds- Returns:
- the agent output
-
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
-