Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgMiaiStrategy Class Reference

#include <SgMiaiStrategy.h>

Inheritance diagram for SgMiaiStrategy:

Inheritance graph
[legend]
List of all members.

Detailed Description

Pair of moves strategy - if opponent plays one we must play other.

Definition at line 33 of file 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.

Private Member Functions

void StrategyFailed ()
 strategy has failed - set m_failed flag and release resources

Private Attributes

SgVector< SgMiaiPairm_miaiStrategies
 move pairs - must play one in each pair
SgVector< SgPointm_openThreats
 open threats must be answered to achieve strategy.
bool m_failed
 Strategy has failed if opponent has occupied both points in a pair.


Constructor & Destructor Documentation

SgMiaiStrategy::SgMiaiStrategy ( SgBlackWhite  player  ) 

Initialized to empty strategy; use AddPair.

Definition at line 38 of file SgMiaiStrategy.h.


Member Function Documentation

void SgMiaiStrategy::AddPair ( const SgMiaiPair miaiPair  ) 

Add a miai strategy on pair of points.

Definition at line 35 of file SgMiaiStrategy.cpp.

References SgPointSet::Contains(), Dependency(), SgPointUtil::InBoardRange(), m_miaiStrategies, and SG_ASSERT.

void SgMiaiStrategy::Clear (  )  [virtual]

See SgStrategy::Clear.

Reimplemented from SgStrategy.

Definition at line 50 of file SgMiaiStrategy.cpp.

References SgStrategy::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 59 of file SgMiaiStrategy.cpp.

References SgPointSet::Include(), and m_miaiStrategies.

Referenced by AddPair(), and Clear().

void SgMiaiStrategy::ExecuteMove ( SgPoint  p,
SgBlackWhite  player 
) [virtual]

See SgStrategy::ExecuteMove.

Implements SgStrategy.

Definition at line 89 of file SgMiaiStrategy.cpp.

References m_failed, m_miaiStrategies, m_openThreats, SgMiaiPairUtil::Other(), SgStrategy::Player(), SgVector< T >::PushBack(), and StrategyFailed().

bool SgMiaiStrategy::HasOverlappingMiaiPairs (  )  const

Pairs that overlap give a double threat.

Definition at line 131 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 54 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 152 of file SgMiaiStrategy.cpp.

References m_openThreats, SG_ASSERT, and SG_NULLPOINT.

Referenced by SgMiaiMap::ConvertFromSgMiaiStrategy().

const SgVector< SgPoint > & SgMiaiStrategy::OpenThreats (  )  const

See m_openThreats.

Definition at line 147 of file SgMiaiStrategy.cpp.

References m_openThreats.

SgBlackWhite SgStrategy::Player (  )  const [inherited]

See m_player.

Definition at line 46 of file SgStrategy.h.

References SgStrategy::m_player.

Referenced by SgMiaiMap::ConvertFromSgMiaiStrategy(), and ExecuteMove().

void SgMiaiStrategy::SetStrategy ( const SgVector< SgMiaiPair > &  miaiStrategies  ) 

Set whole strategy.

Definition at line 47 of file SgMiaiStrategy.h.

References m_miaiStrategies.

SgStrategyStatus SgMiaiStrategy::Status (  )  const [virtual]

See SgStrategyStatus.

Implements SgStrategy.

Definition at line 70 of file SgMiaiStrategy.cpp.

References m_failed, m_openThreats, SGSTRATEGY_ACHIEVED, SGSTRATEGY_FAILED, and SGSTRATEGY_THREATENED.

void SgMiaiStrategy::StrategyFailed (  )  [private]

strategy has failed - set m_failed flag and release resources

Definition at line 82 of file SgMiaiStrategy.cpp.

References m_failed, m_miaiStrategies, and m_openThreats.

Referenced by ExecuteMove().

void SgMiaiStrategy::UndoMove (  )  [virtual]

See SgStrategy::UndoMove.

Implements SgStrategy.

Definition at line 159 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 22 of file SgMiaiStrategy.cpp.

References m_failed, m_miaiStrategies, m_openThreats, and SgStrategy::Write().


Member Data Documentation

bool SgMiaiStrategy::m_failed [private]

Strategy has failed if opponent has occupied both points in a pair.

Definition at line 100 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 92 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 97 of file SgMiaiStrategy.h.

Referenced by Clear(), ExecuteMove(), OpenThreatMove(), OpenThreats(), Status(), StrategyFailed(), and Write().


The documentation for this class was generated from the following files:


17 Jun 2010 Doxygen 1.4.7