]> ruin.nu Git - icfp05.git/blobdiff - robbersrc/robber.cpp
add the number of connecting streets as a factor in the goodness of an interconnection
[icfp05.git] / robbersrc / robber.cpp
index a9ab618d90cd144e81a4365a0f4a8b1110d097dd..b2a32d44a8081f90dfbac4691ea6312475911c2c 100644 (file)
@@ -8,6 +8,12 @@ using namespace std;
 using namespace __gnu_cxx;
 
 string Robber::turn(){
+
+       //Ignore bribing for now
+       cout << "nobribe:" << endl;
+       string input;
+       getline(cin,input);
+
        hash_map<string,double> streets;
        Intersection& inter = _intersections[_location];
        for (hash_map<string,StreetType>::const_iterator street = inter.connections.begin();
@@ -16,25 +22,29 @@ string Robber::turn(){
                        //cerr << "Discarding: " << street->first << " since car is needed" << endl;
                        continue;
                }
-               double goodness = 0;
+               //cerr << "Looking at street: " << street->first << endl;
                Intersection& conInter = _intersections[street->first];
+               double goodness = conInter.connections.size();
 
                list<string> closestFootCop = shortestPath(street->first, cop_foot, FindPlayer(_players, cop_foot, 6), true);
-               list<string> closestCarCop = shortestPath(street->first, cop_car, FindPlayer(_players, cop_car, 5), true);
-
-               unsigned int closestCop = 0;
+               unsigned int closestCop = closestFootCop.size();
                bool copInCar = false;
+               //cerr << "Cop on fot " << closestCop << " intersections away." << endl;
+
+               if (closestCop > 0 && closestCop < 3)
+                       continue;
 
-               if (closestCarCop.size() < closestFootCop.size() && closestCarCop.size() > 0){
+               list<string> closestCarCop = shortestPath(street->first, cop_car, FindPlayer(_players, cop_car, closestCop - 1 > 0 ? closestCop : 5), true);
+               //cerr << "Cop in car " << closestCarCop.size() << " intersections away." << endl;
+
+               if (closestCarCop.size() > 0){
                        closestCop = closestCarCop.size();
                        copInCar = true;
-               }else 
-                       closestCop = closestFootCop.size();
+               }
 
-               if (closestCop > 0 && closestCop < 3){
-                       //cerr << "Cop " << closestCop << " intersections away." << endl;
+               //cerr << "Cop " << closestCop << " intersections away." << endl;
+               if (closestCop > 0 && closestCop < 3)
                        continue;
-               }
 
                priority_queue<double> banks;
                for(hash_map<string,int>::const_iterator bank = _banks.begin();
@@ -54,7 +64,7 @@ string Robber::turn(){
                                        continue;
                                //list<string>::iterator i = l.begin();
                                //++i;
-                               banks.push(bank->second/(pow(l.size(),4.0)));
+                               banks.push(bank->second/(pow(l.size(),2.0)));
                        }
                }
                //sort(banks.begin(),banks.end(),greater<double>());
@@ -106,13 +116,20 @@ string Robber::turn(){
                }
        }
        _oldLocation = _location;
+       //cerr << "Moving to: " << destination << endl;
                
        return destination;
        
 }
+void Robber::move(std::string location){
+       cout << "rmov\\" << endl;
+       Bot::move(location);
+       cout << "nobribe:" << endl;
+       cout << "rmov/" << endl;
+}
 
 int main(){
-       Robber robber("robber");
+       Robber robber("harv-robber");
        robber.play();
 
        return 0;