-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapproximate_q_learning.h
39 lines (30 loc) · 1.04 KB
/
approximate_q_learning.h
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
/*
Copyright (C) 2017 Meritxell Jordana
Copyright (C) 2017 Marc Sanchez
*/
#ifndef __APPROXIMATE_Q_LEARNING_H
#define __APPROXIMATE_Q_LEARNING_H
#include <map>
#include "map.h"
#include "strategy.h"
#include "reinforcement_agent.h"
using namespace std;
class ApproximateQLearning : public ReinforcementAgent {
std::map<QValuesKey, double> qvalues;
std::map<string, double> weights;
double getQValue(QValuesKey key);
void setQValue(QValuesKey &key, double newValue);
double computeValueFromQValues(Map &map);
Direction computeActionFromQValues(Map &map);
void update(QValuesKey &key, Map &nextState, double reward);
Direction getPolicy(Map &map);
double getValue(Map &map);
bool flipCoin(double p);
std::map<string, double> getFeatures(QValuesKey &key);
static void divideMapBy(std::map<string, double> &features, double divisor);
public:
ApproximateQLearning(Map *map, const double epsilon = 0.05,
const double alpha = 0.2, const double discount = 0.8);
Direction getAction();
};
#endif