/usr/include/osl/rating/group.h is in libosl-dev 0.6.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | /* group.h
*/
#ifndef _GROUP_H
#define _GROUP_H
#include "osl/rating/feature.h"
#include "osl/rating/range.h"
#include "osl/stl/vector.h"
#include <boost/ptr_container/ptr_vector.hpp>
namespace osl
{
namespace rating
{
/** mutually exclusive set of features */
class Group : public boost::ptr_vector<Feature>
{
public:
std::string group_name;
Group(const std::string& name);
Group(Feature *f) : group_name(f->name()) { push_back(f); }
virtual ~Group();
virtual void show(std::ostream&, int name_width, const range_t& range,
const vector<double>& weights) const;
/** @return -1 if not found */
virtual int findMatch(const NumEffectState& state, Move m, const RatingEnv& env) const;
void showMinMax(std::ostream& os, int name_width, const range_t& range,
const vector<double>& weights) const;
void showAll(std::ostream& os, int name_width, const range_t& range,
const vector<double>& weights) const;
void showTopN(std::ostream& os, int name_width, const range_t& range,
const vector<double>& weights, int n) const;
void saveResult(const std::string& directory, const range_t& range,
const vector<double>& weights) const;
bool load(const std::string& directory, const range_t& range,
vector<double>& weights) const;
virtual bool effectiveInCheck() const { return (*this)[0].effectiveInCheck(); }
};
struct TakeBackGroup : public Group
{
TakeBackGroup() : Group("TakeBack")
{
push_back(new TakeBack());
push_back(new TakeBack2());
}
#ifndef MINIMAL
void show(std::ostream& os, int name_width, const range_t& range,
const vector<double>& weights) const
{
showAll(os, name_width, range, weights);
}
#endif
int findMatch(const NumEffectState&, Move move, const RatingEnv& env) const
{
const Square to = move.to();
if (! env.history.hasLastMove() || env.history.lastMove().to() != to)
return -1;
if (! env.history.hasLastMove(2) || env.history.lastMove(2).to() != to)
return 0;
return 1;
}
bool effectiveInCheck() const { return true; }
};
struct CheckGroup : public Group
{
CheckGroup() : Group("Check")
{
for (int i=0; i<4; ++i)
for (int p=0; p<8; ++p) // progress8
push_back(new Check(i));
}
void show(std::ostream& os, int name_width, const range_t& range,
const vector<double>& weights) const
{
showAll(os, name_width, range, weights);
}
int findMatch(const NumEffectState& state, Move move, const RatingEnv& env) const
{
using namespace osl::move_classifier;
const bool direct = PlayerMoveAdaptor<osl::move_classifier::DirectCheck>::isMember(state, move);
const bool open = ConditionAdaptor<osl::move_classifier::OpenCheck>::isMember(state, move);
int index = -1;
if (direct && !open)
index = Check::openLong(state, move);
else if (open)
index = direct + 2;
const int progress8 = env.progress.value()/2;
return index*8 + progress8;
}
bool effectiveInCheck() const { return true; }
};
class SendOffGroup : public Group
{
public:
SendOffGroup() : Group("SendOff")
{
for (int p=0; p<8; ++p) // progress8
push_back(new SendOff(0));
for (int p=0; p<8; ++p) // progress8
push_back(new SendOff(1));
}
void show(std::ostream& os, int name_width, const range_t& range,
const vector<double>& weights) const
{
showAll(os, name_width, range, weights);
}
int findMatch(const NumEffectState&, Move move, const RatingEnv& env) const
{
if (! env.sendoffs.isMember(move.to()))
return -1;
const int progress8 = env.progress.value()/2;
return (move.capturePtype() != PTYPE_EMPTY)*8 + progress8;
}
};
struct BlockGroup : public Group
{
BlockGroup() : Group("Block")
{
for (int s=0; s<=3; ++s) {
for (int o=0; o<=3; ++o) {
push_back(new Block(s, o));
}
}
}
void show(std::ostream& os, int name_width, const range_t& range,
const vector<double>& weights) const
{
showAll(os, name_width, range, weights);
}
int findMatch(const NumEffectState& state, Move move, const RatingEnv& ) const
{
const int index = Block::count(state, move.to(), state.turn())*4
+ Block::count(state, move.to(), alt(state.turn()));
return index;
}
bool effectiveInCheck() const { return true; }
};
struct OpenGroup : public Group
{
OpenGroup() : Group("Open")
{
for (int i=0; i<16; ++i)
push_back(new Open(i));
}
void show(std::ostream& os, int name_width, const range_t& range,
const vector<double>& weights) const
{
showTopN(os, name_width, range, weights, 3);
}
int findMatch(const NumEffectState& state, Move move, const RatingEnv& ) const
{
const int index = Open::index(state, move);
return index;
}
bool effectiveInCheck() const { return true; }
};
struct ChaseGroup : public Group
{
ChaseGroup();
void show(std::ostream& os, int name_width, const range_t& range,
const vector<double>& weights) const
{
showTopN(os, name_width, range, weights, 3);
}
int findMatch(const NumEffectState& state, Move move, const RatingEnv& env) const;
};
struct KaranariGroup : public Group
{
KaranariGroup();
void show(std::ostream& os, int name_width, const range_t& range,
const vector<double>& weights) const
{
showAll(os, name_width, range, weights);
}
int findMatch(const NumEffectState& state, Move move, const RatingEnv&) const;
};
struct ImmediateAddSupportGroup : public Group
{
ImmediateAddSupportGroup();
void show(std::ostream& os, int name_width, const range_t& range,
const vector<double>& weights) const
{
showTopN(os, name_width, range, weights, 3);
}
int findMatch(const NumEffectState& state, Move move, const RatingEnv& env) const
{
const int index = ImmediateAddSupport::index(state, move, env);
if (index < 0)
return index;
const int progress8 = env.progress.value()/2;
return index*8 + progress8;
}
};
struct BadLanceGroup : public Group
{
BadLanceGroup() : Group("BadLance")
{
push_back(new BadLance(false));
push_back(new BadLance(true));
}
void show(std::ostream& os, int name_width, const range_t& range,
const vector<double>& weights) const
{
showAll(os, name_width, range, weights);
}
int findMatch(const NumEffectState& state, Move move, const RatingEnv&) const
{
const Square front = Board_Table.nextSquare(move.player(), move.to(), U);
if (! BadLance::basicMatch(state, move, front))
return -1;
const int index = state.hasEffectAt(alt(move.player()), front);
return index;
}
};
struct PawnAttackGroup : public Group
{
PawnAttackGroup() : Group("PawnAttack")
{
for (int p=0; p<8; ++p) // progress8
push_back(new PawnAttack());
}
void show(std::ostream& os, int name_width, const range_t& range,
const vector<double>& weights) const
{
showAll(os, name_width, range, weights);
}
int findMatch(const NumEffectState& state, Move move, const RatingEnv& env) const
{
if (! (*this)[0].match(state, move, env))
return -1;
const int progress8 = env.progress.value()/2;
return progress8;
}
};
}
}
#endif /* _GROUP_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|