root/ggpa/State.h

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

GGPA code from the good old days of SIGART

Line 
1 /*
2  * State.h
3  *
4  * Header file for State class
5  *
6  */
7
8 #ifndef STATE_H
9 #define STATE_H
10
11 #define ZERO_VALUE 0.0
12 #define ONE_VALUE 1.0
13
14 #include <vector>
15 #include "Sentence.h"
16 using namespace std;
17
18 /*
19  * This class of objects will hold a single state of a game
20  */
21 class State {
22
23 private:
24     vector<double> values;
25
26 public:
27     State();
28
29     /*
30      * State
31      * One argument constructor
32      * Parameters: size - an int that represents the number of attributes in a
33      *                    state
34      * Creates a new, empty state with the given number of attributes.
35      */
36     State(int size);
37
38     State(const State &state);
39
40     int operator=(const State &state);
41
42     bool operator==(const State &state) const;
43
44     bool operator<(const State& state) const;
45
46     /******************************************************************
47      * add and remove functions
48      */
49
50     /*
51      * addSentence
52      * Parameters: sentence - the sentence to add
53      * No return type
54      * Adds the parameter sentence to the State.  This means that the sentence
55      * is true in the current state of the game.  If the sentence is an action
56      * it can not be added to a State, and thus this function will terminate
57      * with an error message
58      */
59     void addSentence(const Sentence* sentence);
60
61
62     /******************************************************************
63      * These two functions will be required for using the State with a
64      *    neural network.  Do not change their signatures unless absolutely
65      *    necessary.
66      */
67
68     /*
69      * toInputs
70      *
71      * Parameters:   None
72      * Return value: A const reference to a vector of doubles, each between 0
73      * and 1
74      *
75      * This function converts a state to an vector of doubles, each between 0
76      * and 1.  This array will be the same size for all States, and it will
77      * always be the same for a specific State
78      */
79     const vector<double>& toInputs() const;
80
81     /*
82      * containsSentence
83      * Parameters: sentence - a const Sentence* to look for in the state
84      * Return type: bool
85      * Returns true if the Sentence is set in this state, and false otherwise
86      */
87     bool containsSentence(const Sentence* sentence) const;
88
89     /*
90      * getSize
91      * No parameters
92      * returns the number of values in the state
93      */
94     unsigned int getSize() const;
95
96     /*
97      * Prints the values for this state.
98      *
99      */
100     void print() const;
101
102 };
103
104 #endif
105
Note: See TracBrowser for help on using the browser.