X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bot%2Fbot.h;h=72d2d6bd7a88888bd3f9367dc3c783beac2c435b;hb=ea32d9ec2a34aa06cce2495c4efcb0864911be43;hp=d07fb06e829dbb395105873333f75cb86023f58e;hpb=8e53d666f72d37d80fabee7e493d2058a13a6dae;p=icfp05.git diff --git a/bot/bot.h b/bot/bot.h index d07fb06..72d2d6b 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 > @@ -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 adjs; + __gnu_cxx::hash_map connections; + IntersectionType type; + int x; + int y; }; struct Player{ - std::string type; + PlayerType type; std::string location; }; @@ -50,24 +54,60 @@ struct Bank{ int value; }; -std::vector tokenizeString(std::string input); +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); + Bot(const std::string& name, PlayerType type); + virtual ~Bot(){}; - void play(); + virtual void play(); + + protected: void buildGraph(); void updateWorld(); - virtual void turn() = 0; + 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); - private: __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; - std::string _position; + PlayerType _type; + std::string _location; + int _world; + int _robbed; + int _smell; }; +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; + } +}; #endif