00001 00005 #ifndef _SAVEDPOLICY_HH_ 00006 #define _SAVEDPOLICY_HH_ 00007 00008 #include <rl_common/Random.h> 00009 #include <rl_common/core.hh> 00010 00011 #include <map> 00012 #include <set> 00013 #include <vector> 00014 00016 class SavedPolicy: public Agent { 00017 public: 00021 SavedPolicy(int numactions, const char* filename); 00022 00023 virtual ~SavedPolicy(); 00024 00025 virtual int first_action(const std::vector<float> &s); 00026 virtual int next_action(float r, const std::vector<float> &s); 00027 virtual void last_action(float r); 00028 virtual void setDebug(bool d) {}; 00029 virtual void seedExp(std::vector<experience>); 00030 00031 void loadPolicy(const char* filename); 00032 00033 protected: 00037 typedef const std::vector<float> *state_t; 00038 00042 state_t canonicalize(const std::vector<float> &s); 00043 void printState(const std::vector<float> &s); 00044 00045 00046 private: 00050 std::set<std::vector<float> > statespace; 00051 00056 std::map<state_t, std::vector<float> > Q; 00057 00058 const int numactions; 00059 00060 bool ACTDEBUG; 00061 bool LOADDEBUG; 00062 bool loaded; 00063 00064 }; 00065 00066 #endif