Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
inline bool StoneBoard::IsPlayed(HexPoint cell) const
{
    BenzeneAssert(Const().IsValid(cell));
    return m_played.test(cell);
}
Exemplo n.º 4
0
inline bitset_t StoneBoard::GetColor(HexColor color) const
{
    BenzeneAssert(HexColorUtil::isValidColor(color));
    if (color == EMPTY) return GetEmpty();
    return m_stones[color] & Const().GetLocations();
}
Exemplo n.º 5
0
inline bool StoneBoard::IsOccupied(HexPoint cell) const
{
    BenzeneAssert(Const().IsLocation(cell));
    return (IsBlack(cell) || IsWhite(cell));
}
Exemplo n.º 6
0
inline bitset_t StoneBoard::GetPlayed(HexColor color) const 
{
    BenzeneAssert(HexColorUtil::isBlackWhite(color));
    return m_played & GetColor(color);
}
Exemplo n.º 7
0
inline bool StoneBoard::IsColor(HexPoint cell, HexColor color) const
{
    BenzeneAssert(HexColorUtil::isBlackWhite(color));
    BenzeneAssert(Const().IsLocation(cell));
    return m_stones[color].test(cell);
}
Exemplo n.º 8
0
inline bool StoneBoard::IsEmpty(HexPoint cell) const
{
    BenzeneAssert(Const().IsLocation(cell));
    return !IsOccupied(cell);
}
Exemplo n.º 9
0
inline bool StoneBoard::IsBlack(HexPoint cell) const    
{
    BenzeneAssert(Const().IsValid(cell));
    return m_stones[BLACK].test(cell);
}
Exemplo n.º 10
0
inline bool StoneBoard::IsWhite(HexPoint cell) const    
{
    BenzeneAssert(Const().IsValid(cell));
    return m_stones[WHITE].test(cell);
}
Exemplo n.º 11
0
inline int Pattern::GetWeight() const
{
    BenzeneAssert(m_flags & HAS_WEIGHT);
    return m_weight;
}
Exemplo n.º 12
0
inline HexPoint HexPointUtil::colorEdge2(HexColor color)
{
    BenzeneAssert(HexColorUtil::isBlackWhite(color));
    return (color == VERTICAL_COLOR) ? SOUTH : WEST;
}
Exemplo n.º 13
0
inline const std::vector<std::pair<int, int> >& Pattern::GetMoves2() const
{
    BenzeneAssert(m_flags & HAS_MOVES2);
    return m_moves2;
}
Exemplo n.º 14
0
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];
}
Exemplo n.º 15
0
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);
}
Exemplo n.º 16
0
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;
}
Exemplo n.º 17
0
inline bool HexPointUtil::isColorEdge(HexPoint cell, HexColor color)
{
    BenzeneAssert(HexColorUtil::isBlackWhite(color));
    return (cell == colorEdge1(color) || cell == colorEdge2(color));
}