X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bot%2Fbot.cpp;h=7605cf1ebd473c8b9b373c4c3fc9fc0a19caa185;hb=3a975985ae3a8b2b1cc34df85bc81186afa43842;hp=181b423d44c82e714aca3f84a82c882d78c77604;hpb=518c5700d8f00b70e2b5b6d448efb7b474d57157;p=icfp05.git diff --git a/bot/bot.cpp b/bot/bot.cpp index 181b423..7605cf1 100644 --- a/bot/bot.cpp +++ b/bot/bot.cpp @@ -70,22 +70,11 @@ void Bot::play(){ _name = value(input); cerr << "Got name: " << _name << endl; - //robber and 5 cops - getline(cin, input); - _players[value(input)].type = robber; - getline(cin, input); - _players[value(input)].type = cop_foot; - getline(cin, input); - _players[value(input)].type = cop_foot; - getline(cin, input); - _players[value(input)].type = cop_foot; - getline(cin, input); - _players[value(input)].type = cop_foot; + 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(input)].type = robber; + getline(cin, input); + _players[value(input)].type = cop_foot; + getline(cin, input); + _players[value(input)].type = cop_foot; + getline(cin, input); + _players[value(input)].type = cop_foot; + getline(cin, input); + _players[value(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(){ @@ -223,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){