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: object

Configuration 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

all_actions_legal

If True, ignores collision/bounds checking for legal action generation.

constrictor

If True, enables "Constrictor" mode where snakes grow infinitely and leave a permanent trail.

food_spawn_chance

Probability (out of 100) of food spawning on a given turn.

h

Height of the game board.

hazard_damage

Amount of health lost per turn when a snake is inside a hazard zone.

init_food_pos

Fixed starting positions for food.

init_hazards

Initial coordinates of hazard tiles.

init_snake_health

Starting health for each snake.

init_snake_len

Starting length for each snake.

init_snake_pos

Fixed starting positions for snakes.

init_snakes_alive

Initial alive status for each snake.

init_turns_played

Starting turn number for the game state.

max_snake_health

Maximum health capacity for each snake.

min_food

Minimum amount of food to keep on the board at all times.

num_actions

UP, DOWN, LEFT, RIGHT).

num_players

Total number of snakes in the game.

royale

If True, enables "Royale" mode with a shrinking hazard zone.

shrink_n_turns

Number of turns between hazard zone shrink events in Royale mode.

view_radius

Radius of visibility for restricted modes.

w

Width of the game board.

wrapped

If True, enables "Wrapped" mode where snakes can move through board edges.

ec

Configuration for how the game state is encoded into neural network inputs.

reward_cfg

Configuration determining how rewards are assigned to snakes.

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. None spawns 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. None implies random spawning.

init_snakes_alive: list[bool] | None = None#

Initial alive status for each snake. None implies 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. None implies 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.