TTT v0.2.0 TTT.Console.Board View Source

A command line representation of a game board.

Link to this section Summary

Link to this section Functions

## Parameters

- left_pad, right_pad: String of empty space(s).

Returns a map which contains coordinates as keys and numbers (1 - 9) as values, representing available spots on the board.

Link to this function register_move(board, list, token) View Source
## Parameters

- board: Map that represents the current state of the board.
- list: List that contains coordinates that represent moves made by a player.
- token: String of player's token.

Returns a map with player's token as value for each coordinate that matches those in
the list.

## Examples

list = [{0, 1}, {1, 1}, {2, 1}]

%{
  {0, 0} => "1",
  {0, 1} => "X",
  {0, 2} => "7",
  {1, 0} => "2",
  {1, 1} => "X",
  {1, 2} => "8",
  {2, 0} => "3",
  {2, 1} => "X",
  {2, 2} => "9"
}
Link to this function render_board(board, moves, token_length) View Source

## Parameters

- board: Map that represents the current state of the board.
- moves: Map that contains a collection of players' moves and tokens.
- token_length: Integer that represents the lenght of the longest token.
It is use to make sure the row dividers are the same length as the rows.

Renders and draws the board in command line with tokens as values in their corresponding coordinates.

Link to this function show_board(board, token_length) View Source

## Parameters

- board: Map that represents the current state of the board.
- token_length: Integer that represents the lenght of the longer token.
It is use to make sure the row dividers scales according to the size of the tokens.

Draws a scaled board with it’s contents in command line.