Class Util

java.lang.Object
ubc.team09.player.Util

public class Util extends Object
A class that contains a set of general utility functions used for communicating with the game server.
  • Method Details

    • randomBoard

      public static State randomBoard(double arrowDensity)
      Generates a random Amazons boardstate.
    • initialBoard

      public static State initialBoard()
      Generates the starting Amazons board state.
    • parseState

      public static BoardState parseState(Map<String,Object> messageDetails)
      Parses the occupancy board and queen positions from a GAME_STATE_BOARD or GAME_ACTION_START message.

      If the board received from the server is incoherent in some way (e.g., it is missing a queen), then this will return null.
    • parseMove

      public static int parseMove(BoardState state, Map<String,Object> details)
      Formats the message details of a message of the type GAME_ACTION_MOVE into the standard integer representation.

      If the start position in the received move does not match any of the state's queens, then the player will be set to -1.
    • getStartPosition

      public static ArrayList<Integer> getStartPosition(int move)
      Takes a move from the standard integer encoding and returns a server- appropriate ArrayList that represents it's starting position.
    • getEndPosition

      public static ArrayList<Integer> getEndPosition(int move)
      Takes a move from the standard integer encoding and returns a server- appropriate ArrayList that represents it's starting position.
    • getArrowPosition

      public static ArrayList<Integer> getArrowPosition(int move)
      Takes a move from the standard integer encoding and returns a server- appropriate ArrayList that represents it's starting position.