View Source Hanoi.TowerState (Towers of Hanoi v1.0.0)
Private API: GenServer providing the business logic for the game. Created by TowerGame along with ETS table to hold state.
Summary
Functions
Returns a specification to start this module under a supervisor.
Function returning the current state of the hanoi board
Debug function returning current state of hanoi board in a textual representation.
Returns the current state of the game, board, moves etc.
Function that for a board with all stones on left pile will move them in a legal way (no big stone on small stone) to the right hand pile
Function returning the number of moves that have been played.
Function that returns the number of stones on the board.
Handles events
Completes work of init asynchronously
Sets up basic state. Most of work completed in continuation asynchronously.
Funtion returns true if game is complete That is all stones in correct order on right hand pile
Funtion that moves a stone between piles. Will error if the stone is bigger than the one at the top of the pile. Increments moves taken.
Restarts a game with a new number of stones on the board. Resets move count
Call this function to start up the module. Name and Stones must be provided.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec get_board_state(name :: atom()) :: Hanoi.Board.t()
Function returning the current state of the hanoi board
Debug function returning current state of hanoi board in a textual representation.
Returns the current state of the game, board, moves etc.
Function that for a board with all stones on left pile will move them in a legal way (no big stone on small stone) to the right hand pile
@spec get_number_moves(name :: atom()) :: non_neg_integer()
Function returning the number of moves that have been played.
@spec get_number_stones(name :: atom()) :: non_neg_integer()
Function that returns the number of stones on the board.
Handles events
Completes work of init asynchronously
Sets up basic state. Most of work completed in continuation asynchronously.
Funtion returns true if game is complete That is all stones in correct order on right hand pile
Funtion that moves a stone between piles. Will error if the stone is bigger than the one at the top of the pile. Increments moves taken.
@spec reset_game(name :: atom(), new_stones :: pos_integer()) :: :ok
Restarts a game with a new number of stones on the board. Resets move count
Call this function to start up the module. Name and Stones must be provided.