TTT v0.2.0 TTT.Core.Game View Source

This module represents the core rules of the game.

Link to this section Summary

Link to this section Functions

Link to this function cell_taken?(turns, cell) View Source

## Parameters

- turns: Mapset of each player's moves.
- cell: Coordinate of the current move made by a player.

Returns boolean of whether the cell already exsit in turns.

## Parameters

- {col, row}: Tuple of coordinate that represents a play's move.

Returns boolean of whether each component of the coordinate is in bound.

Link to this function new_game(arg, token_length) View Source

## Parameters

- players: Tuple of player structs which contains player's name, token and type.
- token_length: Integer of the length of the longer token.

Returns a game struct.

Link to this function play_turn(state, player, cell) View Source

## Parameters

- state: Struct of the game.
- player: Struct of player in turn.
- cell: Tuple of coordinates of the player's move.

Returns the updated game struct(state) after checking each conditions. If no errors, player’s move coordinate will be recorded in the game struct(state) and last player updated.

## Parameters

- %Game: Struct of the game.

Returns the progress of the game.