Class Agent


  • public abstract class Agent
    extends Object
    Superclass to extend agents from.
    • Constructor Detail

      • Agent

        public Agent​(String host,
                     Integer port,
                     ProtocolManager.ConnectionType conType,
                     String name,
                     String authors,
                     String description,
                     String token,
                     boolean printNetwork)
        Creates an agent which is ready to connect to the specified server, introducing itself with the given attributes if provided. See parameters for details.
        Parameters:
        host - Server to connect to.
        port - Port to connect via, should be null iff you're using WebSocket or WebSocketSecure.
        conType - Type of connection TCP, WebSocket, WebSocketSecure.
        name - Name of the agent, can be null.
        authors - Authors of the agent, can be null.
        description - Description of the agent, can be null.
        token - Token of the agent, can be null.
        printNetwork - Whether to print client-server-communication to stdout.
    • Method Detail

      • search

        public abstract void search​(KalahState ks)
                             throws IOException
        Called when the server sends a state to the client e.g. asks it to start computing moves for that state. Important: Also see should_stop()
        Parameters:
        ks - A board with south to move
        Throws:
        IOException - If something goes wrong during the computation of the move
      • getName

        public String getName()
        Returns agent's name or null if not specified.
      • getAuthors

        public String getAuthors()
        Returns agent's authors or null if not specified.
      • getDescription

        public String getDescription()
        Returns agent's description or null if not specified.
      • getToken

        public String getToken()
        Returns agent's token or null if not specified.
      • run

        public final void run()
                       throws IOException
        Connects to the server, plays games until the server closes the connection or an error occurs. Exits the connection in a clean way upon error and passes the Exception to the caller as an IOException.
        Throws:
        IOException - In case an I/O error occurs (also includes protocol and agent errors).