actions

Actions to be dispatched.

actions
Static Members
moveToken(rowIndex, colIndex)
updateScores()
resetGame(boardSize)

actionTypes

Type of actions to be dispatched.

actionTypes
Static Members
TOKEN_MOVED
SCORES_UPDATED
GAME_RESET

CellComp

Component that renders the value of a Cell.

new CellComp(props: object)

Extends Component

Parameters
props (object)
Name Description
props.style string CSS style.
props.onClick function Function to be triggered when component is clicked.
props.value number Value of Cell .

GameComp

Functional Component that renders a Game.

GameComp
Parameters
props (object)
Name Description
props.reset function Function to reset a Game .
props.board array 2 dimensional array of numbers representing the values of Cells in a Board .

GameEndComp

Functional Component that renders an overlay when a Game ends.

GameEndComp
Parameters
props (object)
Name Description
props.style string CSS style.
props.message string Message to be displayed in the overlay.

ScoreComp

Functional Component that renders the score of a Player.

ScoreComp
Parameters
props (object)
Name Description
props.score number Score of a Player .
props.name string Name to identify the Player .

WildCardComp

Functional Component that renders the Token in a Game.

WildCardComp
Parameters
props (object)
Name Description
props.style string CSS style.

CellCont

Container to connect a CellComp.

CellCont
Parameters
props (object)
Name Description
props.rowIndex number Row index of the Cell in a Board .
props.colIndex number Column index of the Cell in a Board .
props.value number Value of the Cell .

GameCont

Container to connect a GameComp.

GameCont
Parameters
props (object)
Name Description
props.boardSize number Size of a Board .

GameEndCont

Container to connect a GameEndComp.

GameEndCont

ScoreCont

Container to connect a ScoreComp.

ScoreCont
Parameters
props (object)
Name Description
props.playerName number Flag to identify a Player . See flags.TURNS .

WildCardCont

Container to connect a WildCardComp.

WildCardCont

LocalStorageManager

Class to save and retrieve the state of the application in local storage. It is based on this code.

new LocalStorageManager()
Instance Members
getGameState()
setGameState(gameState)
clearGameState()

Agent

Class representing an agent. An agent is a Player that plays the game following a certain criteria. It is considered a type of AI.

new Agent()

Extends Player

Instance Members
getMaxValuePosition(token, boardMatrix)
getMaxGainValuePosition(token, boardMatrix)
getBestAverageValuePosition(token, boardMatrix)

Board

Class representing a board. A board has a matrix of Cells.

new Board(boardSize: number, matrix: array?)
Parameters
boardSize (number)
matrix (array?) 2 dimensional array of numbers. If this parameter is given, boardSize is ignored.
Instance Members
updateFromMatrix(matrix)
updateFromVector(vector)
updateFromScratch(boardSize)
isCellSelectable(rowIndex, colIndex)
updateCellsByToken(token)
getValueInCellByToken(token)
canPlayerMakeMove(player, token)
findTokenPosition()
serialize()
asMatrix()

Cell

Class representing a cell. A cell is a positioned element in the Board that contains a value.

new Cell(value: number, rowIndex: number, colIndex: number)
Parameters
value (number)
rowIndex (number)
colIndex (number)
Instance Members
updateValue(value)
isSelectable()
updateFromObject(cell)

flags

Flags used in the logic's game.

flags
Static Members
GAME_STATUSES
TURNS
PLAYER_DIRECTIONS
GAME_CONTINUITY

Game

Class representing a game. A game is made of a Board a Token and 2 Players, one of them is an Agent.

new Game(boardSize: number)
Parameters
boardSize (number) Defines a square Board .
Instance Members
updateFromScratch(boardSize)
moveToken(rowIndex, colIndex)
updateLastValueInCellWhereTokenIs()
updateStatus(status)
updateCellsWhereTokenIs()
updateCurrentPlayerScore()
passToken()
updateContinuity()
getCurrentPlayer()
getNextPlayer()
serialize()
updateFromObject(game)

Player

Class representing a player. A player has a direction of playing and a score.

new Player()
Instance Members
incrementScore(value)
serialize()
toString()
updateFromObject(player)

Token

Class representing a token. A token is the element that moves in the Board to select a Cell.

new Token(boardSize: number)
Parameters
boardSize (number) The size of the Board .
Instance Members
moveTo(rowIndex, colIndex)
set(rowIndex, colIndex)
serialize()
toString()
updateFromObject(token)

utils

Utility functions for the logic's game.

utils
Static Members
rotateClockwise(matrix)
rotateCounterClockwise(matrix)
rotateIndicesClockwise(rowIndex, colIndex, size)
rotateIndicesCounterClockwise(rowIndex, colIndex, size)
getGainsMatrix(tokenColIndex, gameMatrix)
getBestGain(tokenRowIndex, tokenColIndex, gainsMatrix, boardMatrix)
randomInteger(min, max)
updateObjectFromJsonString(object, jsonString)
updateObjectFromLiteral(object, literal)
vectorToMatrix(vector)

reduce

Update the state of the game based on the received actions

reduce
Parameters
state (object = initialState) State of the application.
action (object) Action with relevant data to update the state of the application.