inline HexPoint HexPointUtil::rightEdge(HexPoint edge) { BenzeneAssert(isEdge(edge)); if (edge == NORTH) return WEST; if (edge == SOUTH) return EAST; if (edge == EAST) return NORTH; BenzeneAssert(edge == WEST); return SOUTH; }
inline HexColor StoneBoard::WhoseTurn() const { BenzeneAssert(IsStandardPosition()); bitset_t mask = GetPlayed() & Const().GetCells(); std::size_t first = (GetColor(FIRST_TO_PLAY) & mask).count(); std::size_t second = (GetColor(!FIRST_TO_PLAY) & mask).count(); return (first > second) ? !FIRST_TO_PLAY : FIRST_TO_PLAY; }
inline bool StoneBoard::IsPlayed(HexPoint cell) const { BenzeneAssert(Const().IsValid(cell)); return m_played.test(cell); }
inline bitset_t StoneBoard::GetColor(HexColor color) const { BenzeneAssert(HexColorUtil::isValidColor(color)); if (color == EMPTY) return GetEmpty(); return m_stones[color] & Const().GetLocations(); }
inline bool StoneBoard::IsOccupied(HexPoint cell) const { BenzeneAssert(Const().IsLocation(cell)); return (IsBlack(cell) || IsWhite(cell)); }
inline bitset_t StoneBoard::GetPlayed(HexColor color) const { BenzeneAssert(HexColorUtil::isBlackWhite(color)); return m_played & GetColor(color); }
inline bool StoneBoard::IsColor(HexPoint cell, HexColor color) const { BenzeneAssert(HexColorUtil::isBlackWhite(color)); BenzeneAssert(Const().IsLocation(cell)); return m_stones[color].test(cell); }
inline bool StoneBoard::IsEmpty(HexPoint cell) const { BenzeneAssert(Const().IsLocation(cell)); return !IsOccupied(cell); }
inline bool StoneBoard::IsBlack(HexPoint cell) const { BenzeneAssert(Const().IsValid(cell)); return m_stones[BLACK].test(cell); }
inline bool StoneBoard::IsWhite(HexPoint cell) const { BenzeneAssert(Const().IsValid(cell)); return m_stones[WHITE].test(cell); }
inline int Pattern::GetWeight() const { BenzeneAssert(m_flags & HAS_WEIGHT); return m_weight; }
inline HexPoint HexPointUtil::colorEdge2(HexColor color) { BenzeneAssert(HexColorUtil::isBlackWhite(color)); return (color == VERTICAL_COLOR) ? SOUTH : WEST; }
inline const std::vector<std::pair<int, int> >& Pattern::GetMoves2() const { BenzeneAssert(m_flags & HAS_MOVES2); return m_moves2; }
inline int HexPointUtil::DeltaY(int dir) { BenzeneAssert(DIR_EAST <= dir && dir < NUM_DIRECTIONS); static const int dy[] = {0, -1, -1, 0, 1, 1}; return dy[dir]; }
inline HexPoint HexPointUtil::coordsToPoint(int x, int y) { BenzeneAssert(0 <= x && x < MAX_WIDTH); BenzeneAssert(0 <= y && y < MAX_HEIGHT); return static_cast<HexPoint>(FIRST_CELL + (y*MAX_WIDTH) + x); }
inline void HexPointUtil::pointToCoords(HexPoint cell, int& x, int& y) { BenzeneAssert(FIRST_CELL <= cell && cell < FIRST_INVALID); x = (cell-FIRST_CELL) % MAX_WIDTH; y = (cell-FIRST_CELL) / MAX_WIDTH; }
inline bool HexPointUtil::isColorEdge(HexPoint cell, HexColor color) { BenzeneAssert(HexColorUtil::isBlackWhite(color)); return (cell == colorEdge1(color) || cell == colorEdge2(color)); }