moveAdaptor.h
Go to the documentation of this file.
00001 /* moveAdaptor.h
00002  */
00003 #ifndef OSL_MOVE_CLASSIFIER_MOVE_ADAPTOR_H
00004 #define OSL_MOVE_CLASSIFIER_MOVE_ADAPTOR_H
00005 
00006 #include "osl/state/numEffectState.h"
00007 #include "osl/move_classifier/classifierTraits.h"
00008 namespace osl
00009 {
00010   namespace move_classifier
00011   {
00012     template <class Classifier>
00013     struct MoveAdaptor
00014     {
00015       static bool isMember(const NumEffectState& state, Move m) 
00016       {
00017         return Classifier::isMember(state, m.ptype(), m.from(), m.to());
00018       }
00019     };
00020 
00021     template <template <Player> class Classifier>
00022     struct PlayerMoveAdaptor
00023     {
00024       template <class State>
00025       static bool isMember(const State& state, Move m) 
00026       {
00027         assert(m.player() == state.turn());
00028         if (state.turn() == BLACK)
00029           return Classifier<BLACK>::isMember(state, m.ptype(), m.from(), m.to());
00030         else
00031           return Classifier<WHITE>::isMember(state, m.ptype(), m.from(), m.to());
00032       }
00033     };
00034 
00036     template <template <Player> class Classifier>
00037     struct ConditionAdaptor
00038     {
00039       template <class State>
00040       static bool isMember(const State& state, Move m) 
00041       {
00042         if (! ClassifierTraits<Classifier<BLACK> >::drop_suitable
00043             && m.isDrop())
00044           return ClassifierTraits<Classifier<BLACK> >::result_if_drop;
00045         return PlayerMoveAdaptor<Classifier>::isMember(state, m);
00046       }
00047     };
00048   } // namespace move_classifier
00049 } // namespace osl
00050 
00051 #endif /* OSL_MOVE_CLASSIFIER_MOVE_ADAPTOR_H */
00052 // ;;; Local Variables:
00053 // ;;; mode:c++
00054 // ;;; c-basic-offset:2
00055 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines