Represents the game board.
More...
Represents the game board.
Definition at line 12 of file Board.cs.
◆ Board()
Board |
( |
int |
rows = 7 , |
|
|
int |
cols = 7 , |
|
|
int |
piecesInSequence = 4 , |
|
|
int |
roundPieces = 10 , |
|
|
int |
squarePieces = 11 |
|
) |
| |
|
inline |
Creates a new board.
- Parameters
-
rows | Number of rows. |
cols | Number of columns. |
piecesInSequence | Number of required pieces in a row for player to win. |
roundPieces | Initial number of round pieces per player. |
squarePieces | Initial number of square pieces per player. |
Definition at line 127 of file Board.cs.
◆ CheckWinner()
Check if there is a winner.
- Parameters
-
solution | Optional parameter where solution will be placed if there is a winner. |
- Returns
- The Winner of the current game, if any.
Definition at line 418 of file Board.cs.
◆ Copy()
Returns a copy of this board which can be freely modified by the AI in a different thread.
- Returns
- A copy of this board.
Definition at line 471 of file Board.cs.
◆ DoMove()
int DoMove |
( |
PShape |
shape, |
|
|
int |
col |
|
) |
| |
|
inline |
Make a move, return row
- Parameters
-
shape | Shape of piece used in move (color is obtained from Board.Turn). |
col | Column where to drop piece. |
- Returns
- Row where piece was placed or -1 if move is invalid.
Definition at line 305 of file Board.cs.
◆ IsColumnFull()
bool IsColumnFull |
( |
int |
col | ) |
|
Is the specified column full?
- Parameters
-
col | The column to check if it's full. |
- Returns
true
if the column is full, false
otherwise.
◆ PieceCount()
Get number of remaining pieces with the given color and shape.
- Parameters
-
color | Pieces color. |
shape | Pieces shape. |
- Returns
- Number of remaining pieces with the given color and shape.
◆ UndoMove()
Undo last move.
- Returns
- The Move that was undone.
Definition at line 374 of file Board.cs.
◆ cols
Number of columns in the board.
Definition at line 53 of file Board.cs.
◆ piecesInSequence
readonly int piecesInSequence |
How many pieces in sequence to find a winner.
Definition at line 56 of file Board.cs.
◆ roundPieces
Initial number of round pieces for each player.
Definition at line 59 of file Board.cs.
◆ rows
Number of rows in the board.
Definition at line 50 of file Board.cs.
◆ squarePieces
readonly int squarePieces |
Initial number of square pieces for each player.
Definition at line 62 of file Board.cs.
◆ winCorridors
readonly IEnumerable<IEnumerable<Pos> > winCorridors |
Array of win corridors, which can be used for building an heuristic.
Definition at line 67 of file Board.cs.
◆ 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
-
row | Board row to access. |
col | Board column to access. |
- Returns
- The piece in the specified board position, or
null
if no piece is in the given position.
- Exceptions
-
System.IndexOutOfRangeException | Thrown when the given position is invalid (outside the board). |
Definition at line 28 of file Board.cs.
◆ Turn
Who's turn is it?
The color of the player who's currently playing.
Definition at line 47 of file Board.cs.
The documentation for this class was generated from the following file: