Go to the documentation of this file.00001
00007 #ifndef _LIGHTWORLD_H_
00008 #define _LIGHTWORLD_H_
00009
00010 #include <set>
00011 #include <rl_common/Random.h>
00012 #include <rl_common/core.hh>
00013
00014
00015 class LightWorld: public Environment {
00016 public:
00022 LightWorld(Random &rand, bool stochastic, int nrooms);
00023
00024 virtual ~LightWorld();
00025
00026 virtual const std::vector<float> &sensation() const;
00027 virtual float apply(int action);
00028
00029 virtual bool terminal() const;
00030 virtual void reset();
00031 virtual int getNumActions();
00032 virtual void getMinMaxFeatures(std::vector<float> *minFeat, std::vector<float> *maxFeat);
00033 virtual bool isEpisodic() { return false; };
00034 virtual void getMinMaxReward(float* minR, float* maxR);
00035
00036
00037 friend std::ostream &operator<<(std::ostream &out, const LightWorld &playroom);
00038
00039
00040 void resetKey();
00041 void setKey(std::vector<float> testS);
00042
00043 struct room_info {
00044 int height;
00045 int width;
00046 int key_ns;
00047 int key_ew;
00048 int lock_ns;
00049 int lock_ew;
00050 int door_ns;
00051 int door_ew;
00052 };
00053
00054 typedef std::pair<float,float> coord_t;
00055 enum lightworld_action_t {NORTH, EAST, WEST, SOUTH, PICKUP, PRESS, NUM_ACTIONS};
00056
00057 bool LWDEBUG;
00058
00059 const bool noisy;
00060 int nrooms;
00061 Random &rng;
00062
00063 std::vector<float> s;
00064 float& ns;
00065 float& ew;
00066 float& have_key;
00067 float& door_open;
00068 float& room_id;
00069 float& key_n;
00070 float& key_e;
00071 float& key_w;
00072 float& key_s;
00073 float& lock_n;
00074 float& lock_e;
00075 float& lock_w;
00076 float& lock_s;
00077 float& door_n;
00078 float& door_e;
00079 float& door_w;
00080 float& door_s;
00081
00082 std::vector<room_info> rooms;
00083
00084 void updateSensors();
00085 int applyNoise(int action);
00086
00088 void print_state() const;
00089
00091 void print_map() const;
00092
00093 void updateVisits();
00094
00095 int totalVisited;
00096 int keyVisited;
00097 int lockVisited;
00098 int doorVisited;
00099 int haveKey;
00100 int doorOpen;
00101 int leaveRoom;
00102 int pressKey;
00103 int pressLockCorrect;
00104 int pressLockIncorrect;
00105 int pressDoor;
00106 int pressOther;
00107 int pickupKeyCorrect;
00108 int pickupKeyIncorrect;
00109 int pickupLock;
00110 int pickupDoor;
00111 int pickupOther;
00112
00113 int MAX_SENSE;
00114
00115 };
00116
00117 #endif