root/ggpa/Table.h

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

GGPA code from the good old days of SIGART

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