Virtual Connection. More...
#include <VC.hpp>
Public Types | |
enum | Type { FULL, SEMI, NUM_TYPES } |
Two types of Virtual VCSet: FULL and SEMI. More... | |
Public Member Functions | |
VC () | |
Constucts and empty VC with endpoints are (INVALID_POINT, INVALID_POINT). | |
VC (HexPoint x, HexPoint y) | |
Creates an empty VC between x and y: no key, empty carrier, VC_RULE_BASE. | |
VC (HexPoint x, HexPoint y, const bitset_t &carrier, VcCombineRule from) | |
Creates a 0-connection between x and y with the given carrier. | |
VC (HexPoint x, HexPoint y, HexPoint key, const bitset_t &carrier, VcCombineRule from) | |
Creates a 1-connection between x and y with the given carrier and key. | |
HexPoint | x () const |
Returns the smaller of the two endpoints. | |
HexPoint | y () const |
Returns the larger of the two endpoints. | |
HexPoint | key () const |
Returns the key of the connection. | |
bitset_t | carrier () const |
The set of cells required in order to realize this connection. | |
Type | type () const |
Returns the type of connection. | |
VcCombineRule | rule () const |
Returns rule used to construct this connection. | |
int | count () const |
Returns the number of set bits in the carrier; this is cached so only takes constant time. | |
bool | IsEmpty () const |
Returns true if the carrier is empty, false otherwise. | |
std::string | toString () const |
Returns string representation of connection. | |
bool | processed () const |
Returns true if this vc has been processed; false, otherwise. | |
void | setProcessed (bool flag) |
Sets the processed flag. | |
bool | operator== (const VC &o) const |
Two VCs are equal if their keys and carriers are equal. | |
bool | operator!= (const VC &o) const |
bool | operator< (const VC &o) const |
Comparison is by the number of set bits in the carrier. | |
bool | operator> (const VC &o) const |
bool | operator<= (const VC &o) const |
bool | isSubsetOf (const VC &o) const |
Is this a subset of o? | |
Static Public Member Functions | |
Static methods | |
static VC | AndVCs (HexPoint x, HexPoint y, const VC &v1, const VC &v2) |
Returns a new full VC by unioning v1 and v2. | |
static VC | AndVCs (HexPoint x, HexPoint y, const VC &v1, const VC &v2, const bitset_t &capturedSet) |
static VC | AndVCs (HexPoint x, HexPoint y, const VC &v1, const VC &v2, HexPoint key) |
Returns a new semi VC with key key by unioning v1 and v2. | |
static VC | AndVCs (HexPoint x, HexPoint y, const VC &v1, const VC &v2, const bitset_t &capturedSet, HexPoint key) |
static VC | UpgradeSemi (const VC &v1, const bitset_t &takeout, HexPoint outx, HexPoint outy) |
static VC | ShrinkFull (const VC &v1, const bitset_t &takeout, HexPoint outx, HexPoint outy) |
static VC | ShrinkSemi (const VC &v1, const bitset_t &takeout, HexPoint outx, HexPoint outy) |
Static Public Attributes | |
static const HexPoint | NO_KEY = INVALID_POINT |
Full connections must have their keys set to NO_KEY. | |
Private Attributes | |
short | m_x |
The smaller of the two endpoints. | |
short | m_y |
The larger of the two endpoints. | |
short | m_key |
The connection key; if NO_KEY, then this is a FULL connection, otherwise this is a SEMI connectin. | |
bitset_t | m_carrier |
The empty cells that may be required to realize this connection. | |
byte | m_rule |
The rule used to construct this connection. | |
byte | m_processed |
Flag denoting whether this connection has been used to build other connections. | |
byte | m_count |
Cached number of bits in the carrier. |
Virtual Connection.
Definition at line 66 of file VC.hpp.
enum VC::Type |
Two types of Virtual VCSet: FULL and SEMI.
FULL (or "0") connections are second-player strategies guaranteeing the connection even if the opponent goes first. FULL must have their key set to NO_KEY.
SEMI (or "1") connections are first-player strategies; ie, the first player can make the connection if he is given one free move. This free move is called the "key" of the connection.
VC::VC | ( | ) |
Constucts and empty VC with endpoints are (INVALID_POINT, INVALID_POINT).
Definition at line 13 of file VC.cpp.
Referenced by AndVCs(), ShrinkFull(), ShrinkSemi(), and UpgradeSemi().
VC::VC | ( | HexPoint | x, | |
HexPoint | y, | |||
const bitset_t & | carrier, | |||
VcCombineRule | from | |||
) |
VC::VC | ( | HexPoint | x, | |
HexPoint | y, | |||
HexPoint | key, | |||
const bitset_t & | carrier, | |||
VcCombineRule | from | |||
) |
VC VC::AndVCs | ( | HexPoint | x, | |
HexPoint | y, | |||
const VC & | v1, | |||
const VC & | v2, | |||
const bitset_t & | capturedSet, | |||
HexPoint | key | |||
) | [static] |
Definition at line 103 of file VC.cpp.
References carrier(), HexAssert, BitsetUtil::IsSubsetOf(), VC(), and VC_RULE_AND.
VC VC::AndVCs | ( | HexPoint | x, | |
HexPoint | y, | |||
const VC & | v1, | |||
const VC & | v2, | |||
const bitset_t & | capturedSet | |||
) | [static] |
Definition at line 89 of file VC.cpp.
References carrier(), HexAssert, BitsetUtil::IsSubsetOf(), VC(), and VC_RULE_AND.
Returns a new full VC by unioning v1 and v2.
Definition at line 83 of file VC.cpp.
References carrier(), HexAssert, VC(), and VC_RULE_AND.
Referenced by VCBuilder::doAnd().
bitset_t VC::carrier | ( | ) | const [inline] |
The set of cells required in order to realize this connection.
Definition at line 235 of file VC.hpp.
References m_carrier.
Referenced by VCList::add(), VCBuilder::AddNewFull(), VCBuilder::AddNewSemi(), VCBuilder::andClosure(), AndVCs(), VCBuilder::doAnd(), EndgameUtils::IsLostGame(), EndgameUtils::IsWonGame(), VCBuilder::MergeAndShrink(), VCBuilder::OrRule::operator()(), ShrinkFull(), ShrinkSemi(), VCList::simple_add(), toString(), and UpgradeSemi().
int VC::count | ( | ) | const [inline] |
Returns the number of set bits in the carrier; this is cached so only takes constant time.
Definition at line 250 of file VC.hpp.
References m_count.
Referenced by operator<().
bool VC::IsEmpty | ( | ) | const [inline] |
Returns true if the carrier is empty, false otherwise.
Definition at line 255 of file VC.hpp.
References m_carrier, and benzene_bitset< _Nb >::none().
Referenced by TwoDistance::IsAdjacent().
bool VC::isSubsetOf | ( | const VC & | o | ) | const [inline] |
Is this a subset of o?
Definition at line 305 of file VC.hpp.
References BitsetUtil::IsSubsetOf(), and m_carrier.
Referenced by VCList::add().
HexPoint VC::key | ( | ) | const [inline] |
Returns the key of the connection.
Definition at line 230 of file VC.hpp.
References m_key.
Referenced by ShrinkFull(), ShrinkSemi(), toString(), and UpgradeSemi().
bool VC::operator< | ( | const VC & | o | ) | const [inline] |
bool VC::operator== | ( | const VC & | o | ) | const [inline] |
bool VC::processed | ( | ) | const [inline] |
Returns true if this vc has been processed; false, otherwise.
Definition at line 260 of file VC.hpp.
References m_processed.
VcCombineRule VC::rule | ( | ) | const [inline] |
Returns rule used to construct this connection.
Definition at line 245 of file VC.hpp.
References m_rule.
Referenced by ShrinkFull(), ShrinkSemi(), and toString().
void VC::setProcessed | ( | bool | flag | ) | [inline] |
Sets the processed flag.
ONLY USE THIS IF YOU KNOW WHAT YOU ARE DOING!
Should only be called inside of VCSet.
Definition at line 265 of file VC.hpp.
References m_processed.
VC VC::ShrinkSemi | ( | const VC & | v1, | |
const bitset_t & | takeout, | |||
HexPoint | outx, | |||
HexPoint | outy | |||
) | [static] |
Definition at line 128 of file VC.cpp.
References carrier(), HexAssert, key(), NO_KEY, rule(), benzene_bitset< _Nb >::test(), and VC().
Referenced by VCBuilder::MergeAndShrink().
std::string VC::toString | ( | ) | const |
VC::Type VC::type | ( | ) | const [inline] |
Returns the type of connection.
Definition at line 240 of file VC.hpp.
References FULL, m_key, NO_KEY, and SEMI.
Referenced by VCSet::Add(), VCBuilder::AddNewFull(), toString(), and VC().
VC VC::UpgradeSemi | ( | const VC & | v1, | |
const bitset_t & | takeout, | |||
HexPoint | outx, | |||
HexPoint | outy | |||
) | [static] |
Definition at line 112 of file VC.cpp.
References carrier(), HexAssert, key(), NO_KEY, benzene_bitset< _Nb >::test(), VC(), and VC_RULE_AND.
Referenced by VCBuilder::MergeAndShrink().
HexPoint VC::x | ( | ) | const [inline] |
Returns the smaller of the two endpoints.
Definition at line 220 of file VC.hpp.
References m_x.
Referenced by VCSet::Add(), VCList::add(), VCBuilder::AddNewFull(), VCBuilder::AddNewSemi(), VCBuilder::andClosure(), VCList::simple_add(), and toString().
HexPoint VC::y | ( | ) | const [inline] |
Returns the larger of the two endpoints.
Definition at line 225 of file VC.hpp.
References m_y.
Referenced by VCSet::Add(), VCList::add(), VCBuilder::AddNewFull(), VCBuilder::AddNewSemi(), VCBuilder::andClosure(), VCList::simple_add(), and toString().
bitset_t VC::m_carrier [private] |
The empty cells that may be required to realize this connection.
Definition at line 207 of file VC.hpp.
Referenced by carrier(), IsEmpty(), isSubsetOf(), operator<(), operator==(), and VC().
byte VC::m_count [private] |
short VC::m_key [private] |
The connection key; if NO_KEY, then this is a FULL connection, otherwise this is a SEMI connectin.
Definition at line 203 of file VC.hpp.
Referenced by key(), operator<(), operator==(), and type().
byte VC::m_processed [private] |
Flag denoting whether this connection has been used to build other connections.
Definition at line 214 of file VC.hpp.
Referenced by processed(), and setProcessed().
byte VC::m_rule [private] |
short VC::m_x [private] |
short VC::m_y [private] |
const HexPoint VC::NO_KEY = INVALID_POINT [static] |
Full connections must have their keys set to NO_KEY.
Definition at line 83 of file VC.hpp.
Referenced by ShrinkFull(), ShrinkSemi(), type(), and UpgradeSemi().