A group on the board. More...
#include <Groups.hpp>
Public Member Functions | |
Group () | |
Creates an empty invalid group. | |
std::size_t | Size () const |
Number of stones in group. | |
HexColor | Color () const |
Color of the group. | |
HexPoint | Captain () const |
Point used as the representative of this group. | |
bool | IsMember (HexPoint point) const |
Returns true if point is a member of group, false otherwise. | |
const bitset_t & | Members () const |
Returns the members. | |
const bitset_t & | Nbs () const |
Returns neighbours. | |
const bitset_t & | Nbs (HexColorSet colorset) const |
Returns the captains of neighboring groups whose color belongs to colorset. | |
Private Member Functions | |
Group (const Groups *groups, HexColor color, HexPoint captain, const bitset_t &members, const bitset_t &nbs) | |
Used only by GroupBuilder::Build(). | |
void | ComputeColorsetNbs () const |
Private Attributes | |
HexColor | m_color |
HexPoint | m_captain |
bitset_t | m_members |
bitset_t | m_nbs |
const Groups * | m_groups |
Pointer to Groups object which this Group belongs. | |
std::vector< std::size_t > | m_nbs_index |
Indices of neighbouring groups in parent Groups's list of groups. | |
bool | m_colorsets_computed |
True if the colorset neighbours have been computed yet. | |
bitset_t | m_nbs_colorset [NUM_COLOR_SETS] |
Computed colorset neighbours. | |
Friends | |
class | GroupBuilder |
A group on the board.
A group is a maximal set of like-colored stones. Groups of color EMPTY are always singletons.
Definition at line 25 of file Groups.hpp.
Group::Group | ( | ) | [inline] |
Creates an empty invalid group.
Only GroupBuilder can construct valid groups.
Definition at line 89 of file Groups.hpp.
Group::Group | ( | const Groups * | groups, | |
HexColor | color, | |||
HexPoint | captain, | |||
const bitset_t & | members, | |||
const bitset_t & | nbs | |||
) | [inline, private] |
Used only by GroupBuilder::Build().
Definition at line 97 of file Groups.hpp.
HexPoint Group::Captain | ( | ) | const [inline] |
Point used as the representative of this group.
Definition at line 119 of file Groups.hpp.
References m_captain.
Referenced by Groups::CaptainOf(), BenzeneHtpEngine::CmdGetAbsorbGroup(), ComputeColorsetNbs(), Groups::IsCaptain(), VCBuilder::Merge(), and Groups::Nbs().
HexColor Group::Color | ( | ) | const [inline] |
Color of the group.
Definition at line 114 of file Groups.hpp.
References m_color.
Referenced by ComputeColorsetNbs(), VCBuilder::Merge(), and VCBuilder::RemoveAllContaining().
void Group::ComputeColorsetNbs | ( | ) | const [private] |
Definition at line 126 of file Groups.cpp.
References Captain(), Color(), HexColorSetUtil::InSet(), Groups::m_groups, m_groups, m_nbs_colorset, m_nbs_index, NUM_COLOR_SETS, and benzene_bitset< _Nb >::set().
Referenced by Nbs().
bool Group::IsMember | ( | HexPoint | point | ) | const [inline] |
Returns true if point is a member of group, false otherwise.
Definition at line 124 of file Groups.hpp.
References m_members, and benzene_bitset< _Nb >::test().
const bitset_t & Group::Members | ( | ) | const [inline] |
const bitset_t & Group::Nbs | ( | HexColorSet | colorset | ) | const |
Returns the captains of neighboring groups whose color belongs to colorset.
If first time, neighbors in each colorset will be computed.
Definition at line 116 of file Groups.cpp.
References ComputeColorsetNbs(), m_colorsets_computed, and m_nbs_colorset.
const bitset_t & Group::Nbs | ( | ) | const [inline] |
Returns neighbours.
Definition at line 134 of file Groups.hpp.
References m_nbs.
Referenced by Groups::Nbs().
std::size_t Group::Size | ( | ) | const [inline] |
Number of stones in group.
Definition at line 108 of file Groups.hpp.
References benzene_bitset< _Nb >::count(), and m_members.
friend class GroupBuilder [friend] |
Definition at line 59 of file Groups.hpp.
HexPoint Group::m_captain [private] |
Definition at line 63 of file Groups.hpp.
Referenced by Captain().
HexColor Group::m_color [private] |
Definition at line 61 of file Groups.hpp.
Referenced by Color().
bool Group::m_colorsets_computed [mutable, private] |
True if the colorset neighbours have been computed yet.
Definition at line 78 of file Groups.hpp.
Referenced by Nbs().
const Groups* Group::m_groups [private] |
Pointer to Groups object which this Group belongs.
Definition at line 70 of file Groups.hpp.
Referenced by ComputeColorsetNbs().
bitset_t Group::m_members [private] |
Definition at line 65 of file Groups.hpp.
Referenced by IsMember(), Members(), and Size().
bitset_t Group::m_nbs [private] |
Definition at line 67 of file Groups.hpp.
Referenced by GroupBuilder::Build(), and Nbs().
bitset_t Group::m_nbs_colorset[NUM_COLOR_SETS] [mutable, private] |
Computed colorset neighbours.
Definition at line 81 of file Groups.hpp.
Referenced by ComputeColorsetNbs(), and Nbs().
std::vector<std::size_t> Group::m_nbs_index [private] |
Indices of neighbouring groups in parent Groups's list of groups.
We don't use pointers because then it would be difficult to copy a Groups object.
Definition at line 75 of file Groups.hpp.
Referenced by GroupBuilder::Build(), and ComputeColorsetNbs().