X-Git-Url: https://ruin.nu/git/?p=icfp05.git;a=blobdiff_plain;f=bot%2Fbot.h;h=731a106a4a1dbcc847ee41f2fd65da03c1ac96dd;hp=416fe63a000e9ee68f9f0998a2023266c6048f4c;hb=d7d9942fc9d1066670e166182e36791dfbf035d7;hpb=1e91b29637d981acb253bc4be7d0eeab63602790 diff --git a/bot/bot.h b/bot/bot.h index 416fe63..731a106 100644 --- a/bot/bot.h +++ b/bot/bot.h @@ -2,9 +2,10 @@ #define __BOT_H__ #include -#include +#include #include #include +#include // 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 > @@ -33,16 +34,18 @@ namespace __gnu_cxx { }; enum StreetType{foot, car, both}; +enum PlayerType{robber, cop_foot, cop_car}; +enum IntersectionType{hq, bank, robber_start, ordinary}; struct Intersection{ __gnu_cxx::hash_map connections; - std::string type; + IntersectionType type; int x; int y; }; struct Player{ - std::string type; + PlayerType type; std::string location; }; @@ -54,29 +57,60 @@ struct Bank{ template T value(std::string input); +struct SPInfo{ + std::string name; + bool settled; + SPInfo* parent; + int cost; +}; + + +struct SPGoal{ + virtual ~SPGoal(){} + virtual int operator()(const SPInfo* node) const = 0; +}; + class Bot { public: - Bot(std::string name, std::string type); - virtual ~Bot(); + Bot(const std::string& name, PlayerType type); + virtual ~Bot(){}; virtual void play(); protected: void buildGraph(); void updateWorld(); - virtual std::string turn(); + virtual std::string turn() = 0; void move(std::string location); + void getPlayers(); + std::list shortestPath(const std::string& from, PlayerType type, const SPGoal& goal, bool reverse = false); __gnu_cxx::hash_map _intersections; __gnu_cxx::hash_map _players; __gnu_cxx::hash_map _banks; + std::map _evidence; + std::map _playerTypeNames; + std::map _playerTypes; std::string _name; - std::string _type; + PlayerType _type; std::string _location; int _world; int _robbed; int _smell; }; +struct SimpleSPGoal : public SPGoal{ + std::string _to; + SimpleSPGoal(std::string to); + int operator()(const SPInfo* node) const; +}; + +struct FindPlayer : SPGoal{ + int _limit; + const __gnu_cxx::hash_map& _players; + PlayerType _type; + FindPlayer(const __gnu_cxx::hash_map& players, PlayerType type, int limit = 0); + int operator()(const SPInfo* node) const; +}; #endif