puissance4

Types

Board = array[length, Column]
Board data structure
Column = object
  free: uint
  content: array[length, string]
Column data structure

Lets

p1 = "\e[31mO\e[0m"
Player 1's icon (red)
p2 = "\e[36mO\e[0m"
Player 2's icon (blue)

Consts

length = 7
column length

Procs

proc add(column: uint; player: string; board: var Board): bool {....raises: [],
    tags: [].}
add player to the column if possible
proc checkWinner(board: Board; round: uint): bool {....raises: [IOError,
    ValueError, RegexInternalError, InvalidUnicodeError, KeyError, SyntaxError,
    StudyError], tags: [ExecIOEffect, WriteIOEffect].}
check for winner (horizontal, vertical, diagonal)
proc getCol(p: string): uint {....raises: [IOError],
                               tags: [ReadIOEffect, WriteIOEffect].}
ask user for a column between 1 and 7
proc initBoard(): Board {....raises: [], tags: [].}
set all the case of the board to a '.'
proc show(b: Board) {....raises: [IOError], tags: [ExecIOEffect, WriteIOEffect].}
show the formatted board to the screen
proc to_string(b: Board): string {....raises: [], tags: [].}
convert the board to a one line string