battlesnake/gamestate
Types
A Battlesnake on the board.
pub type Battlesnake {
Battlesnake(
id: String,
name: String,
health: Int,
body: List(Position),
latency: String,
head: Position,
length: Int,
shout: String,
squad: String,
customizations: Customizations,
)
}
Constructors
-
Battlesnake( id: String, name: String, health: Int, body: List(Position), latency: String, head: Position, length: Int, shout: String, squad: String, customizations: Customizations, )
Arguments
-
id
Unique identifier for this Battlesnake in the context of the current game.
-
name
Name given to this Battlesnake by its author.
-
health
Health value of this Battlesnake, between 0 and 100 inclusively.
-
body
List of coordinates representing this Battlesnake’s location on the game board. This list is ordered from head to tail.
-
latency
The previous response time of this Battlesnake, in milliseconds. If the Battlesnake timed out and failed to respond, the game timeout will be returned (
game.timeout
). -
head
Coordinates for this Battlesnake’s head. Equivalent to the first element of the body list.
-
length
Length of this Battlesnake from head to tail. Equivalent to the length of the body list.
-
shout
Message shouted by this Battlesnake on the previous turn.
-
squad
The squad that the Battlesnake belongs to. Used to identify squad members in Squad Mode games.
-
customizations
The collection of customizations that control how this Battlesnake is displayed.
-
pub type Board {
Board(
height: Int,
width: Int,
food: List(Position),
hazards: List(Position),
snakes: List(Battlesnake),
)
}
Constructors
-
Board( height: Int, width: Int, food: List(Position), hazards: List(Position), snakes: List(Battlesnake), )
Arguments
-
height
The number of rows in the y-axis of the game board.
-
width
The number of columns in the x-axis of the game board.
-
food
List of coordinates representing food locations on the game board.
-
hazards
List of coordinates representing hazardous locations on the game board.
-
snakes
Array of Battlesnake Objects representing all Battlesnakes remaining on the game board (including yourself if you haven’t been eliminated).
-
The collection of customizations that control how this Battlesnake is displayed.
pub type Customizations {
Customizations(color: String, head: String, tail: String)
}
Constructors
-
Customizations(color: String, head: String, tail: String)
Holds general information about the current game.
pub type Game {
Game(
id: String,
ruleset: Ruleset,
map: String,
timeout: Int,
source: String,
)
}
Constructors
-
Game( id: String, ruleset: Ruleset, map: String, timeout: Int, source: String, )
Arguments
-
id
A unique identifier for this game.
-
ruleset
Information about the ruleset being used to run this game.
-
map
The name of the map being played on.
-
timeout
How much time your snake has to respond to requests for this game in milliseconds.
-
source
The source of this game. One of:
- “tournament”
- “league” (for League Arenas)
- “arena” (for all other Arenas)
- “challenge”
- “custom” (for all other games sources)
The values for this field may change in the near future.
-
This gets sent by the server every time a game starts, ends, or a turn is requested.
pub type GameState {
GameState(
game: Game,
turn: Int,
board: Board,
you: Battlesnake,
)
}
Constructors
-
GameState(game: Game, turn: Int, board: Board, you: Battlesnake)
Arguments
-
turn
Turn number (starting at 0 for new games).
-
A position on the game board. (0,0) is in the bottom left.
pub type Position {
Position(x: Int, y: Int)
}
Constructors
-
Position(x: Int, y: Int)
Ruleset settings for the Royale gamemode.
pub type RoyaleSettings {
RoyaleSettings(shrink_every_n_turns: Int)
}
Constructors
-
RoyaleSettings(shrink_every_n_turns: Int)
Arguments
-
shrink_every_n_turns
In Royale mode, the number of turns between generating new hazards (shrinking the safe board space).
-
pub type Ruleset {
Ruleset(
name: String,
version: String,
settings: RulesetSettings,
)
}
Constructors
-
Ruleset(name: String, version: String, settings: RulesetSettings)
Arguments
-
name
Name of the ruleset being used to run this game.
-
version
The release version of the Rules module used in this game.
-
settings
A collection of specific settings being used by the current game that control how the rules are applied.
-
A collection of specific settings being used by the current game that control how the rules are applied.
pub type RulesetSettings {
RulesetSettings(
food_spawn_chance: Int,
minimum_food: Int,
hazard_damage_per_turn: Int,
royale: RoyaleSettings,
squad: SquadSettings,
)
}
Constructors
-
RulesetSettings( food_spawn_chance: Int, minimum_food: Int, hazard_damage_per_turn: Int, royale: RoyaleSettings, squad: SquadSettings, )
Arguments
-
food_spawn_chance
Percentage chance of spawning a new food every round.
-
minimum_food
Minimum food to keep on the board every turn.
-
hazard_damage_per_turn
Health damage a snake will take when ending its turn in a hazard. This stacks on top of the regular 1 damage a snake takes per turn.
-
royale
Ruleset settings for the Royale gamemode.
-
squad
Ruleset settings for the Squad gamemode.
-
Ruleset settings for the Squad gamemode.
pub type SquadSettings {
SquadSettings(
allow_body_collisions: Bool,
shared_elimination: Bool,
shared_health: Bool,
shared_length: Bool,
)
}
Constructors
-
SquadSettings( allow_body_collisions: Bool, shared_elimination: Bool, shared_health: Bool, shared_length: Bool, )
Arguments
-
allow_body_collisions
In Squad mode, allow members of the same squad to move over each other without dying.
-
shared_elimination
In Squad mode, all squad members are eliminated when one is eliminated.
-
shared_health
In Squad mode, all squad members share health.
-
shared_length
In Squad mode, all squad members share length.
-