16 using Index = uint16_t;
17 constexpr static const Index IndexNone = std::numeric_limits<Index>::max();
19 using CacheRef = uint32_t;
23 Result(Reward r,
bool ok,
bool t =
false) : R(r), Success(ok), Termination(t) { }
24 bool operator<(
const Result&)
const;
25 bool operator>(
const Result &that)
const {
return that < *
this; }
26 bool operator==(
const Result&)
const;
27 std::string str()
const;
31 bool Termination{
false};
34 Action(
const std::string &name, uint index = std::numeric_limits<Index>::max()) : mName(name), mIndex(index) { }
37 const std::string& name()
const {
return mName; }
38 Index index()
const {
return mIndex; }
39 bool legal()
const {
return mLegal; }
41 virtual Result performAs(Agent& context, PyObject *arg = 0) {
return Result(); }
43 virtual void clearCache(CacheRef = 0) { }
44 virtual Result performAs(Agent& context, PyObject *arg, CacheRef) {
return performAs(context); }
46 virtual Result undoAs(Agent&);
47 Action *getUndo()
const {
return mUndo; }
49 void setUndo(Action *A) { mUndo = A; }
50 void setIndex(Index a) { mIndex = a; }
51 void setLegal(
bool b) { mLegal = b; }
53 void setActionCountIncrement(uint n) { mActionCountIncrement = n; }
55 virtual PyObject *getPy()
const;
58 uint mActionCountIncrement{1};
60 const std::string mName;
61 Index mIndex{std::numeric_limits<Index>::max()};