root/ggpa/main.cpp

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

GGPA code from the good old days of SIGART

Line 
1 /*
2  *  Main.cpp
3  *
4  *
5  *  Created by Bonan Zheng on 3/3/07.
6  *  Copyright 2007 __MyCompanyName__. All rights reserved.
7  *
8  */
9
10 #include "GameWorld.h"
11 #include "TestTools.h"
12 #include "QLearner.h"
13 #include <fstream>
14 #include <sstream>
15 #include <stdlib.h>
16 #include "string.h"
17 using namespace std;
18
19 int main(){
20     cout << "Test tic tac toes rules ..." << endl;
21 //parameters to test
22     string matchID = "123";
23     string role = "xplayer";
24     double startClock = 30;
25     double playClock = 30;
26     string request;
27
28     // read in the rules
29     string ruleFile = "TicTacToe.rul";
30     // open tO5Ahe file
31     ifstream ruleStream(ruleFile.c_str());
32     if (!ruleStream.is_open()) {
33         cerr << "Could not open file " << ruleFile << endl;
34         exit(1);
35     }
36
37     // read in the rules, line by line
38  string rules = "";
39     string line;
40     while (!getline(ruleStream, line).eof()) {
41         //cout << "line: " << line << endl;
42         rules = rules +" " + line;
43
44     }
45     rules = rules + " "+line;
46     // close the file
47     ruleStream.close();
48
49     ostringstream stream1;
50
51     stream1 << "(START " << matchID << " " << role << " (" <<  rules
52             << ") " << startClock
53             << " " << playClock << ")";
54     //cout<< stream1 << endl;
55     request = stream1.str();
56     GameWorld world(request);
57     world.output();
58     GameWorld* pointer =&world;
59     QLearner learnPlease(pointer);
60        
61             cout << endl << "Updating" << endl;
62     vector<string> roles = world.getRoles();
63     vector<Action*> actions(roles.size());
64
65     for (unsigned int roleIndex = 0; roleIndex < roles.size(); roleIndex++) {
66         vector<Action*> legalMoves = world.getLegalMoves(roles[roleIndex]);
67         cout << roles[roleIndex] << endl;
68
69
70         /*assertTrue(legalMoves.size() != 0, "No legal moves!");*/
71         //actions[roleIndex] = legalMoves[0];
72     }
73
74     learnPlease.learn(30);
75         cout<<"finish"<<endl;
76 return 0;
77 }
78
79
Note: See TracBrowser for help on using the browser.