8 using namespace __gnu_cxx;
10 string Robber::turn(){
12 //Ignore bribing for now
13 cout << "nobribe:" << endl;
15 cerr << "New turn" << endl;
19 cerr << "Starting to calculate shortest path" << endl;
20 list<string> l = shortestPath(_location, robber,*this, *this);
21 _oldLocation = _location;
23 cerr << "Found a route" << endl;
24 list<string>::iterator i = l.begin();
27 cerr << "Moving to: " << _location << endl;
31 int Robber::operator()(const SPInfo* node) const{
32 //cerr << "Goal for " << node->name << endl;
33 if (node->cost > 10 || (clock()-_time)/CLOCKS_PER_SEC > 2.4)
38 int Robber::cost(const std::string& from, const std::string& to) const{
40 //cerr << "Calculating cost between " << from << " and " << to << endl;
41 hash_map<string,Intersection>::const_iterator conInter = _intersections.find(to);
42 if (conInter == _intersections.end())
43 return 1000000; //Should never happen
47 list<string> closestFootCop = shortestPath(to, cop_foot, FindPlayer(_players, cop_foot, 10), true);
48 unsigned int closestCop = closestFootCop.size();
49 bool copInCar = false;
50 //cerr << "Cop on fot " << closestCop << " intersections away." << endl;
52 if (closestCop > 0 && closestCop < 3)
55 list<string> closestCarCop = shortestPath(to, cop_car, FindPlayer(_players, cop_car, closestCop - 1 > 0 ? closestCop : 5), true);
56 //cerr << "Cop in car " << closestCarCop.size() << " intersections away." << endl;
58 if (closestCarCop.size() > 0){
59 closestCop = closestCarCop.size();
63 //cerr << "Cop " << closestCop << " intersections away." << endl;
64 if (closestCop > 0 && closestCop < 3)
67 //cerr << "Goodness before cop: " << goodness << endl;
69 //cerr << "Cop " << closestCop << " intersections away." << endl;
70 cost += 8 - (copInCar ? closestCop : closestCop - 1);
72 //cerr << "Goodness after cop: " << goodness << endl;
74 if (conInter->second.type == bank){
75 //cerr << "FOUND A BANK" << endl;
76 if (closestCop > 0 && closestCop < 4)
78 else if (_banks.find(to)->second > 0){
79 //cerr << "No cop close to bank" << endl;
84 if (to == _oldLocation)
86 cerr << "Street: " << to << " cost: " << cost << endl;
91 void Robber::move(std::string location){
92 cout << "rmov\\" << endl;
94 cout << "nobribe:" << endl;
95 cout << "rmov/" << endl;
99 Robber robber("harv-robber");
105 #include "../botsrc/shortestPath.cpp"