Created
April 17, 2020 11:24
-
-
Save jmerle/9607f7e1bc4614126094fa4584d35edc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List, Optional, Tuple | |
from battlehack20.engine.game.game import * | |
def log(msg: str): | |
""" | |
Type-agnostic method. | |
Logs a message. | |
""" | |
... | |
def get_board_size() -> int: | |
""" | |
Type-agnostic method. | |
Returns the board size. | |
""" | |
... | |
def get_bytecode() -> int: | |
""" | |
Type-agnostic method. | |
Returns the number of bytecodes left. | |
""" | |
... | |
def get_team() -> Team: | |
""" | |
Type-agnostic method. | |
Returns the robot’s team, either `Team.WHITE` or `Team.BLACK`. | |
""" | |
... | |
def get_type() -> RobotType: | |
""" | |
Type-agnostic method. | |
Returns the robot’s type, either `RobotType.OVERLORD` or `RobotType.PAWN`. | |
""" | |
... | |
def check_space(row: int, col: int) -> bool: | |
""" | |
Type-agnostic method. | |
Returns `False` if there is no robot at the location, the robot type of the robot if there is one there, | |
and throws a `RobotError` if outside the vision range. | |
""" | |
... | |
def get_board() -> List[List[Optional[Team]]]: | |
""" | |
Overlord method. | |
Returns the current state of the board as an array of `Team.WHITE`, `Team.BLACK`, and `None`, representing | |
white-occupied, black-occupied, and empty squares, respectively. | |
""" | |
... | |
def spawn(row: int, col: int): | |
""" | |
Overlord method. | |
Spawns a pawn at the given location, but throws a `RobotError` if the pawn is not spawned at the edge on your | |
side of the board, or if you have already spawned a pawn in this turn. | |
""" | |
... | |
def capture(row: int, col: int): | |
""" | |
Pawn method. | |
Captures an enemy piece at the given location, but throws a `RobotError` if the there is not an enemy pawn there | |
or if the location is not diagonally in front of you. | |
""" | |
... | |
def get_location() -> Tuple[int, int]: | |
""" | |
Pawn method. | |
Returns a `(row, col)` tuple of the robot’s location. | |
""" | |
... | |
def move_forward(): | |
""" | |
Pawn method. | |
Moves forward one step, but throws a `RobotError` if you have already moved, if the location is outside the board | |
or if there is another pawn in front of you. | |
""" | |
... | |
def sense() -> List[Tuple[int, int, Team]]: | |
""" | |
Pawn method. | |
Returns a list of tuples of the form `(row, col, robot.team)` visible to this robot (excluding yourself), | |
that is, if `max(|robot.x - other.x|, |robot.y - other.y|) <= 2`. | |
""" | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment