00001
00002
00003 #ifndef _CATEGORYLISTUTIL_TCC
00004 #define _CATEGORYLISTUTIL_TCC
00005
00006 #include "osl/category/categoryListUtil.h"
00007 #include "osl/category/categoryUtil.h"
00008 #include "osl/move_classifier/moveAdaptor.h"
00009 #include "osl/move_classifier/safeMove.h"
00010 #include "osl/container/moveLogProbSet.h"
00011
00012 namespace osl
00013 {
00014 namespace category
00015 {
00016 template <class MoveSet>
00017 struct CategoryListUtilGatherAll
00018 {
00019 MoveSet *out;
00020 const NumEffectState& state;
00021 CategoryListUtilGatherAll(MoveSet *o, const NumEffectState& s)
00022 : out(o), state(s)
00023 {
00024 }
00025 template <bool is_king_escape>
00026 bool operator()(const char *,
00027 const MoveLogProbVector& moves)
00028 {
00029 for (MoveLogProbVector::const_iterator p=moves.begin();
00030 p!=moves.end(); ++p)
00031 {
00032 using namespace osl::move_classifier;
00033 const Move m = p->getMove();
00034 if (m.isPass() || m.isDrop()
00035 || PlayerMoveAdaptor<SafeMove>::isMember(state, m))
00036 {
00037 out->assignIfBetter(*p);
00038 }
00039 }
00040 const bool king_escape_generated = is_king_escape && (! moves.empty());
00041 return ! king_escape_generated;
00042 }
00043 };
00044 }
00045 }
00046
00047 template <typename Categories, typename MoveSet>
00048 void osl::category::CategoryListUtil::
00049 gatherAllMoves(const CategoryEnv& env, MoveSet& out)
00050 {
00051 forEachCategory(Categories(), env,
00052 CategoryListUtilGatherAll<MoveSet>(&out, *env.state));
00053 }
00054
00055 template <class Generator>
00056 void
00057 #ifdef __GNUC__
00058 __attribute__ ((noinline))
00059 #endif
00060 osl::category::CategoryListUtil::
00061 generate(const CategoryEnv& env, MoveLogProbVector& out)
00062 {
00063 boost::function_requires<category::CategoryConcept<Generator> >();
00064 CategoryUtil<Generator>::generate(env, out);
00065 }
00066
00067 #endif
00068
00069
00070
00071