root/ggpa/QFunction.h

Revision 1, 2.6 kB (checked in by pantley2, 4 years ago)

GGPA code from the good old days of SIGART

Line 
1 /*
2  * QFunction.h
3  * Abstract class - do not implement
4  * This will be a superclass of a set of classes that will serve to represent
5  * the approximation to the Q-function for the Q-learning algorithm.  For
6  * example, we will have a table version, a neural network version, and a
7  * version that will use several neural networks, one for each action.
8  */
9
10 #ifndef QFUNCTION_H
11 #define QFUNCTION_H
12
13 #include <string>
14
15 #include "State.h"
16 #include "Action.h"
17
18 class QFunction {
19
20 private: 
21
22     // Declare any private variables here
23
24
25 public:
26
27    
28     virtual ~QFunction() {};
29
30
31     /*********************************************************************
32      * Do not modify these functions unless it is absolutely necessary.
33      * Any subclasses should implement these functions.
34      *********************************************************************/
35
36     /*
37      * update
38      * Parameters:   state - a State object that represents a state in the game
39      *               action - an Action object that represents an action in the
40      *                        game
41      *               utility - a double that represents the utility to insert
42      *                         for this State/Action pair
43      * No return value
44      *
45      * Updates the entry for the given State/Action pair.
46      */
47     virtual void update(State &state, Action &action, double utility) = 0;
48
49     /*
50      * getValue
51      * Parameters:   state - a State object that represents a state in the game
52      *               action - an Action object that represents an action in the
53      *                        game
54      * Return value: a double representing the utility of the given State/
55      *   Action pair.
56      * This function will return the current utility of the given State/Action
57      *   pair.  In other words, it will return a value representing how good
58      *   the action is from the state.
59      */
60     virtual double getValue(State &state, Action &action) = 0;
61
62     /*
63      * writeToFile
64      *
65      * Parameters:   file - String containing the name of the file to write to.
66      * Return value: none
67      *
68      * Writes the QFunction to the given file.  If the file does not exist, it
69      *   will be created.  If it does exist, then it will be written to the
70      *   end of the file
71      */
72     virtual void writeToFile(string filename) = 0;
73
74     /*
75      * readFromFile
76      *
77      * Parameters:   file - string containing the name of the file to read from
78      * Return value: none
79      *
80      * Reads in a QFunction from a file.  The current QFunction will be set to
81      *    be this saved QFunction
82      */
83     virtual void readFromFile(string filename) = 0;
84 };
85
86 #endif
87
Note: See TracBrowser for help on using the browser.