Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SpDumbTacticalPlayer.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file SpDumbTacticalPlayer.h
00003     Dumb tactical player
00004 */
00005 //----------------------------------------------------------------------------
00006 
00007 #ifndef SP_DUMBTACTICALPLAYER_H
00008 #define SP_DUMBTACTICALPLAYER_H
00009 
00010 #include "SpSimplePlayer.h"
00011 #include "SpMoveGenerator.h"
00012 
00013 //----------------------------------------------------------------------------
00014 
00015 /** Plays mostly to extend/reduce liberties.
00016     Plays the following, in priority order:
00017     1. If own group has single liberty, play there
00018     2. Amongst opponent groups without two eyes, find the one with the least
00019        libs, and fill the one with the most second order liberties. If there
00020        is a tie pick one at random.
00021     3. Make a random move that doesn't fill own eye
00022     4. Pass
00023 */
00024 class SpDumbTacticalMoveGenerator
00025     : public SpStaticMoveGenerator
00026 {
00027 public:
00028     explicit SpDumbTacticalMoveGenerator(GoBoard& board);
00029     
00030     virtual void GenerateMoves(SgEvaluatedMoves& eval, SgBlackWhite toPlay);
00031 
00032     virtual bool ExecuteMoveForScoring()
00033     {
00034         return false;
00035     }
00036 
00037     virtual int Score(SgPoint p);
00038 
00039 private:
00040     bool m_useLadders;
00041     
00042     void GenerateAttackMoves(SgEvaluatedMoves& eval);
00043 
00044     void GenerateDefendMoves(SgEvaluatedMoves& eval);
00045 };
00046 
00047 //----------------------------------------------------------------------------
00048 
00049 /** A SpSimplePlayer using the SpDumbTacticalMoveGenerator */
00050 class SpDumbTacticalPlayer
00051     : public SpSimplePlayer
00052 {
00053 public:
00054     SpDumbTacticalPlayer(GoBoard& board)
00055         : SpSimplePlayer(board, new SpDumbTacticalMoveGenerator(board))
00056     { }
00057     
00058     std::string Name() const
00059     {
00060         return "DumbTactical";
00061     }
00062 };
00063 
00064 //----------------------------------------------------------------------------
00065 
00066 #endif // SP_DUMBTACTICALPLAYER_H
00067 


17 Jun 2010 Doxygen 1.4.7