Class JavaPlayerAgent

java.lang.Object
com.codingame.gameengine.runner.JavaPlayerAgent

public class JavaPlayerAgent extends Object
A participating AI written as a Java class.
  • Field Details

    • UTF8

      public static final Charset 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

      public JavaPlayerAgent(String className)
      Parameters:
      className - The name of the class to use as a participating AI.
  • Method Details

    • getInputStream

      protected OutputStream getInputStream()
    • getOutputStream

      protected InputStream getOutputStream()
    • getErrorStream

      protected InputStream getErrorStream()
    • initialize

      public void initialize(Properties conf)
      Initialize an agent given global properties. A call to this function is needed before-all
      Parameters:
      conf - Global configuration
    • runInputOutput

      protected void runInputOutput() throws Exception
      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

      public void sendInput(String input)
      Write 'input' to standard input of agent
      Parameters:
      input - an input to write
    • getOutput

      public String getOutput(int nbLine, long timeout)
      Get the output of an agent
      Parameters:
      nbLine - Number of lines wanted
      timeout - Stop reading after timeout milliseconds
      Returns:
      the agent output
    • readError

      public String 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

      public String getNickname()
    • setNickname

      public void setNickname(String nickname)
    • getAvatar

      public String getAvatar()
    • setAvatar

      public void setAvatar(String avatar)
    • getOutput

      public String getOutput(int nbLine, long timeout, boolean extraBufferSpace)