説明を見る。00001
00002
00003 #ifndef _PINGROUP_H
00004 #define _PINGROUP_H
00005
00006 #include "osl/rating/group.h"
00007 #include "osl/rating/feature/pinAttack.h"
00008
00009 namespace osl
00010 {
00011 namespace rating
00012 {
00013 struct PinGroup : public Group
00014 {
00015 PinGroup() : Group("PinAttack")
00016 {
00017 for (int s = PTYPE_PIECE_MIN; s<= PTYPE_MAX; ++s) {
00018 for (int t = PTYPE_PIECE_MIN; t<= PTYPE_MAX; ++t) {
00019 const Ptype self = static_cast<Ptype>(s);
00020 const Ptype target = static_cast<Ptype>(t);
00021 for (int p=0; p<8; ++p)
00022 push_back(new PinAttack(true, self, target));
00023 for (int p=0; p<8; ++p)
00024 push_back(new PinAttack(false, self, target));
00025 }
00026 }
00027 }
00028 void show(std::ostream& os, int name_width, const range_t& range,
00029 const std::vector<double>& weights) const
00030 {
00031 showTopN(os, name_width, range, weights, 3);
00032 }
00033 int findMatch(const NumEffectState& state, Move move, const RatingEnv& env) const
00034 {
00035 const int progress8 = env.progress.value()/2;
00036 const int attack_index = PinAttack::index(state, move, env, true);
00037 if (attack_index >= 0)
00038 return attack_index*8 + progress8;
00039 const int defense_index = PinAttack::index(state, move, env, false);
00040 if (defense_index >= 0)
00041 return defense_index*8 + progress8;
00042 return -1;
00043 }
00044 };
00045
00046 struct EscapePinGroup : public Group
00047 {
00048 EscapePinGroup() : Group("EscapePin")
00049 {
00050 for (int s = PTYPE_BASIC_MIN+1; s<= PTYPE_MAX; ++s) {
00051 const Ptype self = static_cast<Ptype>(s);
00052 for (int p=0; p<8; ++p)
00053 push_back(new EscapePin(self));
00054 }
00055 }
00056 void show(std::ostream& os, int name_width, const range_t& range,
00057 const std::vector<double>& weights) const
00058 {
00059 showTopN(os, name_width, range, weights, 3);
00060 }
00061 int findMatch(const NumEffectState&, Move move, const RatingEnv& env) const
00062 {
00063 if (move.ptype() != KING || ! env.my_pin.any())
00064 return -1;
00065 int s;
00066 for (s = PTYPE_BASIC_MIN+1; s<= PTYPE_MAX; ++s) {
00067 const Ptype pinned = static_cast<Ptype>(s);
00068 if ((env.my_pin.getMask(Ptype_Table.getIndex(pinned))
00069 & Ptype_Table.getMaskLow(pinned)).any())
00070 break;
00071 }
00072 s -= PTYPE_BASIC_MIN+1;
00073 assert(s >= 0);
00074 const int progress8 = env.progress.value()/2;
00075 return s*8 + progress8;
00076 }
00077 };
00078 }
00079 }
00080
00081
00082 #endif
00083
00084
00085
00086