Class Player

java.lang.Object
ygraph.ai.smartfox.games.GamePlayer
ubc.team09.player.Player

public class Player extends ygraph.ai.smartfox.games.GamePlayer
This class handles communication with the game server. It holds no logic for making decisions; all game decisions are made by the VI that it is assigned.

Example
Player player = new Player(
	"username",  // The username used for communication with the server.
	new EDI(),   // Use the EDI VI to decide moves.
	C.BLACK,     // Black plays first.
	30           // 30 seconds per move.
)

// Try to connect to the server.
try {
	player.connect();
} catch (Exception e) {
	System.out.println("Error connecting to the server.")
}
  • Constructor Details

    • Player

      public Player(String username, VI vi, byte startingColor, int timeLimit)
      Creates a new game player which consults the given VI for decisions.
      Parameters:
      username - The username assigned to this player.
      vi - The VI to consult for move recommendations.
      startingColor - Indicates which color will move first (in case, for some reason, Black is supposed to move first).
      timeLimit - The time limit per turn, in seconds.
  • Method Details

    • connect

      public void connect()
      Specified by:
      connect in class ygraph.ai.smartfox.games.GamePlayer
    • getGameClient

      public ygraph.ai.smartfox.games.GameClient getGameClient()
      Specified by:
      getGameClient in class ygraph.ai.smartfox.games.GamePlayer
    • getGameGUI

      public ygraph.ai.smartfox.games.BaseGameGUI getGameGUI()
      Specified by:
      getGameGUI in class ygraph.ai.smartfox.games.GamePlayer
    • handleMessage

      public boolean handleMessage(String msgType, String msg)
      Overrides:
      handleMessage in class ygraph.ai.smartfox.games.GamePlayer
    • handleGameMessage

      public boolean handleGameMessage(String msgType, Map<String,Object> details)
      Specified by:
      handleGameMessage in class ygraph.ai.smartfox.games.GamePlayer
    • onLogin

      public void onLogin()
      Specified by:
      onLogin in class ygraph.ai.smartfox.games.GamePlayer
    • userName

      public String userName()
      Specified by:
      userName in class ygraph.ai.smartfox.games.GamePlayer