Python SDK for Bombahead Bomberman bot competition
Project description
Bombahead Python SDK
Welcome to the bombahead-py documentation. This SDK is designed for developers who wish to build autonomous agents (bots) for the Bombahead competition.
As software engineers, our goal is to abstract away the underlying networking protocols, serialization formats, and game loop timing. The SDK handles all of these infrastructural concerns, allowing you to focus purely on the algorithmic design of your bot: state evaluation, pathfinding, and decision-making.
1. Getting Started
The SDK requires Python 3.10 or higher. You can install it directly via pip:
pip install bombahead-py
2. Core Architecture
The architecture of the SDK is built around a simple reactive event loop. Your bot operates as an asynchronous callback invoked upon receiving a state update from the server.
To implement a bot, you must define a class that satisfies the Bot protocol. This requires implementing a single method: get_next_move(self, state: GameState, helpers: GameHelpers) -> Action.
Example: A Minimal Bot
from bombahead import Action, Bot, GameHelpers, GameState, run
class MyBot(Bot):
def get_next_move(self, state: GameState, helpers: GameHelpers) -> Action:
# A trivial policy: always do nothing.
return Action.DO_NOTHING
if __name__ == "__main__":
# `run` blocks the main thread, handling the event loop and network I/O
run(MyBot())
3. State Representation (GameState)
The GameState object provides a complete snapshot of the game environment at the current tick.
3.1 Properties of GameState
current_tick: int: The discrete time step of the current simulation frame.me: Player | None: Your bot's entity. It may beNoneif the game has not fully initialized or if your bot has been eliminated.opponents: list[Player]: A list of active adversary entities.field: Field: The 2D grid representing the arena.bombs: list[Bomb]: Active bombs currently placed on the field.explosions: list[Position]: Positions currently covered by active blast waves.
3.2 Key Models
Player
id: str: The unique identifier.pos: Position: The entity's coordinate.health: int: Current hit points.score: int: Current accumulated score.
Position
A simple immutable 2D vector (x, y). Provides a utility method distance_to(other: Position) -> int to compute the Manhattan distance (L1 norm) between two points.
Bomb
pos: Position: Where the bomb is placed.fuse: int: Ticks remaining until detonation. A fuse of1means it detonates on the next tick.
Field
Represents the discrete matrix of the game.
width: int,height: int: The dimensions of the map.cell_at(pos: Position) -> CellType: Safely returns the material of a given coordinate. Out-of-bounds coordinates implicitly returnCellType.WALL.
CellType Enum
AIR: Traversable space.WALL: Indestructible boundary or obstacle.BOX: Destructible obstacle that may yield points or clear paths.
4. The Decision Space (Action)
Your algorithmic policy must evaluate the state and return one of the following deterministic actions defined in the Action enum:
Action.MOVE_UPAction.MOVE_DOWNAction.MOVE_LEFTAction.MOVE_RIGHTAction.PLACE_BOMBAction.DO_NOTHING
5. Algorithmic Helpers (GameHelpers)
To accelerate development and prevent the reinvention of standard algorithms, the SDK provides the GameHelpers class. This is instantiated automatically per tick and provides optimized implementations for common spatial queries.
Navigation and Traversal
-
is_walkable(pos: Position) -> boolChecks if a position is strictly within bounds, not a wall, not a box, and not currently occupied by a bomb. -
get_adjacent_walkable_positions(pos: Position) -> list[Position]Returns a list of orthogonally adjacent coordinates that are currently walkable. -
get_next_action_towards(start: Position, target: Position) -> ActionComputes the shortest path fromstarttotargetusing Breadth-First Search (BFS). Returns the immediateActionrequired to step along that path. If no path exists, returnsAction.DO_NOTHING.
Hazard Analysis
-
is_safe(pos: Position) -> boolA critical heuristic. Evaluates whether a given position is currently free of bombs, active explosions, and imminent blast radii (i.e., it simulates bomb blast patterns across the grid). -
get_nearest_safe_position(start: Position) -> PositionUses BFS to locate the closest coordinate that satisfiesis_safe() == True. Crucial for evasion routines. If the current position is already safe, it returnsstart.
Tactical Queries
find_nearest_box(start: Position) -> tuple[Position, bool]Locates the closest destructibleBOXusing BFS. Returns a tuple(Position, bool). The boolean indicates whether a box was successfully found.
6. Design Philosophy & Advice
As you design your bot, treat the get_next_move function as a pure functional mapping from State to Action. Avoid relying heavily on external mutable state across ticks unless you are implementing advanced predictive models or tracking specific adversary behaviors.
A Recommended Architecture:
- Survival Prioritization: Always check if your current
Positionis safe (helpers.is_safe()). If not, immediately defer tohelpers.get_next_action_towards()targetinghelpers.get_nearest_safe_position(). - Offensive Strategy: If safe, locate targets (boxes or opponents) and evaluate if placing a bomb will yield a strategic advantage without trapping your own bot.
- Traversal: Use the pathfinding helpers to close the distance to targets.
Good luck, and build algorithms that are both robust and theoretically sound.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bombahead_py-0.1.3.tar.gz.
File metadata
- Download URL: bombahead_py-0.1.3.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
396c3d20f6de7b5689e84be2537781fe47c2f0e90d6067f4e175e3129add3010
|
|
| MD5 |
6cd78e12cad337d81d9df11d16a68351
|
|
| BLAKE2b-256 |
bc3072fda10822f3d24d3c6e92b9d55c0be09d49fe97cbe36f04815ce5b42752
|
File details
Details for the file bombahead_py-0.1.3-py3-none-any.whl.
File metadata
- Download URL: bombahead_py-0.1.3-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3661c600093a9a2a5a8a978b7b45d998788d0cf45298e63ac13c9f1558192b49
|
|
| MD5 |
761fc9798aa8112f2e5afb659e16882a
|
|
| BLAKE2b-256 |
a70b0671fb1cfbb7cc028b4cb7a50353926c32f1033685e9c3154c7e3ac1683c
|