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

Configuration 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

fixed_food_spawn_chance

Sets a fixed probability for food spawning.

include_num_food_on_board

Includes a global feature representing the total number of food items currently spawned on the board.

include_view_mask

Includes a mask layer representing the limited field of view of the snake, useful for partially observable training environments.

single_temperature_input

If True, represents the temperature input as a single global scalar value.

temperature_input

Includes an environment temperature input feature, often used for modulating exploration or custom game modes.

include_current_food

Includes a spatial layer representing the current locations of food on the board.

include_next_food

Includes a layer for predicted or upcoming food spawns, if supported by the environment.

include_board

Includes a base layer representing the playable board area (useful for identifying boundaries).

include_number_of_turns

Includes the current turn number of the game as a feature.

compress_enemies

If True, all enemy snakes share the same encoding layers.

include_snake_body_as_one_hot

Encodes snake body segments using a one-hot representation to differentiate the order of body parts.

include_snake_body

Includes a standard spatial layer showing the occupied positions of all snake bodies.

include_snake_head

Includes a specific spatial layer indicating the positions of snake heads.

include_snake_tail

Includes a specific spatial layer indicating the positions of snake tails.

include_snake_health

Includes a feature or layer representing the current health (starvation countdown) of the snakes.

include_snake_length

Includes a feature or layer representing the current length of the snakes.

include_distance_map

Includes a spatial distance map (e.g., Manhattan distance from the ego snake's head to other tiles).

flatten

If True, flattens the multi-dimensional spatial tensor into a 1D array before returning.

centered

Centers the spatial observation tensor around the ego snake's head (egocentric view) rather than using an absolute board (allocentric view).

include_area_control

Includes a layer detailing area control metrics, such as a Voronoi partition showing which snake is closest to which tiles.

include_food_distance

Includes a feature or gradient layer representing the distance to the nearest food item.

include_hazards

Includes a spatial layer mapping hazard zones (e.g., the shrinking hazard sauce in Royale mode).

include_tail_distance

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