BotContext (self.ctx)
Accessible inside act() via self.ctx. Provides a read-only interface to the game state for a specific bot.
Robot Status
get_id(): Returns the unique bot ID (int).get_energy(): Returns current energy (int).get_location(): Returns currentPoint(x, y).get_abilities(): Returns list of abilities (list[str]).get_algae_held(): Returns amount of algae held (int).get_type(): Returns list of abilities (alias forget_abilities).spawn_cost(abilities): Returns the scrap cost to spawn a bot with given abilities (int).api: TheGameAPIinstance (see GameAPI).
Example
Sensing
sense_enemies(): Returns list of visibleEnemyBots.sense_enemies_in_radius(point, radius): Returns list ofEnemyBots within radius of a point.sense_own_bots(): Returns list of your otherBots.sense_own_bots_in_radius(point, radius): Returns list of yourBots within radius of a point.sense_algae(radius): Returns list ofAlgaewithin radius of the bot.sense_algae_in_radius(point, radius): Returns list ofAlgaewithin radius of a point.sense_unknown_algae(point): Returns sorted list of(distance, Algae)tuples for algae with unknown poison status.sense_scraps_in_radius(point, radius): Returns list ofScrapwithin radius of a point.sense_objects(): Returns a dict containing lists ofscraps,banks, andenergypads.sense_walls(): Returns list of all visible walls (list[Point]).sense_walls_in_radius(point, radius): Returns list of walls within radius of a point.
Example
Pathing & Checks
next_point(pos, direction): Returns the nextPointin direction, orNoneif out of bounds.next_point_speed(pos, direction, step): Returns nextPointfor speed move (step 1 or 2), orNoneif invalid.run_bfs(start, end): Returns a list of points representing the shortest path, or empty list if no path.can_move(direction): ReturnsTrueif moving in detail direction is within map bounds.shortest_path(target): Returns Manhattan distance to target (int).check_blocked_point(point): ReturnsTrueif point is blocked by wall, enemy, or own bot.check_blocked_direction(direction): ReturnsTrueif moving in direction would result in a blocked position.can_defend(): ReturnsTrueif bot hasSHIELDability.can_spawn(abilities): ReturnsTrueif you have enough scraps and bot limit is not reached.
Example
Nearest Object Helpers
get_nearest_bank(): Returns the nearestBank.get_energy_pads(): Returns list of allEnergyPads.get_nearest_energy_pad(): Returns the nearestEnergyPad.get_nearest_scrap(): Returns the nearestScrap.get_nearest_algae(): Returns the nearestAlgae.get_nearest_enemy(): Returns the nearest enemyBot.
Example
Collision Avoidance
move_target(bot_pos, target_pos): Returns the bestDirectionto move towards target, avoiding obstacles. ReturnsNoneif no path.move_target_speed(bot_pos, target_pos): Returns a tuple(Direction, steps)for speed-boosted movement.stepsis 1 or 2.