Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TTT<CellType>

Type parameters

  • CellType

Hierarchy

Index

Properties

Private _winner

_winner: PlayerOrTie = undefined

board

board: Array<Array<CellType>>

Holds the state of the game board as a two dimensional array each element of the inner array is a SubBoard

Protected maxMoves

maxMoves: number

Holds the maximum number of moves before the board is full this is here to avoid recalculating it every time its needed

Protected moves

moves: number

Counter of moves that have been played so far

nextBoard

nextBoard: Coord

Holds the coordinates of the board that should be played next If the last move sends you to a finished board, then this will be null and you may choose any.

Protected size

size: number

Indicates the size of Ultimate TTT we're dealing with typically this will be 3 for a 3x3 board.

Accessors

winner

  • get winner(): 0 | 1 | -1
  • set winner(value: PlayerOrTie): void
  • Game winner, will be null if no one has won yet, -1 in a tie, 0 if player 1 won or 1 if player 2 won.

    Returns 0 | 1 | -1

  • Game winner, will be null if no one has won yet, -1 in a tie, 0 if player 1 won or 1 if player 2 won.

    Parameters

    Returns void

Methods

copy

  • copy(): TTT<CellType>
  • Return a new UTTT board as a copy of this one

    Returns TTT<CellType>

    Copy of the current game

getMoves

  • getMoves(): number

getResult

  • getResult(): number
  • Returns the winner for the game, throws an exception if the game hasn't finished yet.

    Returns number

    -1 for a tie, 0 you won, 1 opponent won

isFinished

  • isFinished(): boolean
  • Returns true if the game is over

    Returns boolean

prettyPrint

  • prettyPrint(): string
  • Returns a string with the board formatted for display including new lines.

    Returns string

    Printable version of the game board

Generated using TypeDoc