Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgMiaiMap.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file SgMiaiMap.h
00003     Efficient implementation of a consistent (not broken) SgMiaiStrategy.
00004 
00005 */
00006 //----------------------------------------------------------------------------
00007 
00008 #ifndef SG_MIAIMAP_H
00009 #define SG_MIAIMAP_H
00010 
00011 #include "SgArray.h"
00012 #include "SgBlackWhite.h"
00013 #include "SgBWArray.h"
00014 #include "SgMiaiStrategy.h"
00015 #include "SgPoint.h"
00016 
00017 //----------------------------------------------------------------------------
00018 
00019 /** Efficient implementation of a SgMiaiStrategy.
00020     The miai strategy must be achievable (not broken).
00021     Uses two boards, one for each color.
00022     Board entries either point to the miai point, 
00023     or are set to SG_NULLPOINT if the point is not part of a miai.
00024     Can only be used going forward through a game - does not support undo.
00025 */
00026 class SgMiaiMap
00027 {
00028 public:
00029     /** Initialize to empty map. */
00030     SgMiaiMap();
00031     
00032     /** See SgStrategy::ExecuteMove */
00033     void ExecuteMove(SgPoint p, SgBlackWhite player);
00034     
00035     /** See m_forcedMove */
00036     SgPoint ForcedMove() const {return m_forcedMove;}
00037 
00038     /** See SgStrategyStatus */
00039     SgStrategyStatus Status() const;
00040 
00041     /** Convert SgMiaiStrategy into SgMiaiMap. 
00042         The SgMiaiStrategy must not have overlapping threats.
00043     */
00044     void ConvertFromSgMiaiStrategy(const SgMiaiStrategy& s);
00045     
00046     /** Convert SgMiaiMap into SgMiaiStrategy. 
00047     */
00048     void ConvertToSgMiaiStrategy(SgMiaiStrategy* s) const;
00049 private:
00050     /** Move that must be played to stop or convert an open threat.
00051         Returns SG_NULLPOINT if no such move.
00052     */
00053     SgPoint m_forcedMove;
00054     
00055     /** Strategy has failed if opponent has occupied both points in a pair */
00056     bool m_failed;
00057     
00058     /** The maps, one for each color. */
00059     SgBWArray<SgArray<int,SG_MAXPOINT> > m_map;
00060 };
00061 
00062 std::ostream& operator<<(std::ostream& stream, const SgStrategy& s);
00063 
00064 //----------------------------------------------------------------------------
00065 
00066 #endif // SG_MIAIMAP_H


17 Jun 2010 Doxygen 1.4.7