+++ /dev/null
-#ifndef __BOT_H__
-#define __BOT_H__
-
-#include <ext/hash_map>
-#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 >
- struct hash< std::basic_string<CharT, Traits, Alloc> > {
- size_t operator()(const std::basic_string<CharT, Traits, Alloc>& s) const {
-
- const std::collate<CharT>& c = std::use_facet< std::collate<CharT> >(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<CharT, Traits, Alloc> > { //yes you need this version aswell!
-
- size_t operator()(const std::basic_string<CharT, Traits, Alloc>& s) const {
-
- const std::collate<CharT>& c = std::use_facet< std::collate<CharT> >(std::locale());
-
- return c.hash(s.c_str(), s.c_str() + s.size());
- }
-
- };
-};
-
-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<std::string,StreetType> connections;
- IntersectionType type;
- int x;
- int y;
-};
-
-struct Player{
- PlayerType type;
- std::string location;
-};
-
-struct Bank{
- std::string location;
- int value;
-};
-
-template<class T>
-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(const std::string& name, PlayerType type);
- virtual ~Bot(){};
-
- virtual void play();
-
- protected:
- void buildGraph();
- void updateWorld();
- virtual std::string turn() = 0;
- void move(std::string location);
- void getPlayers();
- std::list<std::string> shortestPath(const std::string& from, PlayerType type, const SPGoal& goal, bool reverse = false);
-
- __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<int, std::string> _evidence;
- std::map<PlayerType, std::string> _playerTypeNames;
- std::map<std::string, PlayerType> _playerTypes;
- std::string _name;
- 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<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