Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgStrategy.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file SgStrategy.h
00003     SgStrategy is a strategy for winning a specified goal.
00004 
00005     An example of a strategy: keep a territory safe that was proven safe
00006     earlier on. The strategy contains answers to any opponent threat.
00007     Strategies can be generated, tracked, and enforced during search. */
00008 //----------------------------------------------------------------------------
00009 
00010 #ifndef SG_STRATEGY_H
00011 #define SG_STRATEGY_H
00012 
00013 #include "SgArray.h"
00014 #include "SgBlackWhite.h"
00015 #include "SgBWArray.h"
00016 #include "SgHash.h"
00017 #include "SgPointSet.h"
00018 
00019 //----------------------------------------------------------------------------
00020 
00021 enum SgStrategyStatus
00022 {
00023     SGSTRATEGY_ACHIEVED,
00024     SGSTRATEGY_THREATENED,
00025     SGSTRATEGY_UNKNOWN,
00026     SGSTRATEGY_FAILED,
00027     _SGSTRATEGY_COUNT
00028 };
00029 
00030 std::ostream& operator<<(std::ostream& stream, SgStrategyStatus s);
00031 
00032 //----------------------------------------------------------------------------
00033 
00034 /** Strategy for achieving a certain goal.
00035     Pure virtual class, see e.g. SgMiaiStrategy for an implementation. */
00036 class SgStrategy
00037 {
00038 public:
00039     SgStrategy(SgBlackWhite player);
00040     
00041     virtual ~SgStrategy() {}
00042 
00043     /** See m_player */
00044     SgBlackWhite Player() const
00045     {
00046         return m_player;
00047     }
00048 
00049     /** remove all data, reset to empty strategy. */
00050     virtual void Clear();
00051     
00052     /** all points on board that can possibly affect strategy */
00053     virtual SgPointSet Dependency() const = 0;
00054     
00055     /** check success of strategy on given board */
00056     virtual SgStrategyStatus Status() const = 0;
00057     
00058     /** update strategy with move */
00059     virtual void ExecuteMove(SgMove p, SgBlackWhite player) = 0;
00060     
00061     /** go back to strategy state before move */
00062     virtual void UndoMove() = 0;
00063         
00064     /** Write object to stream. Do not call directly, use operator<< */
00065     virtual void Write(std::ostream& stream) const;
00066 
00067 private:
00068     /** The player that this strategy is for */
00069     SgBlackWhite m_player;
00070 
00071     /** Hash code of board region for which strategy is defined */
00072     SgHashCode m_code;
00073 };
00074 
00075 std::ostream& operator<<(std::ostream& stream, const SgStrategy& s);
00076 
00077 //----------------------------------------------------------------------------
00078 
00079 #endif // SG_STRATEGY_H


Sun Mar 13 2011 Doxygen 1.7.1