]> ruin.nu Git - icfp05.git/blobdiff - bot/bot.h
more sane shortest path implementation and more tuning of the robber algorithm
[icfp05.git] / bot / bot.h
index d07fb06e829dbb395105873333f75cb86023f58e..7d278319332a6c9e2c416d9fa3d3f6aef5f34a41 100644 (file)
--- a/bot/bot.h
+++ b/bot/bot.h
@@ -2,9 +2,10 @@
 #define __BOT_H__
 
 #include <ext/hash_map>
-#include <vector>
+#include <list>
 #include <string>
 #include <locale>
+#include <map>
 // These are needed to be able to use std::string as key in a hash_map.
 namespace __gnu_cxx {
        template< typename CharT, typename Traits, typename Alloc >
@@ -32,16 +33,19 @@ namespace __gnu_cxx {
                };
 };
 
-struct AdjInfo{
-       std::string intersection;
-};
+enum StreetType{foot, car, both};
+enum PlayerType{robber, cop_foot, cop_car};
+enum IntersectionType{hq, bank, robber_start, ordinary};
 
 struct Intersection{
-       std::vector<AdjInfo> adjs;
+       __gnu_cxx::hash_map<std::string,StreetType> connections;
+       std::string type;
+       int x;
+       int y;
 };
 
 struct Player{
-       std::string type;
+       PlayerType type;
        std::string location;
 };
 
@@ -50,23 +54,34 @@ struct Bank{
        int value;
 };
 
-std::vector<std::string> tokenizeString(std::string input);
+template<class T>
+T value(std::string input);
 
 class Bot {
        public:
-               Bot(std::string name, std::string type);
+               Bot(const std::string& name, PlayerType type);
+               virtual ~Bot();
+
+               virtual void play();
 
-               void play();
+       protected:
                void buildGraph();
                void updateWorld();
-               virtual void turn() = 0;
+               virtual std::string turn();
+               void move(std::string location);
+               std::list<std::string> shortestPath(const std::string& from, const std::string& to, PlayerType type);
 
-       private:
        __gnu_cxx::hash_map<std::string, Intersection> _intersections;
        __gnu_cxx::hash_map<std::string, Player> _players;
+       __gnu_cxx::hash_map<std::string, int> _banks;
+       std::map<PlayerType, std::string> _playerTypeNames;
+       std::map<std::string, PlayerType> _playerTypes;
        std::string _name;
-       std::string _type;
-       std::string _position;
+       PlayerType _type;
+       std::string _location;
+       int _world;
+       int _robbed;
+       int _smell;
 };