BitBully 0.0.59-a2
Loading...
Searching...
No Matches
BitBully::Board Class Reference

Public Types

enum  Player { P_EMPTY = 0 , P_YELLOW = 1 , P_RED = 2 }
using TBitBoard = uint64_t
using TMovesCounter = int
using TBoardArray = std::array<std::array<int32_t, N_ROWS>, N_COLUMNS>
using TBoardArrayT = std::array<std::array<int32_t, N_COLUMNS>, N_ROWS>

Public Member Functions

Board playMoveOnCopy (const TBitBoard mv) const
Board copy () const
TBitBoard legalMovesMask () const
std::vector< int > legalMoves (bool nonLosing, bool orderMoves) const
auto popCountBoard () const
bool isLegalMove (int column) const
uint64_t uid () const
uint64_t hash () const
bool operator== (const Board &b) const
bool operator!= (const Board &b) const
TBitBoard findOddThreats (TBitBoard moves)
bool setBoard (const TBoardArray &board)
bool setBoard (const TBoardArrayT &board)
bool setBoard (const std::vector< int > &moveSequence)
bool play (int column)
bool play (const std::vector< int > &moveSequence)
bool play (const std::string &moveSequence)
bool setBoard (const std::string &moveSequence)
TBoardArray toArray () const
bool canWin () const
bool canWin (int column) const
bool hasWin () const
std::string toString () const
TMovesCounter movesLeft () const
TMovesCounter countTokens () const
Board mirror () const
MoveList sortMoves (TBitBoard moves) const
TBitBoard findThreats (TBitBoard moves)
TBitBoard generateNonLosingMoves () const
TBitBoard doubleThreat (const TBitBoard moves) const
int toHuffman () const
std::vector< BoardallPositions (const int upToNPly, bool exactlyN) const

Static Public Member Functions

static constexpr int popCountBoard (uint64_t x)
static uint64_t hash (uint64_t x)
static TBitBoard nextMove (TBitBoard allMoves)
static bool isValid (const TBoardArray &board)
static TBitBoard lsb (const TBitBoard x)
static std::pair< Board, std::vector< int > > randomBoard (const int nPly, const bool forbidDirectWin=true)

Static Public Attributes

static constexpr int N_COLUMNS = 7
static constexpr int N_ROWS = 6
static constexpr int COLUMN_BIT_OFFSET = 9
static constexpr size_t N_VALID_BOARD_VALUES = 3

Friends

class BoardTest

Detailed Description

Definition at line 100 of file Board.h.

Member Typedef Documentation

◆ TBitBoard

using BitBully::Board::TBitBoard = uint64_t

Definition at line 110 of file Board.h.

◆ TBoardArray

using BitBully::Board::TBoardArray = std::array<std::array<int32_t, N_ROWS>, N_COLUMNS>

Definition at line 112 of file Board.h.

◆ TBoardArrayT

using BitBully::Board::TBoardArrayT = std::array<std::array<int32_t, N_COLUMNS>, N_ROWS>

Definition at line 113 of file Board.h.

◆ TMovesCounter

using BitBully::Board::TMovesCounter = int

Definition at line 111 of file Board.h.

Member Enumeration Documentation

◆ Player

enum BitBully::Board::Player

Definition at line 108 of file Board.h.

Constructor & Destructor Documentation

◆ Board()

BitBully::Board::Board ( )

Definition at line 9 of file Board.cpp.

Member Function Documentation

◆ allPositions()

std::vector< Board > BitBully::Board::allPositions ( const int upToNPly,
bool exactlyN ) const
inlinenodiscard

Definition at line 301 of file Board.h.

◆ canWin() [1/2]

bool BitBully::Board::canWin ( ) const
nodiscard

Definition at line 396 of file Board.cpp.

◆ canWin() [2/2]

bool BitBully::Board::canWin ( int column) const
nodiscard

Definition at line 401 of file Board.cpp.

◆ copy()

Board BitBully::Board::copy ( ) const
inlinenodiscard

Definition at line 121 of file Board.h.

◆ countTokens()

TMovesCounter BitBully::Board::countTokens ( ) const
inlinenodiscard

Definition at line 212 of file Board.h.

◆ doubleThreat()

TBitBoard BitBully::Board::doubleThreat ( const TBitBoard moves) const
inlinenodiscard

Definition at line 243 of file Board.h.

◆ findOddThreats()

Board::TBitBoard BitBully::Board::findOddThreats ( TBitBoard moves)
nodiscard

Definition at line 333 of file Board.cpp.

◆ findThreats()

Board::TBitBoard BitBully::Board::findThreats ( TBitBoard moves)

Definition at line 302 of file Board.cpp.

◆ generateNonLosingMoves()

TBitBoard BitBully::Board::generateNonLosingMoves ( ) const
inlinenodiscard

Definition at line 227 of file Board.h.

◆ hash() [1/2]

uint64_t BitBully::Board::hash ( ) const
inlinenodiscard

Definition at line 159 of file Board.h.

◆ hash() [2/2]

uint64_t BitBully::Board::hash ( uint64_t x)
inlinestaticnodiscard

