TTT v0.2.0 TTT.Core.Logic View Source

This module represents and controlls the flow of the game play.

Link to this section Summary

Functions

If the game ends in a draw, it’ll display a message with the result

Link to this section Functions

Link to this function generate_naive_move(game, starting_move) View Source

## Parameters

- game: Struct of the game.
- starting_move: Interger that represents the first move the navie computer player will take.

## Example: starting_move = 1 => {0, 0} Recursive function calls with incremented starting_move if cell is taken. Returns the move in coordinate if move is available.

Link to this function generate_random_move(game) View Source

## Parameters

- game: Struct of the game.

Recursive function calls with randomly generated move if cell is taken. Returns the move in coordinate if move is available.

If the game ends in a draw, it’ll display a message with the result.

Link to this function switch_turn(game, last_player) View Source

## Parameters

- game: Struct of the game.
- last_player: Struct of the last player played.

Returns the player who plays next.

Link to this function update_visual(board, game) View Source

## Parameters

- board: Map of the board.
- game: Struct of the game.

Convert each player’s moves into a list and calls render_board, passing in a map of the list with the players’ tokens to generate new UI to reflect the new board.