Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

HandCodedPattern.hpp

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file HandCodedPattern.hpp
00003  */
00004 //----------------------------------------------------------------------------
00005 
00006 #ifndef HAND_CODED_PATTERN_HPP
00007 #define HAND_CODED_PATTERN_HPP
00008 
00009 #include "Hex.hpp"
00010 #include "StoneBoard.hpp"
00011 
00012 _BEGIN_BENZENE_NAMESPACE_
00013 
00014 //----------------------------------------------------------------------------
00015 
00016 /** Special patterns that are too big to check with a PatternBoard (to
00017     do so would mean increasing Pattern::MAX_EXTENSION, thus slowing
00018     down PatternBoard::update()).  These are static patterns -- so
00019     they are not translated.
00020 
00021     @todo Want hand-coded vulnerable patterns, not just dominated
00022 */
00023 class HandCodedPattern
00024 {        
00025 public: 
00026 
00027     /** Constructor, sets dominator and dominatee to
00028         INVALID_POINT.  */
00029     HandCodedPattern();
00030 
00031     /** Constructor. */
00032     explicit HandCodedPattern(HexPoint dominatee, HexPoint dominator);
00033 
00034     /** Destructor. */
00035     ~HandCodedPattern();
00036 
00037     //----------------------------------------------------------------------
00038 
00039     /** Adds all HandCodedPatterns into out. */
00040     static void CreatePatterns(std::vector<HandCodedPattern>& out);
00041 
00042     //----------------------------------------------------------------------
00043 
00044     /** Sets the dominated cell. */
00045     void setDominatee(HexPoint dominatee);
00046 
00047     /** Returns the dominated cell. */
00048     HexPoint dominatee() const;
00049     
00050     /** Sets the dominator. */
00051     void setDominator(HexPoint dominator);
00052 
00053     /** Returns the dominator. */
00054     HexPoint dominator() const;
00055 
00056     /** Sets the mask for the pattern. */
00057     void setMask(const bitset_t& bs);
00058     
00059     /** Sets the bitset for the given color. */
00060     void set(HexColor color, const bitset_t& bs);
00061 
00062     /** Rotates the pattern on the given board. */
00063     void rotate(const ConstBoard& brd);
00064 
00065     /** Mirrors the pattern on the given board. */
00066     void mirror(const ConstBoard& brd);
00067 
00068     /** Flips black to white and vice versa. */
00069     void flipColors();
00070 
00071     /** True if pattern matches board. */
00072     bool check(const StoneBoard& brd);
00073     
00074 private:
00075     HexPoint m_dominatee, m_dominator;
00076     bitset_t m_mask;
00077     bitset_t m_color[BLACK_AND_WHITE];
00078 };
00079 
00080 inline void HandCodedPattern::setDominatee(HexPoint dominatee)
00081 {
00082     m_dominatee = dominatee;
00083 }
00084 
00085 inline HexPoint HandCodedPattern::dominatee() const
00086 {
00087     return m_dominatee;
00088 }
00089 
00090 inline void HandCodedPattern::setDominator(HexPoint dominator)
00091 {
00092     m_dominator = dominator;
00093 }
00094 
00095 inline HexPoint HandCodedPattern::dominator() const
00096 {
00097     return m_dominator;
00098 }
00099 
00100 inline void HandCodedPattern::setMask(const bitset_t& mask) 
00101 {
00102     m_mask = mask;
00103 }
00104 
00105 //----------------------------------------------------------------------------
00106 
00107 _END_BENZENE_NAMESPACE_
00108 
00109 #endif  // HAND_CODED_PATTERN_HPP


6 Jan 2011 Doxygen 1.6.3