![]() |
ConnectX 3.0
ConnectX Game Suite
|
#include <board.hpp>
Public Member Functions | |
| Board (uint8_t rows=6, uint8_t cols=7, uint8_t num_players=2) | |
| uint8_t | get (uint8_t row, uint8_t col) const |
| void | set (uint8_t row, uint8_t col, uint8_t player_id) |
| bool | isColumnAvailable (uint8_t col) const |
| std::optional< uint8_t > | getNextRow (uint8_t col) const |
| bool | isFull () const |
| void | clear () |
| uint8_t | getRows () const |
| uint8_t | getCols () const |
| uint8_t | getNumPlayers () const |
| const std::vector< std::vector< uint8_t > > & | getData () const |
Represents the game board state Supports variable dimensions and number of players
| Board::Board | ( | uint8_t | rows = 6, |
| uint8_t | cols = 7, |
||
| uint8_t | num_players = 2 |
||
| ) |
Constructor
| rows | Number of rows (height) |
| cols | Number of columns (width) |
| num_players | Number of players (default 2) |
| void Board::clear | ( | ) |
Reset the board to empty state
| uint8_t Board::get | ( | uint8_t | row, |
| uint8_t | col | ||
| ) | const |
Get the value at a specific position
|
inline |
|
inline |
Get raw board data (for serialization/display)
| std::optional< uint8_t > Board::getNextRow | ( | uint8_t | col | ) | const |
Get the next available row in a column (for dropping piece)
|
inline |
|
inline |
| bool Board::isColumnAvailable | ( | uint8_t | col | ) | const |
Check if a column has space for a new piece
| bool Board::isFull | ( | ) | const |
Check if the board is completely full
| void Board::set | ( | uint8_t | row, |
| uint8_t | col, | ||
| uint8_t | player_id | ||
| ) |
Set the value at a specific position
| row | Row index (0-based) |
| col | Column index (0-based) |
| player_id | Player ID (1..N) |