root/ggpa/QNeuralNetwork.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  * QNeuralNetwork.h
3  * Contains neural network wrapper.
4  */
5
6 #ifndef QNEURALNETWORK_H
7 #define QNEURALNETWORK_H
8
9 #include <string>
10
11 #include "State.h"
12 #include "Action.h"
13 #include "QFunction.h"
14
15 //#include "fann/fixedfann.h"
16 #include "fann/fann.h"
17
18 class QNeuralNetwork : public QFunction {
19
20 private: 
21
22     // Declare any private variables here
23
24     struct fann *_ann;
25
26     int _actionLength, _stateLength;
27
28     const int NUM_HIDDEN_NEURONS;
29
30
31 public:
32
33    
34     QNeuralNetwork();
35     ~QNeuralNetwork();
36
37     QNeuralNetwork operator=(const QNeuralNetwork &theNetwork);
38
39     /*
40      * QNeuralNetwork
41      * Parameters:   actionLength - max length on action.toInputs()
42      *               stateLength - max length on state.toInputs()
43      *
44      * Constructor. Creates a neural network.
45      */
46     QNeuralNetwork(int actionLength, int stateLength);
47
48     /*
49      * update
50      * Parameters:   state - a State object that represents a state in the game
51      *               action - an Action object that represents an action in the
52      *                        game
53      *               utility - a double that represents the utility to insert
54      *                         for this State/Action pair
55      * No return value
56      *
57      * Updates the entry for the given State/Action pair.
58      */
59     void update(State &state, Action &action, double utility);
60
61     /*
62      * getValue
63      * Parameters:   state - a State object that represents a state in the game
64      *               action - an Action object that represents an action in the
65      *                        game
66      * Return value: a double representing the utility of the given State/
67      *   Action pair.
68      * This function will return the current utility of the given State/Action
69      *   pair.  In other words, it will return a value representing how good
70      *   the action is from the state.
71      */
72     double getValue(State &state, Action &action);
73
74     /*
75      * writeToFile
76      *
77      * Parameters:   file - String containing the name of the file to write to.
78      * Return value: none
79      *
80      * Writes the QNeuralNetwork to the given file.  If the file does not exist, it
81      *   will be created.  If it does exist, then it will be written to the
82      *   end of the file
83      */
84     void writeToFile(string filename);
85
86     /*
87      * readFromFile
88      *
89      * Parameters:   file - string containing the name of the file to read from
90      * Return value: none
91      *
92      * Reads in a QNeuralNetwork from a file.  The current QNeuralNetwork will be set to
93      *    be this saved QNeuralNetwork
94      */
95     void readFromFile(string filename);
96 };
97
98 #endif
99
Note: See TracBrowser for help on using the browser.