Arena Building Blocks¶
-
battleground.games.arena.building_blocks.
attack
(state, target)[source]¶ Generate a move object to attack the target, if that is a valid move. Otherwise, return None.
Parameters: - state – The current game state.
- target – id of the target.
Returns: A move object (dict) or None
-
battleground.games.arena.building_blocks.
attack_closest
(state)[source]¶ Generate a move object to attack the closest other player, if that is a valid move. Otherwise, return None.
Parameters: state – The current game state. Returns: A move object (dict), or None.
-
battleground.games.arena.building_blocks.
attack_myself
(state)[source]¶ Generate a move object to attack yourself.
Parameters: state – The current game state. Returns: A move object (dict).
-
battleground.games.arena.building_blocks.
closest_other
(state)[source]¶ Get the id of the closest other player.
Parameters: state – The current game state. Returns: (int) index in gladiator list.
-
battleground.games.arena.building_blocks.
closest_other_location
(state)[source]¶ Get the location of the closest other player, e.g., (x, y).
Parameters: state – The current game state. Returns: tuple (x, y).
-
battleground.games.arena.building_blocks.
distances
(reference_location, locations)[source]¶ Compute distances from a reference location to a set of other locations.
Parameters: - reference_location – iterable of coordinates, e.g., (1, 2)
- locations – iterable of iterables of coordinates, e.g., [(0, 0), (2, 1), …]
Returns: dict of distances {id: float, …}
-
battleground.games.arena.building_blocks.
move_away
(state, location)[source]¶ Generate move that takes you most quickly away from the specified location.
Parameters: - state – The current game state.
- location – tuple of target position, e.g, (x, y)
Returns: A move object (dict).
-
battleground.games.arena.building_blocks.
move_relative
(state, location, towards)[source]¶ Generate move that takes you most directly towards or away from the specified location.
shorthand functions move_toward and move_away are available.
Parameters: - state – The current game state.
- location – tuple of target position, e.g, (x, y)
- towards – bool, move towards location if true, away otherwise
Returns: A move object (dict).
-
battleground.games.arena.building_blocks.
move_toward
(state, location)[source]¶ Generate move that takes you most directly to the specified location.
Parameters: - state – The current game state.
- location – tuple of target position, e.g, (x, y)
Returns: A move object (dict).
-
battleground.games.arena.building_blocks.
my_hitpoints
(state)[source]¶ Return current health (hitpoints) of the player.
Parameters: state – The current game state. Returns: int.
-
battleground.games.arena.building_blocks.
my_location
(state)[source]¶ Get the location of the current player.
Parameters: state – The current game state. Returns: tuple (x, y)
-
battleground.games.arena.building_blocks.
others
(state, alive=True)[source]¶ Get a dictionary of other players.
Parameters: state – The current game state. Returns: (dict) {id: player data, …}