]> ruin.nu Git - icfp05.git/commitdiff
new robber is good
authorMichael Andreen <harv@ruin.nu>
Sun, 10 Jul 2005 15:14:49 +0000 (15:14 +0000)
committerMichael Andreen <harv@ruin.nu>
Sun, 10 Jul 2005 15:14:49 +0000 (15:14 +0000)
newrobber/newrobber.pro
newrobber/robber.cpp

index d8e180d9cce1d490de6dd600ee54a539e461180b..d5ef0c7d5fa19950faf46ace2c3ecdc4ce302bd0 100644 (file)
@@ -6,7 +6,7 @@ TEMPLATE = app
 CONFIG -= qt
 #CONFIG += debug
 unix:LIBS += -lm
-TARGET = ../nrobber
+TARGET = ../robber2
 
 
 # Input
index ccac7d918ac804382b51ebfd5383643db8ea889a..f2a32416a6b9f42c7afc31e605c895b8217f4d2c 100644 (file)
@@ -30,7 +30,10 @@ string Robber::turn(){
 
 int Robber::operator()(const SPInfo* node) const{
        //cerr << "Goal for " << node->name << endl;
-       if (node->cost > 10 || (clock()-_time)/CLOCKS_PER_SEC > 2.4)
+       hash_map<string,int>::const_iterator bank = _banks.find(node->name);
+       if (bank != _banks.end() && bank->second > 0)
+               return 1;
+       if ((clock()-_time)/CLOCKS_PER_SEC > 2.4)
                return 1;
        return 0;
 }
@@ -44,32 +47,37 @@ int Robber::cost(const std::string& from, const std::string& to) const{
 
        int cost = 1;
 
-       list<string> closestFootCop = shortestPath(to, cop_foot, FindPlayer(_players, cop_foot, 10), true);
+       int max = 10;
+       list<string> closestFootCop = shortestPath(to, cop_foot, FindPlayer(_players, cop_foot, max), true);
        unsigned int closestCop = closestFootCop.size();
        bool copInCar = false;
-       //cerr << "Cop on fot " << closestCop << " intersections away." << endl;
+       cerr << "Cop on fot " << closestCop << " intersections away: ";
+       copy(closestFootCop.begin(), closestFootCop.end(), ostream_iterator<string>(cerr, " : "));
+       cerr << endl;
 
-       if (closestCop > 0 && closestCop < 3)
-               return 100;
+       if (closestCop > 0)
+               max = closestCop;
 
-       list<string> closestCarCop = shortestPath(to, cop_car, FindPlayer(_players, cop_car, closestCop - 1 > 0 ? closestCop : 5), true);
-       //cerr << "Cop in car " << closestCarCop.size() << " intersections away." << endl;
+       if (max > 1){
+               list<string> closestCarCop = shortestPath(to, cop_car, FindPlayer(_players, cop_car, max - 1), true);
+               cerr << "Cop in car " << closestCarCop.size() << " intersections away." << endl;
 
-       if (closestCarCop.size() > 0){
-               closestCop = closestCarCop.size();
-               copInCar = true;
+               if (closestCarCop.size() > 0){
+                       closestCop = closestCarCop.size();
+                       copInCar = true;
+               }
        }
 
        //cerr << "Cop " << closestCop << " intersections away." << endl;
-       if (closestCop > 0 && closestCop < 3)
+       if (closestCop > 0 && closestCop < 4)
                return 100;
 
-       //cerr << "Goodness before cop: " << goodness << endl;
+       cerr << "cost before cop: " << cost << endl;
        if (closestCop > 2){
-               //cerr << "Cop " << closestCop << " intersections away." << endl;
-               cost += 8 - (copInCar ? closestCop : closestCop - 1);
+               cerr << "Cop " << closestCop << " intersections away." << endl;
+               cost += 12 - (copInCar ? closestCop : closestCop - 1);
        }
-       //cerr << "Goodness after cop: " << goodness << endl;
+       cerr << "cost after cop: " << cost << endl;
 
        if (conInter->second.type == bank){
                //cerr << "FOUND A BANK" << endl;