ColorShapeLinks AI
An AI competition for the IEEE Conference on Games 2021
Board Class Reference

Represents the game board. More...

+ Collaboration diagram for Board:

Public Member Functions

 Board (int rows=6, int cols=7, int piecesInSequence=4, int roundPieces=10, int squarePieces=11)
 Creates a new board. More...
 
int DoMove (PShape shape, int col)
 Make a move, return row More...
 
Move UndoMove ()
 Undo last move. More...
 
Winner CheckWinner (Pos[] solution=null)
 Check if there is a winner. More...
 
Board Copy ()
 Returns a copy of this board which can be freely modified by the AI in a different thread. More...
 
int PieceCount (PColor color, PShape shape)
 Get number of remaining pieces with the given color and shape. More...
 
bool IsColumnFull (int col)
 Is the specified column full? More...
 

Public Attributes

readonly int rows
 Number of rows in the board. More...
 
readonly int cols
 Number of columns in the board. More...
 
readonly int piecesInSequence
 How many pieces in sequence to find a winner. More...
 
readonly int roundPieces
 Initial number of round pieces for each player. More...
 
readonly int squarePieces
 Initial number of square pieces for each player. More...
 
readonly IEnumerable< IEnumerable< Pos > > winCorridors
 Array of win corridors, which can be used for building an heuristic. More...
 

Properties

Piecethis[int row, int col] [get]
 Read-only indexer for allowing the board contents to be accessed by external code. More...
 
PColor Turn [get]
 Who's turn is it? More...
 

Detailed Description

Represents the game board.

Constructor & Destructor Documentation

◆ Board()

Board ( int  rows = 6,
int  cols = 7,
int  piecesInSequence = 4,
int  roundPieces = 10,
int  squarePieces = 11 
)
inline

Creates a new board.

Parameters
rowsNumber of rows.
colsNumber of columns.
piecesInSequenceNumber of required pieces in a row for player to win.
roundPiecesInitial number of round pieces per player.
squarePiecesInitial number of square pieces per player.

Member Function Documentation

◆ CheckWinner()

Winner CheckWinner ( Pos[]  solution = null)
inline

Check if there is a winner.

Parameters
solutionOptional parameter where solution will be placed if there is a winner.
Returns
The Winner of the current game, if any.

◆ Copy()

Board Copy ( )
inline

Returns a copy of this board which can be freely modified by the AI in a different thread.

Returns
A copy of this board.

◆ DoMove()

int DoMove ( PShape  shape,
int  col 
)
inline

Make a move, return row

Parameters
shapeShape of piece used in move (color is obtained from Turn).
colColumn where to drop piece.
Returns
Row where piece was placed or -1 if move is invalid.
Exceptions
InvalidOperationExceptionThrown when:
  • col is not a valid column.
  • Game is already over when this method is invoked.
  • There are no more pieces of the specified type available.

◆ IsColumnFull()

bool IsColumnFull ( int  col)

Is the specified column full?

Parameters
colThe column to check if it's full.
Returns
true if the column is full, false otherwise.

◆ PieceCount()

int PieceCount ( PColor  color,
PShape  shape 
)

Get number of remaining pieces with the given color and shape.

Parameters
colorPieces color.
shapePieces shape.
Returns
Number of remaining pieces with the given color and shape.

◆ UndoMove()

Move UndoMove ( )
inline

Undo last move.

Returns
The Move that was undone.

Member Data Documentation

◆ cols

readonly int cols

Number of columns in the board.

◆ piecesInSequence

readonly int piecesInSequence

How many pieces in sequence to find a winner.

◆ roundPieces

readonly int roundPieces

Initial number of round pieces for each player.

◆ rows

readonly int rows

Number of rows in the board.

◆ squarePieces

readonly int squarePieces

Initial number of square pieces for each player.

◆ winCorridors

readonly IEnumerable<IEnumerable<Pos> > winCorridors

Array of win corridors, which can be used for building an heuristic.

Property Documentation

◆ this[int row, int col]

Piece? this[int row, int col]
get

Read-only indexer for allowing the board contents to be accessed by external code.

Parameters
rowBoard row to access.
colBoard column to access.
Returns
The piece in the specified board position, or null if no piece is in the given position.
Exceptions
IndexOutOfRangeExceptionThrown when the given position is invalid (outside the board).

◆ Turn

PColor Turn
get

Who's turn is it?

The color of the player who's currently playing.


The documentation for this class was generated from the following file: