#include <iostream>
#include <sstream>
#include <iterator>
+#include <queue>
+#include <utility>
#include "bot.h"
using namespace std;
_type = _players[_name].type;
_location = _players[_name].location;
getline(cin, input);
+ cerr << "New turn" << endl;
move(turn());
+ cerr << "Done with turn." << endl;
}
}
istringstream street(input);
string from;
street >> from;
+ street >> from;
string to;
street >> to;
string type;
street >> type;
+ cerr << "Street between: " << from << " and " << to << " of type: " << type << endl;
if (type == "foot"){
_intersections[from].connections[to] = both;
Intersection& inter = _intersections[to];
}
void Bot::move(std::string location){
+ cerr << "Moving to: " << location << endl;
cout << "mov: " << location << " " << _type << endl;
}
}
std::string Bot::turn(){
+ cerr << "Using stupid stand still Bot::turn" << endl;
return _location;
}
+std::vector<std::string> Bot::shortestPath(std::string from, std::string to, std::string type){
+
+ priority_queue<vector<string>, vector<vector<string> >, greater<vector<string> > > pq;
+
+ vector<string> v;
+ v.push_back(from);
+
+ pq.push(v);
+ hash_map<string,bool> settled;
+
+ while(!pq.empty()){
+ const vector<string>& w = pq.top();
+ if (w.back() == to)
+ return w;
+ settled[w.back()] = true;
+ Intersection& inter = _intersections[w.back()];
+ for (hash_map<string,StreetType>::const_iterator street = inter.connections.begin();
+ street != inter.connections.end(); ++street){
+ if (settled.find(street->first) == settled.end())
+ continue;
+ bool car = type == "cop-car";
+ if ( (car && (street->second == car || street->second == both)) ||
+ (!car && (street->second == foot || street->second == both))){
+ v = w;
+ v.push_back(street->first);
+ pq.push(v);
+ }
+ }
+
+ pq.pop();
+ }
+
+ return vector<string>();
+}
void updateWorld();
virtual std::string turn();
void move(std::string location);
+ std::vector<std::string> shortestPath(std::string from, std::string to, std::string type);
__gnu_cxx::hash_map<std::string, Intersection> _intersections;
__gnu_cxx::hash_map<std::string, Player> _players;