Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Public Member Functions | Private Member Functions | Private Attributes

SgMiaiStrategy Class Reference

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

#include <SgMiaiStrategy.h>

Inheritance diagram for SgMiaiStrategy:
Inheritance graph
[legend]

List of all members.

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< 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.

Detailed Description

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

Definition at line 32 of file SgMiaiStrategy.h.


Constructor & Destructor Documentation

SgMiaiStrategy::SgMiaiStrategy ( SgBlackWhite  player  ) 

Initialized to empty strategy; use AddPair.

Definition at line 37 of file SgMiaiStrategy.h.


Member Function Documentation

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.

Referenced by AddPair(), and Clear().

void SgMiaiStrategy::ExecuteMove ( SgPoint  p,
SgBlackWhite  player 
)
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().

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

See m_openThreats.

Definition at line 146 of file SgMiaiStrategy.cpp.

References m_openThreats.

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  ) 

Set whole strategy.

Definition at line 46 of file SgMiaiStrategy.h.

References m_miaiStrategies.

SgStrategyStatus SgMiaiStrategy::Status (  )  const [virtual]
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.


Member Data Documentation

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().

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().

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().


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


Sun Mar 13 2011 Doxygen 1.7.1