Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

HandicapPlayer.hpp

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file HandicapPlayer.hpp
00003  */
00004 //----------------------------------------------------------------------------
00005 
00006 #ifndef HEXHANDICAPPLAYER_HPP
00007 #define HEXHANDICAPPLAYER_HPP
00008 
00009 #include "BenzenePlayer.hpp"
00010 
00011 _BEGIN_BENZENE_NAMESPACE_
00012 
00013 //----------------------------------------------------------------------------
00014 
00015 /** Player using Handicap to generate moves. 
00016 
00017     @note This player is not used.
00018 
00019     @todo CLEANUP!
00020 */
00021 class HandicapPlayer : public BenzenePlayer
00022 {
00023 public:
00024 
00025     explicit HandicapPlayer(ICEngine* ice);
00026 
00027     virtual ~HandicapPlayer();
00028 
00029     /** returns "handicap". */
00030     std::string Name() const;
00031 
00032 protected:
00033 
00034     /** Generates a move in the given gamestate using handicap
00035         strategy. The handicap player must always be WHITE.
00036     */
00037     virtual HexPoint Search(HexBoard& brd, const Game& game_state,
00038                 HexColor color, const bitset_t& consider,
00039                 double max_time, double& score);
00040     
00041 private:
00042 
00043     ICEngine* m_ice;
00044 
00045     bool m_assume_added_stones;
00046     
00047     PointToPoint m_responseMap;
00048 
00049     int m_width;
00050 
00051     /** Build the mapping of what the mirror of each HexPoint is */
00052     void buildResponseMap(const StoneBoard& brd);
00053 
00054     /** Takes two HexPoints and maps them to each other */
00055     void makeMiai(HexPoint p1, HexPoint p2);
00056 
00057     /** Takes four HexPoints and maps p1, p2, and p3 to dest unless
00058         p1, p2, and/or p3 are already occupied, in which case there
00059         are a number of special cases.
00060         - If dest is occupied by black, p2 is viewed as dead and
00061         ignored.  p1 is mirrored as most other cells are, and p3 is
00062         mirrored to the spot above or below it, just outside of the
00063         pattern of four.
00064         - If dest is occupied by white and any of the two other spaces
00065         are occupied, white plays the last spot.
00066         - If dest is occupied by white and if two or more of p1, p2,
00067         p3 remain unoccupied then p1 and p2 are mirrored and p3 is
00068         mapped to the spot above or below it, just outside of the
00069         pattern of four.
00070         - Finally, if white occupies any of p1, p2, or p3, then p1 and
00071         dest are mirrored as most of the other cells are, p2 is
00072         ignored (as it is either dead for black or occupied by white)
00073         and p3 is mapped to the spot above or below it, just outside
00074         of the pattern of four.
00075     */
00076     void threeToOne(const StoneBoard& brd, 
00077                     HexPoint dest, HexPoint p1, HexPoint p2, HexPoint p3);
00078 };
00079 
00080 inline std::string HandicapPlayer::Name() const
00081 {
00082     return "handicap";
00083 }
00084 
00085 //----------------------------------------------------------------------------
00086 
00087 _END_BENZENE_NAMESPACE_
00088 
00089 #endif // HEXHANDICAPPLAYER_HPP


6 Jan 2011 Doxygen 1.6.3