using namespace std;
using namespace __gnu_cxx;
-struct FindCop : SPGoal{
+struct FindPlayer : SPGoal{
int _limit;
const hash_map<string, Player>& _players;
- FindCop(const hash_map<string, Player>& players, int limit = 0) : _players(players), _limit(limit){}
+ PlayerType _type;
+ FindPlayer(const hash_map<string, Player>& players, PlayerType type, int limit = 0) : _players(players), _type(type), _limit(limit){}
int operator()(const SPInfo* node) const{
if (_limit > 0 && node->cost >= _limit)
return -1;
for(hash_map<string, Player>::const_iterator player = _players.begin();
player != _players.end(); ++player){
- if (player->second.type != robber && player->second.location == node->name){
+ if (player->second.type == _type && player->second.location == node->name){
return 1;
}
}
double goodness = 10;
Intersection& conInter = _intersections[street->first];
- list<string> l = shortestPath(street->first, _type, FindCop(_players, 5));
- if (l.size() > 0){
- cerr << "Cop " << l.size() << " intersections away." << endl;
- if (l.size() < 3)
+ list<string> closestFootCop = shortestPath(street->first, cop_foot, FindPlayer(_players, cop_foot, 5));
+ list<string> closestCarCop = shortestPath(street->first, cop_car, FindPlayer(_players, cop_car, 4));
+
+ unsigned int closestCop = 0;
+ bool copInCar = false;
+
+ if (closestFootCop.size() < closestCarCop.size() && closestFootCop.size() > 0)
+ closestCop = closestFootCop.size();
+ else {
+ closestCop = closestCarCop.size();
+ copInCar = true;
+ }
+
+ if (closestCop > 0){
+ cerr << "Cop " << closestCop << " intersections away." << endl;
+ if (closestCop < 3)
continue;
- goodness *= 1 - 1/l.size();
+ if (!copInCar)
+ --closestCop;
+ goodness *= 1 - 1/closestCop;
}
if (conInter.type == bank){
cerr << "FOUND A BANK" << endl;
- if (l.size() > 0 && l.size() < 4)
+ if (closestCop > 0 && closestCop < 4)
continue;
else if (_banks[street->first] > 0){
cerr << "No cop close to bank" << endl;