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

#include <rules.hpp>

Public Member Functions

 GameRules (uint8_t connect_length=4)
 
bool checkWin (const Board &board, uint8_t player_id) const
 
bool checkDraw (const Board &board) const
 
bool isValidMove (const Board &board, uint8_t column) const
 
uint8_t getConnectLength () const
 

Detailed Description

Encapsulates game rules and win condition checking

Constructor & Destructor Documentation

◆ GameRules()

GameRules::GameRules ( uint8_t  connect_length = 4)
explicit

Constructor

Parameters
connect_lengthNumber of consecutive pieces needed to win (default 4)

Member Function Documentation

◆ checkDraw()

bool GameRules::checkDraw ( const Board board) const

Check if the game is a draw (board full, no winner)

◆ checkWin()

bool GameRules::checkWin ( const Board board,
uint8_t  player_id 
) const

Check if a specific player has won

Parameters
boardCurrent board state
player_idPlayer to check
Returns
true if player has won

◆ getConnectLength()

uint8_t GameRules::getConnectLength ( ) const
inline

◆ isValidMove()

bool GameRules::isValidMove ( const Board board,
uint8_t  column 
) const

Validate if a move is legal


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