hisss.BattleSnakeConfig#
- class hisss.BattleSnakeConfig(num_actions=4, num_players=2, w=5, h=5, ec=<factory>, all_actions_legal=False, max_snake_health=None, min_food=1, food_spawn_chance=15, init_turns_played=0, init_snakes_alive=None, init_snake_pos=None, init_food_pos=None, init_snake_health=None, init_snake_len=None, reward_cfg=<factory>, wrapped=False, royale=False, constrictor=False, shrink_n_turns=25, hazard_damage=14, init_hazards=None, view_radius=None)[source]#
Bases:
objectConfiguration class for setting up a BattleSnake game environment.
This dataclass holds all the parameters needed to initialize a game, including board dimensions, food spawn rates, snake initialization, game modes, and encoding/reward strategies for reinforcement learning environments.
- __init__(num_actions=4, num_players=2, w=5, h=5, ec=<factory>, all_actions_legal=False, max_snake_health=None, min_food=1, food_spawn_chance=15, init_turns_played=0, init_snakes_alive=None, init_snake_pos=None, init_food_pos=None, init_snake_health=None, init_snake_len=None, reward_cfg=<factory>, wrapped=False, royale=False, constrictor=False, shrink_n_turns=25, hazard_damage=14, init_hazards=None, view_radius=None)#
Methods
__init__([num_actions, num_players, w, h, ...])Attributes
If True, ignores collision/bounds checking for legal action generation.
If True, enables "Constrictor" mode where snakes grow infinitely and leave a permanent trail.
Probability (out of 100) of food spawning on a given turn.
Height of the game board.
Amount of health lost per turn when a snake is inside a hazard zone.
Fixed starting positions for food.
Initial coordinates of hazard tiles.
Starting health for each snake.
Starting length for each snake.
Fixed starting positions for snakes.
Initial alive status for each snake.
Starting turn number for the game state.
Maximum health capacity for each snake.
Minimum amount of food to keep on the board at all times.
UP, DOWN, LEFT, RIGHT).
Total number of snakes in the game.
If True, enables "Royale" mode with a shrinking hazard zone.
Number of turns between hazard zone shrink events in Royale mode.
Radius of visibility for restricted modes.
Width of the game board.
If True, enables "Wrapped" mode where snakes can move through board edges.
Configuration for how the game state is encoded into neural network inputs.
Configuration determining how rewards are assigned to snakes.
- all_actions_legal: bool = False#
If True, ignores collision/bounds checking for legal action generation.
- constrictor: bool = False#
If True, enables “Constrictor” mode where snakes grow infinitely and leave a permanent trail.
- ec: BattleSnakeEncodingConfig#
Configuration for how the game state is encoded into neural network inputs.
- food_spawn_chance: int = 15#
Probability (out of 100) of food spawning on a given turn.
- h: int = 5#
Height of the game board.
- hazard_damage: int = 14#
Amount of health lost per turn when a snake is inside a hazard zone.
- init_food_pos: list[list[int]] | None = None#
Fixed starting positions for food.
Nonespawns food randomly;[]spawns no food.
- init_hazards: list[list[int]] | None = None#
Initial coordinates of hazard tiles.
- init_snake_health: list[int] | None = None#
Starting health for each snake.
- init_snake_len: list[int] | None = None#
Starting length for each snake.
- init_snake_pos: dict[int, list[list[int]]] | None = None#
Fixed starting positions for snakes.
Noneimplies random spawning.
- init_snakes_alive: list[bool] | None = None#
Initial alive status for each snake.
Noneimplies all snakes are alive.
- init_turns_played: int = 0#
Starting turn number for the game state.
- max_snake_health: list[int] | None = None#
Maximum health capacity for each snake.
- min_food: int = 1#
Minimum amount of food to keep on the board at all times.
- num_actions: int = 4#
UP, DOWN, LEFT, RIGHT).
- Type:
Number of possible actions (default is 4
- num_players: int = 2#
Total number of snakes in the game.
- reward_cfg: BattleSnakeRewardConfig#
Configuration determining how rewards are assigned to snakes.
- royale: bool = False#
If True, enables “Royale” mode with a shrinking hazard zone.
- shrink_n_turns: int = 25#
Number of turns between hazard zone shrink events in Royale mode.
- view_radius: int | None = None#
Radius of visibility for restricted modes.
Noneimplies full board visibility.
- w: int = 5#
Width of the game board.
- wrapped: bool = False#
If True, enables “Wrapped” mode where snakes can move through board edges.