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 hash_map<string,int>::const_iterator bank = _banks.find(node->name);
34 if (bank != _banks.end() && bank->second > 0)
36 if ((clock()-_time)/CLOCKS_PER_SEC > 2.4)
41 int Robber::cost(const std::string& from, const std::string& to) const{
43 //cerr << "Calculating cost between " << from << " and " << to << endl;
44 hash_map<string,Intersection>::const_iterator conInter = _intersections.find(to);
45 if (conInter == _intersections.end())
46 return 1000000; //Should never happen
51 list<string> closestFootCop = shortestPath(to, cop_foot, FindPlayer(_players, cop_foot, max), true);
52 unsigned int closestCop = closestFootCop.size();
53 bool copInCar = false;
54 cerr << "Cop on fot " << closestCop << " intersections away: ";
55 copy(closestFootCop.begin(), closestFootCop.end(), ostream_iterator<string>(cerr, " : "));
62 list<string> closestCarCop = shortestPath(to, cop_car, FindPlayer(_players, cop_car, max - 1), true);
63 cerr << "Cop in car " << closestCarCop.size() << " intersections away." << endl;
65 if (closestCarCop.size() > 0){
66 closestCop = closestCarCop.size();
71 //cerr << "Cop " << closestCop << " intersections away." << endl;
72 if (closestCop > 0 && closestCop < 4)
75 cerr << "cost before cop: " << cost << endl;
77 cerr << "Cop " << closestCop << " intersections away." << endl;
78 cost += 12 - (copInCar ? closestCop : closestCop - 1);
80 cerr << "cost after cop: " << cost << endl;
82 if (conInter->second.type == bank){
83 //cerr << "FOUND A BANK" << endl;
84 if (closestCop > 0 && closestCop < 4)
86 else if (_banks.find(to)->second > 0){
87 //cerr << "No cop close to bank" << endl;
92 if (to == _oldLocation)
94 cerr << "Street: " << to << " cost: " << cost << endl;
99 void Robber::move(std::string location){
100 cout << "rmov\\" << endl;
102 cout << "nobribe:" << endl;
103 cout << "rmov/" << endl;
107 Robber robber("harv-robber");
113 #include "../botsrc/shortestPath.cpp"