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