ConnectX 3.0
ConnectX Game Suite
Loading...
Searching...
No Matches
Board Class Reference

#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
 

Detailed Description

Represents the game board state Supports variable dimensions and number of players

Constructor & Destructor Documentation

◆ Board()

Board::Board ( uint8_t  rows = 6,
uint8_t  cols = 7,
uint8_t  num_players = 2 
)

Constructor

Parameters
rowsNumber of rows (height)
colsNumber of columns (width)
num_playersNumber of players (default 2)

Member Function Documentation

◆ clear()

void Board::clear ( )

Reset the board to empty state

◆ get()

uint8_t Board::get ( uint8_t  row,
uint8_t  col 
) const

Get the value at a specific position

Returns
0 for empty, 1..N for player N

◆ getCols()

uint8_t Board::getCols ( ) const
inline

◆ getData()

const std::vector< std::vector< uint8_t > > & Board::getData ( ) const
inline

Get raw board data (for serialization/display)

◆ getNextRow()

std::optional< uint8_t > Board::getNextRow ( uint8_t  col) const

Get the next available row in a column (for dropping piece)

Returns
Row index or std::nullopt if column is full

◆ getNumPlayers()

uint8_t Board::getNumPlayers ( ) const
inline

◆ getRows()

uint8_t Board::getRows ( ) const
inline

◆ isColumnAvailable()

bool Board::isColumnAvailable ( uint8_t  col) const

Check if a column has space for a new piece

◆ isFull()

bool Board::isFull ( ) const

Check if the board is completely full

◆ set()

void Board::set ( uint8_t  row,
uint8_t  col,
uint8_t  player_id 
)

Set the value at a specific position

Parameters
rowRow index (0-based)
colColumn index (0-based)
player_idPlayer ID (1..N)

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