_playerTypes["robber"] = robber;
_playerTypes["cop-foot"] = cop_foot;
_playerTypes["cop-car"] = cop_car;
- /*
- priority_queue<vector<string>, vector<vector<string> >, VectComp> pq;
-
- vector<string> v;
- v.push_back("hej");
- pq.push(v);
- v.push_back("hå");
- pq.push(v);
- v.push_back("blaha");
- pq.push(v);
- v.clear();
- v.push_back("hej hå");
- pq.push(v);
- v.clear();
- v.push_back("hejsan");
- pq.push(v);
- v.push_back("what?");
- pq.push(v);
- v.push_back("blaha");
- pq.push(v);
-
- cerr << "Size: " << pq.top().size() << " " << pq.top()[0] << endl;
- pq.pop();
- cerr << "Size: " << pq.top().size() << " " << pq.top()[0] << endl;
- pq.pop();
- cerr << "Size: " << pq.top().size() << " " << pq.top()[0] << endl;
- pq.pop();
- cerr << "Size: " << pq.top().size() << " " << pq.top()[0] << endl;
- pq.pop();
- cerr << "Size: " << pq.top().size() << " " << pq.top()[0] << endl;
- pq.pop();
- cerr << "Size: " << pq.top().size() << " " << pq.top()[0] << endl;
- pq.pop();
-
-*/
}
_name = value<string>(input);
cerr << "Got name: " << _name << endl;
- //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;
+ getPlayers();
cerr << "Got players, building graph." << endl;
getline(cin, input);
buildGraph();
- getline(cin, input);
while (true){
getline(cin, input);
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 )*
_intersections[from].connections[to] = car;
}
cerr << "Number of streets: " << streets << endl;
+ getline(cin, input);
}
void Bot::updateWorld(){
pl.type = _playerTypes[input];
}
//cerr << "Number of players: " << _players.size() << endl;
+ getline(cin, input);
}
void Bot::move(std::string location){
}
};
-std::list<std::string> Bot::shortestPath(const std::string& from, PlayerType type, const SPGoal& goal){
+std::list<std::string> Bot::shortestPath(const std::string& from, PlayerType type, const SPGoal& goal, bool reverse){
//cerr << "New shortest path from: " << from << endl;
pq.push(node);
int g = 0;
+ bool hascar = type == cop_car;
while(!pq.empty()){
node = pq.top();
pq.pop();
for (hash_map<string,StreetType>::const_iterator street = inter.connections.begin();
street != inter.connections.end(); ++street){
hash_map<string,SPInfo>::iterator newNode = nodes.find(street->first);
- bool hascar = type == cop_car;
- if ( (hascar && (street->second == car || street->second == both)) ||
- (!hascar && (street->second == foot || street->second == both))){
+ bool travelStreet = false;
+ if (hascar){
+ if (reverse){
+ if (street->second != foot){
+ hash_map<string,StreetType>::const_iterator st = _intersections[street->first].connections.find(node->name);
+ if (st != _intersections[street->first].connections.end())
+ travelStreet = st->second != foot;
+ else
+ travelStreet = false;
+ }else
+ travelStreet = true;
+ }else
+ travelStreet = street->second != foot;
+ }else{
+ travelStreet = street->second != car;
+ }
+ if (travelStreet){
//cerr << "Adding street: " << street->first << endl;
SPInfo* n = 0;
if (newNode == nodes.end()){