Class Util
java.lang.Object
ubc.team09.player.Util
A class that contains a set of general utility functions used for
communicating with the game server.
-
Method Summary
Modifier and TypeMethodDescriptiongetArrowPosition(int move) Takes a move from the standard integer encoding and returns a server- appropriate ArrayList that represents it's starting position.getEndPosition(int move) Takes a move from the standard integer encoding and returns a server- appropriate ArrayList that represents it's starting position.getStartPosition(int move) Takes a move from the standard integer encoding and returns a server- appropriate ArrayList that represents it's starting position.static StateGenerates the starting Amazons board state.static intparseMove(BoardState state, Map<String, Object> details) Formats the message details of a message of the typeGAME_ACTION_MOVEinto the standard integer representation.static BoardStateparseState(Map<String, Object> messageDetails) Parses the occupancy board and queen positions from aGAME_STATE_BOARDorGAME_ACTION_STARTmessage.static StaterandomBoard(double arrowDensity) Generates a random Amazons boardstate.
-
Method Details
-
randomBoard
Generates a random Amazons boardstate. -
initialBoard
Generates the starting Amazons board state. -
parseState
Parses the occupancy board and queen positions from aGAME_STATE_BOARDorGAME_ACTION_STARTmessage.
If the board received from the server is incoherent in some way (e.g., it is missing a queen), then this will returnnull. -
parseMove
Formats the message details of a message of the typeGAME_ACTION_MOVEinto the standard integer representation.
If thestartposition in the received move does not match any of the state's queens, then theplayerwill be set to-1. -
getStartPosition
-
getEndPosition
-
getArrowPosition
-