hisss.BattleSnakeEncodingConfig#
- class hisss.BattleSnakeEncodingConfig(*, include_current_food, include_next_food, include_board, include_number_of_turns, compress_enemies, include_snake_body_as_one_hot, include_snake_body, include_snake_head, include_snake_tail, include_snake_health, include_snake_length, include_distance_map, flatten, centered, include_area_control, include_food_distance, include_hazards, include_tail_distance, include_num_food_on_board=False, temperature_input=False, single_temperature_input=True, fixed_food_spawn_chance=-1.0, include_view_mask=False)[source]#
Bases:
objectConfiguration for encoding a BattleSnake game state into a NumPy tensor.
This dataclass defines which specific spatial layers and global features should be included when translating the JSON-like game state into a numerical tensor representation, typically used as an observation space for reinforcement learning agents or neural networks.
- __init__(*, include_current_food, include_next_food, include_board, include_number_of_turns, compress_enemies, include_snake_body_as_one_hot, include_snake_body, include_snake_head, include_snake_tail, include_snake_health, include_snake_length, include_distance_map, flatten, centered, include_area_control, include_food_distance, include_hazards, include_tail_distance, include_num_food_on_board=False, temperature_input=False, single_temperature_input=True, fixed_food_spawn_chance=-1.0, include_view_mask=False)#
Methods
__init__(*, include_current_food, ...[, ...])Attributes
Sets a fixed probability for food spawning.
Includes a global feature representing the total number of food items currently spawned on the board.
Includes a mask layer representing the limited field of view of the snake, useful for partially observable training environments.
If True, represents the temperature input as a single global scalar value.
Includes an environment temperature input feature, often used for modulating exploration or custom game modes.
Includes a spatial layer representing the current locations of food on the board.
Includes a layer for predicted or upcoming food spawns, if supported by the environment.
Includes a base layer representing the playable board area (useful for identifying boundaries).
Includes the current turn number of the game as a feature.
If True, all enemy snakes share the same encoding layers.
Encodes snake body segments using a one-hot representation to differentiate the order of body parts.
Includes a standard spatial layer showing the occupied positions of all snake bodies.
Includes a specific spatial layer indicating the positions of snake heads.
Includes a specific spatial layer indicating the positions of snake tails.
Includes a feature or layer representing the current health (starvation countdown) of the snakes.
Includes a feature or layer representing the current length of the snakes.
Includes a spatial distance map (e.g., Manhattan distance from the ego snake's head to other tiles).
If True, flattens the multi-dimensional spatial tensor into a 1D array before returning.
Centers the spatial observation tensor around the ego snake's head (egocentric view) rather than using an absolute board (allocentric view).
Includes a layer detailing area control metrics, such as a Voronoi partition showing which snake is closest to which tiles.
Includes a feature or gradient layer representing the distance to the nearest food item.
Includes a spatial layer mapping hazard zones (e.g., the shrinking hazard sauce in Royale mode).
Includes a feature representing the distance from the ego snake's head to its own tail.
- centered: bool#
Centers the spatial observation tensor around the ego snake’s head (egocentric view) rather than using an absolute board (allocentric view).
- Type:
bool
- compress_enemies: bool#
If True, all enemy snakes share the same encoding layers. If False, enemies are separated into individual layers.
- Type:
bool
- fixed_food_spawn_chance: float = -1.0#
Sets a fixed probability for food spawning. A value of -1 indicates that the default game rules for food spawn chance should be used.
- Type:
float
- flatten: bool#
If True, flattens the multi-dimensional spatial tensor into a 1D array before returning.
- Type:
bool
- include_area_control: bool#
Includes a layer detailing area control metrics, such as a Voronoi partition showing which snake is closest to which tiles.
- Type:
bool
- include_board: bool#
Includes a base layer representing the playable board area (useful for identifying boundaries).
- Type:
bool
- include_current_food: bool#
Includes a spatial layer representing the current locations of food on the board.
- Type:
bool
- include_distance_map: bool#
Includes a spatial distance map (e.g., Manhattan distance from the ego snake’s head to other tiles).
- Type:
bool
- include_food_distance: bool#
Includes a feature or gradient layer representing the distance to the nearest food item.
- Type:
bool
- include_hazards: bool#
Includes a spatial layer mapping hazard zones (e.g., the shrinking hazard sauce in Royale mode).
- Type:
bool
- include_next_food: bool#
Includes a layer for predicted or upcoming food spawns, if supported by the environment.
- Type:
bool
- include_num_food_on_board: bool = False#
Includes a global feature representing the total number of food items currently spawned on the board.
- Type:
bool
- include_number_of_turns: bool#
Includes the current turn number of the game as a feature.
- Type:
bool
- include_snake_body: bool#
Includes a standard spatial layer showing the occupied positions of all snake bodies.
- Type:
bool
- include_snake_body_as_one_hot: bool#
Encodes snake body segments using a one-hot representation to differentiate the order of body parts.
- Type:
bool
- include_snake_head: bool#
Includes a specific spatial layer indicating the positions of snake heads.
- Type:
bool
- include_snake_health: bool#
Includes a feature or layer representing the current health (starvation countdown) of the snakes.
- Type:
bool
- include_snake_length: bool#
Includes a feature or layer representing the current length of the snakes.
- Type:
bool
- include_snake_tail: bool#
Includes a specific spatial layer indicating the positions of snake tails.
- Type:
bool
- include_tail_distance: bool#
Includes a feature representing the distance from the ego snake’s head to its own tail.
- Type:
bool
- include_view_mask: bool = False#
Includes a mask layer representing the limited field of view of the snake, useful for partially observable training environments.
- Type:
bool
- single_temperature_input: bool = True#
If True, represents the temperature input as a single global scalar value.
- Type:
bool
- temperature_input: bool = False#
Includes an environment temperature input feature, often used for modulating exploration or custom game modes.
- Type:
bool