00001 #ifndef __LERNEN_H__ 00002 #define __LERNEN_H__ 00003 00004 #include "Controller.h" 00005 #include "FeedbackSensor.h" 00006 00007 00008 // functions and constants for PRNG 00009 #define PMRAND_MIN 1 // Min. output 00010 #define PMRAND_MAX 2147483647 // Max. output 00011 #define a 48271 00012 #define m 2147483647 00013 #define q (m / a) 00014 #define r (m % a) 00015 00016 class ValueIteration { 00017 00018 public: 00019 void init(); 00020 void exploreAllFeedbacks(bool wait5Seconds); 00021 char moveAndSaveFeedback (unsigned char _action, bool _activateRandomMoving); 00022 void valueIterateAllStates(); 00023 unsigned long int getIterationCount(); 00024 signed long int getDistanceCovered(); 00025 void resetDistanceCounter(); 00026 unsigned char getGreedyAction(unsigned char _row, unsigned char _column); 00027 00029 Controller ctr; 00030 00031 float gamma; 00032 float expParameter; 00033 unsigned char expMode; 00034 float currentExpProbability; 00035 00036 double oldValue; 00037 double newValue; 00038 00039 private: 00040 00041 bool isValidAction(unsigned char _row, unsigned char _column, unsigned char _aktion); 00042 float evaluateAction (unsigned char _row, unsigned char _column, unsigned char _action); 00043 unsigned short get_seed(); 00044 unsigned char getRandomAction(); 00045 bool doExploration(void); 00046 00047 unsigned char random_byte; 00048 unsigned long int iteration; 00049 signed long int distanceCovered; 00050 void gotoRandomState(); 00051 00053 FeedbackSensor fb; 00054 }; 00055 00056 #endif