VCPattern.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #ifndef VC_PATTERN_HPP
00007 #define VC_PATTERN_HPP
00008
00009 #include "Hex.hpp"
00010 #include "StoneBoard.hpp"
00011
00012 _BEGIN_BENZENE_NAMESPACE_
00013
00014
00015
00016 class VCPattern;
00017
00018 typedef std::vector<VCPattern> VCPatternSet;
00019
00020
00021
00022
00023 class VCPattern
00024 {
00025 public:
00026
00027 VCPattern(HexPoint end1, HexPoint end2, const bitset_t& must_have,
00028 const bitset_t& not_oppt);
00029
00030 ~VCPattern();
00031
00032
00033
00034
00035
00036 static const VCPatternSet& GetPatterns(int width, int height,
00037 HexColor color);
00038
00039
00040
00041 bitset_t MustHave() const;
00042
00043
00044 bitset_t NotOpponent() const;
00045
00046
00047 HexPoint Endpoint(int i) const;
00048
00049
00050 bool Matches(HexColor color, const StoneBoard& brd) const;
00051
00052
00053
00054
00055
00056 bool ShiftPattern(HexDirection dir, const StoneBoard& brd);
00057
00058 private:
00059
00060
00061 bitset_t m_must_have;
00062
00063
00064 bitset_t m_not_oppt;
00065
00066
00067 HexPoint m_end1, m_end2;
00068
00069
00070
00071 typedef std::map< std::pair<int, int>, VCPatternSet > VCPatternSetMap;
00072 struct GlobalData
00073 {
00074 VCPatternSetMap constructed[BLACK_AND_WHITE];
00075 };
00076
00077
00078 static VCPatternSetMap& GetConstructed(HexColor color);
00079
00080
00081 static void CreatePatterns(int width, int height);
00082 };
00083
00084 inline bitset_t VCPattern::MustHave() const
00085 {
00086 return m_must_have;
00087 }
00088
00089 inline bitset_t VCPattern::NotOpponent() const
00090 {
00091 return m_not_oppt;
00092 }
00093
00094 inline HexPoint VCPattern::Endpoint(int i) const
00095 {
00096 HexAssert(0 <= i && i <= 1);
00097 if (i == 0) return m_end1;
00098 return m_end2;
00099 }
00100
00101
00102
00103 _END_BENZENE_NAMESPACE_
00104
00105 #endif // VC_PATTERN_HPP