Pair of moves strategy - if opponent plays one we must play other. More...
#include <SgMiaiStrategy.h>
Public Member Functions | |
SgMiaiStrategy (SgBlackWhite player) | |
Initialized to empty strategy; use AddPair. | |
void | AddPair (const SgMiaiPair &miaiPair) |
Add a miai strategy on pair of points. | |
void | SetStrategy (const SgVector< SgMiaiPair > &miaiStrategies) |
Set whole strategy. | |
const SgVector< SgMiaiPair > & | MiaiStrategies () const |
See m_miaiStrategies. | |
bool | HasOverlappingMiaiPairs () const |
Pairs that overlap give a double threat. | |
SgPointSet | Dependency () const |
All points on which this strategy depends. | |
SgStrategyStatus | Status () const |
See SgStrategyStatus. | |
const SgVector< SgPoint > & | OpenThreats () const |
See m_openThreats. | |
SgPoint | OpenThreatMove () const |
If exactly one open threat, return that move. | |
void | ExecuteMove (SgPoint p, SgBlackWhite player) |
See SgStrategy::ExecuteMove. | |
void | UndoMove () |
See SgStrategy::UndoMove. | |
void | Clear () |
See SgStrategy::Clear. | |
void | Write (std::ostream &stream) const |
Write object to stream. | |
SgBlackWhite | Player () const |
See m_player. | |
virtual void | ExecuteMove (SgMove p, SgBlackWhite player)=0 |
update strategy with move | |
Private Member Functions | |
void | StrategyFailed () |
strategy has failed - set m_failed flag and release resources | |
Private Attributes | |
SgVector< SgMiaiPair > | m_miaiStrategies |
move pairs - must play one in each pair | |
SgVector< SgPoint > | m_openThreats |
open threats must be answered to achieve strategy. | |
bool | m_failed |
Strategy has failed if opponent has occupied both points in a pair. |
Pair of moves strategy - if opponent plays one we must play other.
Definition at line 32 of file SgMiaiStrategy.h.
SgMiaiStrategy::SgMiaiStrategy | ( | SgBlackWhite | player | ) |
Initialized to empty strategy; use AddPair.
Definition at line 37 of file SgMiaiStrategy.h.
void SgMiaiStrategy::AddPair | ( | const SgMiaiPair & | miaiPair | ) |
Add a miai strategy on pair of points.
Definition at line 34 of file SgMiaiStrategy.cpp.
References SgPointSet::Contains(), Dependency(), SgPointUtil::InBoardRange(), m_miaiStrategies, SgVector< T >::PushBack(), and SG_ASSERT.
void SgMiaiStrategy::Clear | ( | ) | [virtual] |
See SgStrategy::Clear.
Reimplemented from SgStrategy.
Definition at line 49 of file SgMiaiStrategy.cpp.
References SgVector< T >::Clear(), Dependency(), m_failed, m_miaiStrategies, m_openThreats, and SG_ASSERT.
SgPointSet SgMiaiStrategy::Dependency | ( | ) | const [virtual] |
All points on which this strategy depends.
Implements SgStrategy.
Definition at line 58 of file SgMiaiStrategy.cpp.
References SgPointSet::Include(), and m_miaiStrategies.
void SgMiaiStrategy::ExecuteMove | ( | SgPoint | p, | |
SgBlackWhite | player | |||
) |
Definition at line 88 of file SgMiaiStrategy.cpp.
References SgVector< T >::Exclude(), m_failed, m_miaiStrategies, m_openThreats, SgMiaiPairUtil::Other(), SgStrategy::Player(), SgVector< T >::PushBack(), and StrategyFailed().
virtual void SgStrategy::ExecuteMove | ( | SgMove | p, | |
SgBlackWhite | player | |||
) | [pure virtual, inherited] |
update strategy with move
bool SgMiaiStrategy::HasOverlappingMiaiPairs | ( | ) | const |
Pairs that overlap give a double threat.
Definition at line 130 of file SgMiaiStrategy.cpp.
References SgPointSet::Include(), and m_miaiStrategies.
Referenced by SgMiaiMap::ConvertFromSgMiaiStrategy().
const SgVector<SgMiaiPair>& SgMiaiStrategy::MiaiStrategies | ( | ) | const |
See m_miaiStrategies.
Definition at line 53 of file SgMiaiStrategy.h.
References m_miaiStrategies.
Referenced by SgMiaiMap::ConvertFromSgMiaiStrategy().
SgPoint SgMiaiStrategy::OpenThreatMove | ( | ) | const |
If exactly one open threat, return that move.
If no active threat, return SG_NULLPOINT.
Definition at line 151 of file SgMiaiStrategy.cpp.
References SgVector< T >::Back(), SgVector< T >::IsEmpty(), m_openThreats, SgVector< T >::MaxLength(), SG_ASSERT, and SG_NULLPOINT.
Referenced by SgMiaiMap::ConvertFromSgMiaiStrategy().
SgBlackWhite SgStrategy::Player | ( | ) | const [inherited] |
See m_player.
Definition at line 44 of file SgStrategy.h.
References SgStrategy::m_player.
Referenced by SgMiaiMap::ConvertFromSgMiaiStrategy(), and ExecuteMove().
void SgMiaiStrategy::SetStrategy | ( | const SgVector< SgMiaiPair > & | miaiStrategies | ) |
SgStrategyStatus SgMiaiStrategy::Status | ( | ) | const [virtual] |
See SgStrategyStatus.
Implements SgStrategy.
Definition at line 69 of file SgMiaiStrategy.cpp.
References SgVector< T >::IsEmpty(), SgVector< T >::IsLength(), m_failed, m_openThreats, SGSTRATEGY_ACHIEVED, and SGSTRATEGY_THREATENED.
void SgMiaiStrategy::StrategyFailed | ( | ) | [private] |
strategy has failed - set m_failed flag and release resources
Definition at line 81 of file SgMiaiStrategy.cpp.
References SgVector< T >::Clear(), m_failed, m_miaiStrategies, and m_openThreats.
Referenced by ExecuteMove().
void SgMiaiStrategy::UndoMove | ( | ) | [virtual] |
See SgStrategy::UndoMove.
Implements SgStrategy.
Definition at line 158 of file SgMiaiStrategy.cpp.
References SG_ASSERT.
void SgMiaiStrategy::Write | ( | std::ostream & | stream | ) | const [virtual] |
Write object to stream.
Do not call directly, use operator<<
Reimplemented from SgStrategy.
Definition at line 21 of file SgMiaiStrategy.cpp.
References m_failed, m_miaiStrategies, and m_openThreats.
bool SgMiaiStrategy::m_failed [private] |
Strategy has failed if opponent has occupied both points in a pair.
Definition at line 97 of file SgMiaiStrategy.h.
Referenced by Clear(), ExecuteMove(), Status(), StrategyFailed(), and Write().
SgVector<SgMiaiPair> SgMiaiStrategy::m_miaiStrategies [private] |
move pairs - must play one in each pair
Definition at line 90 of file SgMiaiStrategy.h.
Referenced by AddPair(), Clear(), Dependency(), ExecuteMove(), HasOverlappingMiaiPairs(), MiaiStrategies(), SetStrategy(), StrategyFailed(), and Write().
SgVector<SgPoint> SgMiaiStrategy::m_openThreats [private] |
open threats must be answered to achieve strategy.
More than one open threat means strategy cannot be achieved.
Definition at line 94 of file SgMiaiStrategy.h.
Referenced by Clear(), ExecuteMove(), OpenThreatMove(), OpenThreats(), Status(), StrategyFailed(), and Write().