| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
#include "structures.h" |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
#include <time.h> |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
#include <qapplication.h> |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
void getAuthorInput(QApplication &app); |
|---|
| 22 |
void direct(QApplication &app); |
|---|
| 23 |
void MakeOps(); |
|---|
| 24 |
|
|---|
| 25 |
DirectorForm_impl *dfi = NULL; |
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
void main() |
|---|
| 32 |
{ |
|---|
| 33 |
|
|---|
| 34 |
int argc = 0; |
|---|
| 35 |
QApplication app(argc, NULL); |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
conn = mysql_init(conn); |
|---|
| 39 |
conn = mysql_real_connect(conn, "128.174.252.116", "deus", |
|---|
| 40 |
"DeusExMachina", "deus", 0, NULL, 0); |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
getAuthorInput(app); |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
real_world = new World(); |
|---|
| 47 |
real_world->Locations = MapGenerator(); |
|---|
| 48 |
real_world->map_height = GetMapSize().first; |
|---|
| 49 |
real_world->map_width = GetMapSize().second; |
|---|
| 50 |
|
|---|
| 51 |
MakeOps(); |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
direct(app); |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
mysql_close(conn); |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
void getAuthorInput(QApplication &app) |
|---|
| 66 |
{ |
|---|
| 67 |
AuthorForm_impl f(NULL, "author_form"); |
|---|
| 68 |
QObject::connect(&app, SIGNAL(lastWindowClosed()), &f, SLOT(closing())); |
|---|
| 69 |
|
|---|
| 70 |
f.show(); |
|---|
| 71 |
while (!f.is_closing) app.processEvents(); |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|
| 74 |
void direct(QApplication &app) |
|---|
| 75 |
{ |
|---|
| 76 |
DirectorForm_impl f(NULL, "director_form"); |
|---|
| 77 |
dfi = &f; |
|---|
| 78 |
QObject::connect(&app, SIGNAL(lastWindowClosed()), &f, SLOT(shuttingDown())); |
|---|
| 79 |
QObject::connect(&app, SIGNAL(aboutToQuit()), &f, SLOT(shuttingDown())); |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
QBoxLayout *layout = new QVBoxLayout((QWidget *)f.ForwardFrame, 5); |
|---|
| 88 |
PlanGraphDisplay *f_gd = new PlanGraphDisplay(forward_root, (QWidget*)f.ForwardFrame); |
|---|
| 89 |
layout->addWidget(f_gd); |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
QBoxLayout *rlayout = new QVBoxLayout((QWidget *)f.RegressionFrame, 5); |
|---|
| 93 |
PlanGraphDisplay *r_gd = new PlanGraphDisplay(regression_root, (QWidget*)f.RegressionFrame); |
|---|
| 94 |
rlayout->addWidget(r_gd); |
|---|
| 95 |
|
|---|
| 96 |
f.show(); |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
for (int i = 0; i < 50; i++) |
|---|
| 191 |
{ |
|---|
| 192 |
NPC n; |
|---|
| 193 |
|
|---|
| 194 |
n.name = "npc"; |
|---|
| 195 |
|
|---|
| 196 |
n.xcoord = 300 * (rand()/(double)RAND_MAX); |
|---|
| 197 |
n.ycoord = 300 * (rand()/(double)RAND_MAX); |
|---|
| 198 |
|
|---|
| 199 |
n.attributes.insert(std::pair<string,int>("Hunger", 100*(rand()/(double)RAND_MAX))); |
|---|
| 200 |
n.attributes.insert(std::pair<string,int>("Occupation", 20*(rand()/(double)RAND_MAX))); |
|---|
| 201 |
n.attributes.insert(std::pair<string,int>("Drunk", 100*(rand()/(double)RAND_MAX))); |
|---|
| 202 |
n.attributes.insert(std::pair<string,int>("Thirst", 10*(rand()/(double)RAND_MAX))); |
|---|
| 203 |
n.attributes.insert(std::pair<string,int>("Money", 10000*(rand()/(double)RAND_MAX))); |
|---|
| 204 |
n.attributes.insert(std::pair<string,int>("Morality", 10*(rand()/(double)RAND_MAX))); |
|---|
| 205 |
n.attributes.insert(std::pair<string,int>("Fatigue", 10*(rand()/(double)RAND_MAX))); |
|---|
| 206 |
|
|---|
| 207 |
real_world->NPCs.push_back(n); |
|---|
| 208 |
} |
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 |
bool success = true, complete = false; |
|---|
| 213 |
StoryTracer tracer; |
|---|
| 214 |
while (story_root && !f.shutting_down && !complete) |
|---|
| 215 |
{ |
|---|
| 216 |
forward_search(0 ); |
|---|
| 217 |
f_gd->root = forward_root; f_gd->fit(); |
|---|
| 218 |
app.processEvents(); |
|---|
| 219 |
complete = tracer.Trace(success); |
|---|
| 220 |
r_gd->root = regression_root; r_gd->fit(); |
|---|
| 221 |
app.processEvents(); |
|---|
| 222 |
|
|---|
| 223 |
|
|---|
| 224 |
success = false; |
|---|
| 225 |
app.processEvents(); |
|---|
| 226 |
} |
|---|
| 227 |
} |
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
void MakeOps() |
|---|
| 231 |
{ |
|---|
| 232 |
Operator OP; |
|---|
| 233 |
|
|---|
| 234 |
|
|---|
| 235 |
for(int i=0; i<NUM_COND; i++) |
|---|
| 236 |
{ |
|---|
| 237 |
for(int j=0; j<NUM_COND; j++) |
|---|
| 238 |
{ |
|---|
| 239 |
((OP.PreConds).conditions)[i][j]=""; |
|---|
| 240 |
((OP.PostConds).conditions)[i][j]=""; |
|---|
| 241 |
} |
|---|
| 242 |
} |
|---|
| 243 |
((OP.PreConds).conditions)[0][0]="npc"; |
|---|
| 244 |
((OP.PostConds).conditions)[0][0]="npc"; |
|---|
| 245 |
((OP.PostConds).conditions)[1][0]="attrib value"; |
|---|
| 246 |
OP.code=OP_CHANGEATTRIBUTE; |
|---|
| 247 |
Ops.push_back(OP); |
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
for(i=0; i<NUM_COND; i++) |
|---|
| 251 |
{ |
|---|
| 252 |
for(int j=0; j<NUM_COND; j++) |
|---|
| 253 |
{ |
|---|
| 254 |
((OP.PreConds).conditions)[i][j]=""; |
|---|
| 255 |
((OP.PostConds).conditions)[i][j]=""; |
|---|
| 256 |
} |
|---|
| 257 |
} |
|---|
| 258 |
((OP.PreConds).conditions)[0][0]="npc"; |
|---|
| 259 |
((OP.PostConds).conditions)[0][0]="npc"; |
|---|
| 260 |
((OP.PostConds).conditions)[1][0]="xloc yloc"; |
|---|
| 261 |
OP.code=OP_MOVENPC; |
|---|
| 262 |
Ops.push_back(OP); |
|---|
| 263 |
} |
|---|
| 264 |
|
|---|
| 265 |
void initRegressionPanes() |
|---|
| 266 |
{ |
|---|
| 267 |
printf("Don't call initRegressionPanes()!\n"); |
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 |
} |
|---|
| 280 |
|
|---|
| 281 |
|
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
StoryNode *story_root = NULL; |
|---|
| 286 |
World* real_world = NULL; |
|---|
| 287 |
MYSQL* conn = NULL; |
|---|
| 288 |
list<Operator> Ops; |
|---|
| 289 |
|
|---|
| 290 |
PlanNode* forward_root = NULL; |
|---|
| 291 |
PlanNode* regression_root; |
|---|
| 292 |
PlanNode* current_plan_root = NULL; |
|---|
| 293 |
list<vector<PlanNode*> > pending_execution; |
|---|
| 294 |
|
|---|