]> ruin.nu Git - icfp05.git/blobdiff - bot/bot.cpp
tuning and restructuring
[icfp05.git] / bot / bot.cpp
index dd516328979baf7ea150909a1c69d0f85f20f287..7605cf1ebd473c8b9b373c4c3fc9fc0a19caa185 100644 (file)
@@ -70,22 +70,11 @@ void Bot::play(){
        _name = value<string>(input);
        cerr << "Got name: " << _name << endl;
 
-       //robber and 5 cops
-       getline(cin, input);
-       _players[value<string>(input)];
-       getline(cin, input);
-       _players[value<string>(input)];
-       getline(cin, input);
-       _players[value<string>(input)];
-       getline(cin, input);
-       _players[value<string>(input)];
-       getline(cin, input);
-       _players[value<string>(input)];
+       getPlayers();
 
        cerr << "Got players, building graph." << endl;
        getline(cin, input);
        buildGraph();
-       getline(cin, input);
 
        while (true){
                getline(cin, input);
@@ -94,13 +83,27 @@ void Bot::play(){
                updateWorld();
                _type = _players[_name].type;
                _location = _players[_name].location;
-               getline(cin, input);
                cerr << "New turn" << endl;
                move(turn());
                cerr << "Done with turn." << endl;
        }
 }
 
+void Bot::getPlayers(){
+       string input;
+       //robber and 5 cops
+       getline(cin, input);
+       _players[value<string>(input)].type = robber;
+       getline(cin, input);
+       _players[value<string>(input)].type = cop_foot;
+       getline(cin, input);
+       _players[value<string>(input)].type = cop_foot;
+       getline(cin, input);
+       _players[value<string>(input)].type = cop_foot;
+       getline(cin, input);
+       _players[value<string>(input)].type = cop_foot;
+}
+
 /**
                                nod\ eol        
                                ( nod: loc node-tag coordinate coordinate eol )*        
@@ -168,6 +171,7 @@ void Bot::buildGraph(){
                        _intersections[from].connections[to] = car;
        }
        cerr << "Number of streets: " << streets << endl;
+       getline(cin, input);
 }
 
 void Bot::updateWorld(){
@@ -198,6 +202,11 @@ void Bot::updateWorld(){
                if (input == "ev/")
                        break;
                istringstream evidence(input);
+               int world;
+               evidence >> input;
+               evidence >> input;
+               evidence >> world;
+               _evidence[world] = input;
        }
        
        getline(cin,input);
@@ -218,6 +227,7 @@ void Bot::updateWorld(){
                pl.type = _playerTypes[input];
        }
        //cerr << "Number of players: " << _players.size() << endl;
+       getline(cin, input);
 }
 
 void Bot::move(std::string location){