Snek v0.2.0 Snek.Ruleset behaviour View Source
A behaviour module for implementing variations of game rules.
Implementations define how a game plays out from start to finish, by dynamically specifying:
Link to this section Summary
Types
Valid moves for a snake to play.
Callbacks
Decide whether the game is over at this board position.
Decide the initial board position for a new game.
Apply moves and decide the next turn's board position.
Link to this section Types
Specs
valid_move() :: :north | :south | :east | :west
Valid moves for a snake to play.
Link to this section Callbacks
Specs
done?(board :: Snek.Board.t()) :: boolean()
Decide whether the game is over at this board position.
Specs
init( board_size :: Snek.Board.Size.t(), snake_ids :: MapSet.t(Snek.Board.Snake.id()) ) :: {:ok, Snek.Board.t()} | {:error, atom()}
Decide the initial board position for a new game.
Specs
next( board :: Snek.Board.t(), snake_moves :: [{Snek.Board.Snake.id(), valid_move()}], apple_spawn_chance :: float() ) :: Snek.Board.t()
Apply moves and decide the next turn's board position.