Definition at line 146 of file Board.h.

◆ hasWin()

bool BitBully::Board::hasWin ( ) const
nodiscard

Definition at line 245 of file Board.cpp.

◆ isLegalMove()

bool BitBully::Board::isLegalMove ( int column) const
nodiscard

Definition at line 161 of file Board.cpp.

◆ isValid()

bool BitBully::Board::isValid ( const TBoardArray & board)
staticnodiscard

Definition at line 88 of file Board.cpp.

◆ legalMoves()

std::vector< int > BitBully::Board::legalMoves ( bool nonLosing,
bool orderMoves ) const
nodiscard

Definition at line 436 of file Board.cpp.

◆ legalMovesMask()

Board::TBitBoard BitBully::Board::legalMovesMask ( ) const
nodiscard

Definition at line 407 of file Board.cpp.

◆ lsb()

TBitBoard BitBully::Board::lsb ( const TBitBoard x)
inlinestatic

Definition at line 222 of file Board.h.

◆ mirror()

Board BitBully::Board::mirror ( ) const
nodiscard

Definition at line 481 of file Board.cpp.

◆ movesLeft()

TMovesCounter BitBully::Board::movesLeft ( ) const
inlinenodiscard

Definition at line 210 of file Board.h.

◆ nextMove()

TBitBoard BitBully::Board::nextMove ( TBitBoard allMoves)
inlinestaticnodiscard

Definition at line 163 of file Board.h.

◆ operator!=()

bool BitBully::Board::operator!= ( const Board & b) const
inlinenodiscard

Definition at line 182 of file Board.h.

◆ operator==()

bool BitBully::Board::operator== ( const Board & b) const
inlinenodiscard

Definition at line 173 of file Board.h.

◆ play() [1/3]

bool BitBully::Board::play ( const std::string & moveSequence)
nodiscard

Definition at line 147 of file Board.cpp.

◆ play() [2/3]

bool BitBully::Board::play ( const std::vector< int > & moveSequence)
nodiscard

Definition at line 137 of file Board.cpp.

◆ play() [3/3]

bool BitBully::Board::play ( int column)

Definition at line 128 of file Board.cpp.

◆ playMoveOnCopy()

Board BitBully::Board::playMoveOnCopy ( const TBitBoard mv) const
inlinenodiscard

Definition at line 115 of file Board.h.

◆ popCountBoard() [1/2]

auto BitBully::Board::popCountBoard ( ) const
inlinenodiscard

Definition at line 140 of file Board.h.

◆ popCountBoard() [2/2]

constexpr int BitBully::Board::popCountBoard ( uint64_t x)
inlinestaticnodiscardconstexpr

Definition at line 131 of file Board.h.

◆ randomBoard()

std::pair< Board, std::vector< int > > BitBully::Board::randomBoard ( const int nPly,
const bool forbidDirectWin = true )
inlinestatic

Definition at line 285 of file Board.h.

◆ setBoard() [1/4]

bool BitBully::Board::setBoard ( const std::string & moveSequence)
nodiscard

Definition at line 32 of file Board.cpp.

◆ setBoard() [2/4]

bool BitBully::Board::setBoard ( const std::vector< int > & moveSequence)
nodiscard

Definition at line 21 of file Board.cpp.

◆ setBoard() [3/4]

bool BitBully::Board::setBoard ( const TBoardArray & board)
nodiscard

Definition at line 58 of file Board.cpp.

◆ setBoard() [4/4]

bool BitBully::Board::setBoard ( const TBoardArrayT & board)
nodiscard

Definition at line 53 of file Board.cpp.

◆ sortMoves()

MoveList BitBully::Board::sortMoves ( TBitBoard moves) const
nodiscard

Definition at line 276 of file Board.cpp.

◆ toArray()

Board::TBoardArray BitBully::Board::toArray ( ) const
nodiscard

Definition at line 443 of file Board.cpp.

◆ toHuffman()

int BitBully::Board::toHuffman ( ) const
inlinenodiscard

Definition at line 260 of file Board.h.

◆ toString()

std::string BitBully::Board::toString ( ) const
nodiscard

Definition at line 461 of file Board.cpp.

◆ uid()

uint64_t BitBully::Board::uid ( ) const
inlinenodiscard

Definition at line 153 of file Board.h.

◆ BoardTest

friend class BoardTest
friend

Definition at line 101 of file Board.h.

Member Data Documentation

◆ COLUMN_BIT_OFFSET

int BitBully::Board::COLUMN_BIT_OFFSET = 9
staticconstexpr

Definition at line 107 of file Board.h.

◆ N_COLUMNS

int BitBully::Board::N_COLUMNS = 7
staticconstexpr

Definition at line 105 of file Board.h.

◆ N_ROWS

int BitBully::Board::N_ROWS = 6
staticconstexpr

Definition at line 106 of file Board.h.

◆ N_VALID_BOARD_VALUES

size_t BitBully::Board::N_VALID_BOARD_VALUES = 3
staticconstexpr

Definition at line 109 of file Board.h.


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