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;
26 Intersection& conInter = _intersections[street->first];
28 list<string> closestFootCop = shortestPath(street->first, cop_foot, FindPlayer(_players, cop_foot, 6), true);
29 unsigned int closestCop = closestFootCop.size();
30 //cerr << "Cop on fot " << closestCop << " intersections away." << endl;
31 bool copInCar = false;
32 list<string> closestCarCop = shortestPath(street->first, cop_car, FindPlayer(_players, cop_car, closestCop > 0 ? closestCop : 5), true);
33 //cerr << "Cop in car " << closestCarCop.size() << " intersections away." << endl;
36 if (closestCarCop.size() > 0){
37 closestCop = closestCarCop.size();
41 if (closestCop > 0 && closestCop < 3){
42 //cerr << "Cop " << closestCop << " intersections away." << endl;
46 priority_queue<double> banks;
47 for(hash_map<string,int>::const_iterator bank = _banks.begin();
48 bank != _banks.end(); ++bank){
49 //cerr << "Handling bank at: " << bank->first << endl;
50 if (bank->second > 0){
51 list<string> cop = shortestPath(bank->first, cop_car, FindPlayer(_players, cop_car, 3), true);
55 cop = shortestPath(bank->first, cop_foot, FindPlayer(_players, cop_foot, 3), true);
59 list<string> l = shortestPath(street->first, _type, SimpleSPGoal(bank->first));
62 //list<string>::iterator i = l.begin();
64 banks.push(bank->second/(pow(l.size(),4.0)));
67 //sort(banks.begin(),banks.end(),greater<double>());
69 for (unsigned int i = 0; i < 2 && banks.size() > 0;++i){
70 goodness += banks.top();
74 //cerr << "Goodness before cop: " << goodness << endl;
76 //cerr << "Cop " << closestCop << " intersections away." << endl;
77 goodness *= 1 - 1/(copInCar ? closestCop : closestCop - 1);
79 //cerr << "Goodness after cop: " << goodness << endl;
81 if (conInter.type == bank){
82 //cerr << "FOUND A BANK" << endl;
83 if (closestCop > 0 && closestCop < 4)
85 else if (_banks[street->first] > 0){
86 //cerr << "No cop close to bank" << endl;
91 //cerr << "Street: " << street->first << " goodness: " << goodness << endl;
92 streets[street->first] = goodness;
94 streets[_oldLocation] /= 10;
98 /*cerr << "Using route: ";
99 copy(v.begin(), v.end(), ostream_iterator<string>(cerr, " : "));
103 //stand still if we can't find a better choice..
104 string destination = _location;
106 for (hash_map<string,double>::const_iterator dest = streets.begin();
107 dest != streets.end(); ++dest){
108 //cerr << "Goodness: " << dest->second << endl;
109 if (dest->second > goodness){
110 //cerr << "New Goodness: " << dest->second << endl;
111 goodness = dest->second;
112 destination = dest->first;
115 _oldLocation = _location;
116 //cerr << "Moving to: " << destination << endl;
121 void Robber::move(std::string location){
122 cout << "rmov\\" << endl;
124 cout << "nobribe:" << endl;
125 cout << "rmov/" << endl;
129 Robber robber("harv-robber");