]> ruin.nu Git - icfp05.git/commitdiff
fixed bug in the graph-building
authorMichael Andreen <harv@ruin.nu>
Sat, 9 Jul 2005 21:48:41 +0000 (21:48 +0000)
committerMichael Andreen <harv@ruin.nu>
Sat, 9 Jul 2005 21:48:41 +0000 (21:48 +0000)
botsrc/bot.cpp
copsrc/cop.cpp
robbersrc/robber.cpp

index 10fb5447952d3e4bd58c21e80af169cb2fbf7e6e..a98a42bfb8fc5978a41c7ddcd14ad2b1cd6e0489 100644 (file)
@@ -47,10 +47,10 @@ void Bot::play(){
                getline(cin, input);
                if (input == "game-over")
                        return;
-               cerr << input << endl;
-               cerr << "Updating world" << endl;
+               //cerr << input << endl;
+               //cerr << "Updating world" << endl;
                updateWorld();
-               cerr << "Done updating world" << endl;
+               //cerr << "Done updating world" << endl;
                _type = _players[_name].type;
                _location = _players[_name].location;
                //cerr << "New turn" << endl;
@@ -155,22 +155,29 @@ void Bot::buildGraph(){
                if (type == "foot"){
                        _intersections[from].connections[to] = both;
                        Intersection& inter = _intersections[to];
-                       if (inter.connections.find(from) == inter.connections.end())
+                       hash_map<string,StreetType>::iterator conn = inter.connections.find(from);
+                       if (conn == inter.connections.end())
                                inter.connections[from] = foot;
-               }else
-                       _intersections[from].connections[to] = car;
+                       else if (conn->second == car)
+                               inter.connections[from] = both;
+               }else{
+                       Intersection& inter = _intersections[from];
+                       hash_map<string,StreetType>::iterator conn = inter.connections.find(to);
+                       if (conn == inter.connections.end())
+                               inter.connections[from] = car;
+                       else if (conn->second == foot)
+                               inter.connections[from] = both;
+               }
        }
        //cerr << "Number of streets: " << streets << endl;
        getline(cin, input);
 }
 
 void Bot::updateWorld(){
-       cerr << "Entered updateWorld function" << endl;
        string input;
        getline(cin,input);
-       cerr << input << endl;
        _world = value<int>(input);
-       cerr << "World: " << _world << endl;
+       //cerr << "World: " << _world << endl;
 
        getline(cin,input);
        _robbed = value<int>(input);
@@ -264,7 +271,7 @@ T value(std::string input){
 }
 
 std::string Bot::turn(){
-       cerr << "Using stupid stand still Bot::turn" << endl;
+       //cerr << "Using stupid stand still Bot::turn" << endl;
        return _location;
 }
 
index aed3aeb2b963d9aa6120370dcaa7ee84f56ed34e..dd0b1d1a38fee9866b331f2585914d362d505f3f 100644 (file)
@@ -34,7 +34,7 @@ void Cop::preGamePreparations(){
        }
        for (hash_map<string,Player>::const_iterator player = _players.begin();
                        player != _players.end(); ++player){
-               cerr << "Inital plan for player: " << player->first << endl;
+               //cerr << "Inital plan for player: " << player->first << endl;
                if (player->second.type == robber){
                        _robber = player->first;
                        continue;
@@ -125,7 +125,6 @@ void Cop::sendInformation(){
                        location != maybeRobber.end(); ++location){
                if (location->second > 0)
                        location->second /= possibilities;
-               cerr << "World: " << _world << endl;;
                cout << "inf: " << _robber << " " << location->first << " " << _playerTypeNames[robber] << " "
                        << _world << " " << location->second << endl;
        }
index 9bead891761960fd61654568996c0d043cdba3f3..247a00e6de14d8a1e7a47fe52c92f0e14c552aef 100644 (file)
@@ -22,26 +22,29 @@ string Robber::turn(){
                        //cerr << "Discarding: " << street->first << " since car is needed" << endl;
                        continue;
                }
+               //cerr << "Looking at street: " << street->first << endl;
                double goodness = 0;
                Intersection& conInter = _intersections[street->first];
 
                list<string> closestFootCop = shortestPath(street->first, cop_foot, FindPlayer(_players, cop_foot, 6), true);
                unsigned int closestCop = closestFootCop.size();
-               //cerr << "Cop on fot " << closestCop << " intersections away." << endl;
                bool copInCar = false;
-               list<string> closestCarCop = shortestPath(street->first, cop_car, FindPlayer(_players, cop_car, closestCop > 0 ? closestCop : 5), true);
-               //cerr << "Cop in car " << closestCarCop.size() << " intersections away." << endl;
+               //cerr << "Cop on fot " << closestCop << " intersections away." << endl;
+
+               if (closestCop > 0 && closestCop < 3)
+                       continue;
 
+               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;
                }
 
-               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();
@@ -61,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>());