]> ruin.nu Git - icfp05.git/commitdiff
some restructuring
authorMichael Andreen <harv@ruin.nu>
Sun, 26 Jun 2005 23:13:30 +0000 (23:13 +0000)
committerMichael Andreen <harv@ruin.nu>
Sun, 26 Jun 2005 23:13:30 +0000 (23:13 +0000)
bot/bot.cpp
bot/bot.h
robber/robber.cpp

index 713f1905657d4e16ac594297c57ac58a232e8597..28e8004a2167997f2b5a8bbe629a486ac03f6711 100644 (file)
@@ -304,3 +304,27 @@ std::list<std::string> Bot::shortestPath(const std::string& from, PlayerType typ
        
        return list<string>();
 }
+
+SimpleSPGoal::SimpleSPGoal(std::string to):_to(to){
+}
+
+int SimpleSPGoal::operator()(const SPInfo* node) const{
+       if (node->name == _to)
+               return 1;
+       return 0;
+}
+
+FindPlayer::FindPlayer(const hash_map<string, Player>& players, PlayerType type, int limit) : _players(players), _type(type), _limit(limit){
+}
+
+int FindPlayer::operator()(const SPInfo* node) const{
+       if (_limit > 0 && node->cost >= _limit)
+               return -1;
+       for(hash_map<string, Player>::const_iterator player = _players.begin();
+                       player != _players.end(); ++player){
+               if (player->second.type == _type && player->second.location == node->name){
+                       return 1;
+               }
+       }
+       return 0;
+}
index 72d2d6bd7a88888bd3f9367dc3c783beac2c435b..731a106a4a1dbcc847ee41f2fd65da03c1ac96dd 100644 (file)
--- a/bot/bot.h
+++ b/bot/bot.h
@@ -101,13 +101,16 @@ class Bot {
 
 struct SimpleSPGoal : public SPGoal{
        std::string _to;
-       SimpleSPGoal(std::string to):_to(to){};
-       ~SimpleSPGoal(){}
-       int operator()(const SPInfo* node) const{
-               if (node->name == _to)
-                       return 1;
-               return 0;
-       }
+       SimpleSPGoal(std::string to);
+       int operator()(const SPInfo* node) const;
+};
+
+struct FindPlayer : SPGoal{
+       int _limit;
+       const __gnu_cxx::hash_map<std::string, Player>& _players;
+       PlayerType _type;
+       FindPlayer(const __gnu_cxx::hash_map<std::string, Player>& players, PlayerType type, int limit = 0);
+       int operator()(const SPInfo* node) const;
 };
 
 #endif
index f586f6ae3267a4e95664d54c4c8ec2e9c36d8d38..dbb287a4d760b5bb2dd231497778866318fb24a4 100644 (file)
@@ -7,24 +7,6 @@
 using namespace std;
 using namespace __gnu_cxx;
 
-struct FindPlayer : SPGoal{
-       int _limit;
-       const hash_map<string, Player>& _players;
-       PlayerType _type;
-       FindPlayer(const hash_map<string, Player>& players, PlayerType type, int limit = 0) : _players(players), _type(type), _limit(limit){}
-       int operator()(const SPInfo* node) const{
-               if (_limit > 0 && node->cost >= _limit)
-                       return -1;
-               for(hash_map<string, Player>::const_iterator player = _players.begin();
-                               player != _players.end(); ++player){
-                       if (player->second.type == _type && player->second.location == node->name){
-                               return 1;
-                       }
-               }
-               return 0;
-       }
-};
-
 string Robber::turn(){
        hash_map<string,double> streets;
        Intersection& inter = _intersections[_location];