8 using namespace __gnu_cxx;
10 string Robber::turn(){
12 //Ignore bribing for now
13 cout << "nobribe:" << endl;
17 hash_map<string,double> streets;
18 Intersection& inter = _intersections[_location];
19 for (hash_map<string,StreetType>::const_iterator street = inter.connections.begin();
20 street != inter.connections.end(); ++street){
21 if (street->second == car){
22 //cerr << "Discarding: " << street->first << " since car is needed" << endl;
25 //cerr << "Looking at street: " << street->first << endl;
26 Intersection& conInter = _intersections[street->first];
27 double goodness = conInter.connections.size();
29 list<string> closestFootCop = shortestPath(street->first, cop_foot, FindPlayer(_players, cop_foot, 6), true);
30 unsigned int closestCop = closestFootCop.size();
31 bool copInCar = false;
32 //cerr << "Cop on fot " << closestCop << " intersections away." << endl;
34 if (closestCop > 0 && closestCop < 3)
37 list<string> closestCarCop = shortestPath(street->first, cop_car, FindPlayer(_players, cop_car, closestCop - 1 > 0 ? closestCop : 5), true);
38 //cerr << "Cop in car " << closestCarCop.size() << " intersections away." << endl;
40 if (closestCarCop.size() > 0){
41 closestCop = closestCarCop.size();
45 //cerr << "Cop " << closestCop << " intersections away." << endl;
46 if (closestCop > 0 && closestCop < 3)
49 priority_queue<double> banks;
50 for(hash_map<string,int>::const_iterator bank = _banks.begin();
51 bank != _banks.end(); ++bank){
52 //cerr << "Handling bank at: " << bank->first << endl;
53 if (bank->second > 0){
54 list<string> cop = shortestPath(bank->first, cop_car, FindPlayer(_players, cop_car, 3), true);
58 cop = shortestPath(bank->first, cop_foot, FindPlayer(_players, cop_foot, 3), true);
62 list<string> l = shortestPath(street->first, _type, SimpleSPGoal(bank->first));
65 //list<string>::iterator i = l.begin();
67 banks.push(bank->second/(pow(l.size(),4.0)));
70 //sort(banks.begin(),banks.end(),greater<double>());
72 for (unsigned int i = 0; i < 2 && banks.size() > 0;++i){
73 goodness += banks.top();
77 //cerr << "Goodness before cop: " << goodness << endl;
79 //cerr << "Cop " << closestCop << " intersections away." << endl;
80 goodness *= 1 - 1/(copInCar ? closestCop : closestCop - 1);
82 //cerr << "Goodness after cop: " << goodness << endl;
84 if (conInter.type == bank){
85 //cerr << "FOUND A BANK" << endl;
86 if (closestCop > 0 && closestCop < 4)
88 else if (_banks[street->first] > 0){
89 //cerr << "No cop close to bank" << endl;
94 //cerr << "Street: " << street->first << " goodness: " << goodness << endl;
95 streets[street->first] = goodness;
97 streets[_oldLocation] /= 10;
101 /*cerr << "Using route: ";
102 copy(v.begin(), v.end(), ostream_iterator<string>(cerr, " : "));
106 //stand still if we can't find a better choice..
107 string destination = _location;
109 for (hash_map<string,double>::const_iterator dest = streets.begin();
110 dest != streets.end(); ++dest){
111 //cerr << "Goodness: " << dest->second << endl;
112 if (dest->second > goodness){
113 //cerr << "New Goodness: " << dest->second << endl;
114 goodness = dest->second;
115 destination = dest->first;
118 _oldLocation = _location;
119 //cerr << "Moving to: " << destination << endl;
124 void Robber::move(std::string location){
125 cout << "rmov\\" << endl;
127 cout << "nobribe:" << endl;
128 cout << "rmov/" << endl;
132 Robber robber("harv-robber");