00001 /* capture.h 00002 */ 00003 #ifndef _CAPTURE_H 00004 #define _CAPTURE_H 00005 00006 #include "osl/category/categoryEnv.h" 00007 #include "osl/category/categoryTraits.h" 00008 #include "osl/category/probTable.h" 00009 #include "osl/move_classifier/trapRook.h" 00010 #include "osl/move_classifier/moveAdaptor.h" 00011 #include "osl/container/moveStack.h" 00012 #include <boost/static_assert.hpp> 00013 00014 namespace osl 00015 { 00016 namespace category 00017 { 00022 template <Ptype PTYPE> 00023 struct Capture : public StandardProbabilityCategory 00024 { 00025 static Interpolator<PieceValueTable> probTable; 00026 BOOST_STATIC_ASSERT(PtypeTraits<PTYPE>::isBasic); // ȴ 00027 static const char *getName(); 00028 static bool isInCategory(const CategoryEnv& /*env*/, Move move) 00029 { 00030 const Ptype target = move.capturePtype(); 00031 return (target != PTYPE_EMPTY) && (unpromote(target) == PTYPE); 00032 } 00033 static void generate(const CategoryEnv& env, MoveVector& out); 00034 }; 00035 00039 struct ContinueCapture : public StandardProbabilityCategory 00040 { 00041 static Interpolator<PieceValueTable> probTable; 00042 static const char *getName() { return "ContinueCapture"; } 00043 static bool isEffective(const CategoryEnv& env) 00044 { 00045 return env.history->lastMove(2).isNormal(); 00046 } 00047 static bool isInCategory(const CategoryEnv& env, Move move) 00048 { 00049 if (! isEffective(env)) 00050 return false; 00051 const Move last_last_move=env.history->lastMove(2); 00052 assert(last_last_move.isNormal()); 00053 return (move.from() == last_last_move.to()) 00054 && (move.capturePtype() != PTYPE_EMPTY); 00055 } 00056 struct PositionAction; 00057 static void generate(const CategoryEnv& env, MoveVector& out); 00058 }; 00059 00063 struct TrapRook : public FixedProbabilityCategory 00064 { 00065 static FixedValueTable probTable; 00066 static const char *getName() { return "TrapRook"; } 00067 static bool isInCategory(const CategoryEnv& env, Move move) 00068 { 00069 using move_classifier::PlayerMoveAdaptor; 00070 return PlayerMoveAdaptor<move_classifier::TrapRook>:: 00071 isMember(*env.state, move); 00072 } 00073 }; 00074 00075 } // namespace category 00076 } // namespace osl 00077 00078 #endif /* _CAPTURE_H */ 00079 // ;;; Local Variables: 00080 // ;;; mode:c++ 00081 // ;;; c-basic-offset:2 00082 // ;;; End: