X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bot.h;fp=bot.h;h=d07fb06e829dbb395105873333f75cb86023f58e;hb=1ce2f82187dc028c9987873a57312d88df0a1e82;hp=0000000000000000000000000000000000000000;hpb=7b6b43e3828e32d4204efb984bf5cc2367173d33;p=icfp05.git diff --git a/bot.h b/bot.h new file mode 100644 index 0000000..d07fb06 --- /dev/null +++ b/bot.h @@ -0,0 +1,73 @@ +#ifndef __BOT_H__ +#define __BOT_H__ + +#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 > + struct hash< std::basic_string > { + size_t operator()(const std::basic_string& s) const { + + const std::collate& c = std::use_facet< std::collate >(std::locale()); + + return c.hash(s.c_str(), s.c_str() + s.size()); + + } + + }; + + template< typename CharT, typename Traits, typename Alloc > + struct hash< const std::basic_string > { //yes you need this version aswell! + + size_t operator()(const std::basic_string& s) const { + + const std::collate& c = std::use_facet< std::collate >(std::locale()); + + return c.hash(s.c_str(), s.c_str() + s.size()); + } + + }; +}; + +struct AdjInfo{ + std::string intersection; +}; + +struct Intersection{ + std::vector adjs; +}; + +struct Player{ + std::string type; + std::string location; +}; + +struct Bank{ + std::string location; + int value; +}; + +std::vector tokenizeString(std::string input); + +class Bot { + public: + Bot(std::string name, std::string type); + + void play(); + void buildGraph(); + void updateWorld(); + virtual void turn() = 0; + + private: + __gnu_cxx::hash_map _intersections; + __gnu_cxx::hash_map _players; + std::string _name; + std::string _type; + std::string _position; +}; + + +#endif