7 using namespace __gnu_cxx;
10 hash_map<string,double> streets;
11 Intersection& inter = _intersections[_location];
12 for (hash_map<string,StreetType>::const_iterator street = inter.connections.begin();
13 street != inter.connections.end(); ++street){
15 int curx = _intersections[_location].x;
16 int cury = _intersections[_location].y;
18 int newx = _intersections[street->first].x;
19 int newy = _intersections[street->first].y;
20 for (hash_map<string, Player>::const_iterator player = _players.begin();
21 player != _players.end(); ++player){
22 if (player->first == _name)
25 int px = _intersections[player->second.location].x;
26 int py = _intersections[player->second.location].y;
28 double dist1 = sqrt(pow((curx-px),2.0)+pow((cury-py),2.0));
29 double dist2 = sqrt(pow((newx-px),2.0)+pow((newy-py),2.0));
30 /*cerr << "Original distance: " << dist1 << endl;
31 cerr << "New distance: " << dist2 << endl;
35 if (dist2 < 50 && dist2 < dist1)
38 if (player->second.type == cop_foot && dist2 <= 3)
40 else if (player->second.type == cop_car && dist2 <= 2)
46 cerr << "Street: " << street->first << " goodness: " << goodness << endl;
47 streets[street->first] = goodness;
49 streets[_oldLocation] /= 10;
51 for(hash_map<string,int>::const_iterator bank = _banks.begin();
52 bank != _banks.end(); ++bank){
53 //cerr << "Handling bank at: " << bank->first << endl;
54 if (bank->second > 0){
55 list<string> l = shortestPath(_location, bank->first,_type);
58 list<string>::iterator i = l.begin();
59 streets[*++i] += bank->second/(pow(5.0,double(l.size())));
64 /*cerr << "Using route: ";
65 copy(v.begin(), v.end(), ostream_iterator<string>(cerr, " : "));
71 for (hash_map<string,double>::const_iterator dest = streets.begin();
72 dest != streets.end(); ++dest){
73 cerr << "Goodness: " << dest->second << endl;
74 if (dest->second > goodness){
75 cerr << "New Goodness: " << dest->second << endl;
76 goodness = dest->second;
77 destination = dest->first;
80 _oldLocation = _location;
87 Robber robber("robber");