1 /*
2  * Modification History
3  *
4  * 2006-September-28   Jason Rohrer
5  * Created.
6  *
7  * 2006-October-4   Jason Rohrer
8  * Fixed rapid-fire gift bug.
9  *
10  * 2006-October-10   Jason Rohrer
11  * Added a limit on maximum plot size.
12  */
13 
14 
15 
16 #ifndef GARDENER_AI_2_INCLUDED
17 #define GARDENER_AI_2_INCLUDED
18 
19 
20 #include "Gardener.h"
21 #include "World.h"
22 
23 
24 #define NUM_GARDENER_TASKS   13
25 
26 enum GardenerTask{
27     task_none = 0,  // need to pick a new task
28     task_water,
29     task_harvest,
30     task_eat,
31     task_createPlot,
32     task_abandonPlot,
33     task_plant,
34     task_expandPlot,
35     task_capturePlant,
36     task_poisonPlant,
37     task_giveGift,
38     task_mate,
39     task_rest };
40 
41 
42 
43 /**
44  * Artificial intelligence control for a gardener.
45  *
46  * @author Jason Rohrer
47  */
48 class GardenerAI {
49 
50     public:
51 
52 
53 
54         /**
55          * Constructs an AI.
56          *
57          * All params must be destroyed by caller after this AI is destroyed.
58          *
59          * @param inGardener the gardener to control
60          * @param inWorld the world the gardener is in.
61          */
62         GardenerAI( Gardener *inGardener, World *inWorld );
63 
64 
65 
66         ~GardenerAI();
67 
68 
69 
70         /**
71          * Passes time for this AI.
72          *
73          * @param inTimeDeltaInSeconds the amount of time that has passed.
74          */
75         void passTime( double inTimeDeltaInSeconds );
76 
77 
78 
79     private:
80 
81         Gardener *mGardener;
82         World *mWorld;
83 
84 
85         Vector3D *mNextPlantingLocation;
86         Vector3D *mNextPlotLocation;
87 
88 
89         double mSecondsSinceLastGift;
90 
91         double mCurrentRestTime;
92         double mMaxRestTime;
93 
94 
95         GardenerTask mCurrentTask;
96 
97 
98         /**
99          * Gets the closest plant in inGardener's plot that is not
100          * on our gardener's plot.
101          *
102          * Both parameter and return value are managed and destroyed by
103          * mWorld.
104          *
105          * @param inGardener the gardener to look at.
106          *
107          * @return the plant in inGardener's plot, or NULL if no
108          *   such plant exists.
109          */
110         Plant *getClosestPlantInGardenerPlot( Gardener *inGardener );
111 
112 
113 
114         /**
115          * Gets the driest plant in inGardener's plot.
116          *
117          * @return the plant in inGardener's plot, or NULL if no
118          *   such plant exists.  Managed by mWorld
119          */
120         Plant *getDriestPlant();
121 
122 
123 
124         /**
125          * Expands our plot in the world so that inPlant is contained.
126          *
127          * @param inPlant the plant to contain.  Managed by world.
128          *
129          * @return true if expansion successful, or false if expanding
130          *   our plot to contain inPlant would make our plot too big.
131          */
132         char expandOurPlotToContainPlant( Plant *inPlant );
133 
134 
135 
136     };
137 
138 
139 
140 #endif
141