]> ruin.nu Git - icfp05.git/commitdiff
moved abstract base class to it's own subdir
authorMichael Andreen <harv@ruin.nu>
Fri, 24 Jun 2005 18:24:34 +0000 (18:24 +0000)
committerMichael Andreen <harv@ruin.nu>
Fri, 24 Jun 2005 18:24:34 +0000 (18:24 +0000)
bot.cpp [deleted file]
bot.h [deleted file]
bot/bot.cpp [new file with mode: 0644]
bot/bot.h [new file with mode: 0644]

diff --git a/bot.cpp b/bot.cpp
deleted file mode 100644 (file)
index c7af4a6..0000000
--- a/bot.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <iostream>
-#include <sstream>
-#include <iterator>
-#include "bot.h"
-
-using namespace std;
-using namespace __gnu_cxx;
-
-Bot::Bot(string name, string type){
-       _name = name;
-       _type = type;
-}
-
-void Bot::play(){
-       cout << "reg: " << _name << " " << _type << endl;
-
-       string input;
-       getline(cin, input);
-       if (input != "wsk\\")
-               return;
-       getline(cin, input);
-       _name = tokenizeString(input)[1];
-       cerr << "Got name: " << _name << endl;
-       buildGraph();
-       updateWorld();
-       turn();
-}
-
-void Bot::buildGraph(){
-
-}
-
-std::vector<std::string> tokenizeString(std::string input){
-       istringstream istr(input);
-       vector<string> strings;
-       copy(istream_iterator<string>(istr), istream_iterator<string>(), back_inserter(strings));
-       return strings;
-}
diff --git a/bot.h b/bot.h
deleted file mode 100644 (file)
index d07fb06..0000000
--- a/bot.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef __BOT_H__
-#define __BOT_H__
-
-#include <ext/hash_map>
-#include <vector>
-#include <string>
-#include <locale>
-// 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());
-                       }
-
-               };
-};
-
-struct AdjInfo{
-       std::string intersection;
-};
-
-struct Intersection{
-       std::vector<AdjInfo> adjs;
-};
-
-struct Player{
-       std::string type;
-       std::string location;
-};
-
-struct Bank{
-       std::string location;
-       int value;
-};
-
-std::vector<std::string> 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<std::string, Intersection> _intersections;
-       __gnu_cxx::hash_map<std::string, Player> _players;
-       std::string _name;
-       std::string _type;
-       std::string _position;
-};
-
-
-#endif
diff --git a/bot/bot.cpp b/bot/bot.cpp
new file mode 100644 (file)
index 0000000..c7af4a6
--- /dev/null
@@ -0,0 +1,38 @@
+#include <iostream>
+#include <sstream>
+#include <iterator>
+#include "bot.h"
+
+using namespace std;
+using namespace __gnu_cxx;
+
+Bot::Bot(string name, string type){
+       _name = name;
+       _type = type;
+}
+
+void Bot::play(){
+       cout << "reg: " << _name << " " << _type << endl;
+
+       string input;
+       getline(cin, input);
+       if (input != "wsk\\")
+               return;
+       getline(cin, input);
+       _name = tokenizeString(input)[1];
+       cerr << "Got name: " << _name << endl;
+       buildGraph();
+       updateWorld();
+       turn();
+}
+
+void Bot::buildGraph(){
+
+}
+
+std::vector<std::string> tokenizeString(std::string input){
+       istringstream istr(input);
+       vector<string> strings;
+       copy(istream_iterator<string>(istr), istream_iterator<string>(), back_inserter(strings));
+       return strings;
+}
diff --git a/bot/bot.h b/bot/bot.h
new file mode 100644 (file)
index 0000000..d07fb06
--- /dev/null
+++ b/bot/bot.h
@@ -0,0 +1,73 @@
+#ifndef __BOT_H__
+#define __BOT_H__
+
+#include <ext/hash_map>
+#include <vector>
+#include <string>
+#include <locale>
+// 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());
+                       }
+
+               };
+};
+
+struct AdjInfo{
+       std::string intersection;
+};
+
+struct Intersection{
+       std::vector<AdjInfo> adjs;
+};
+
+struct Player{
+       std::string type;
+       std::string location;
+};
+
+struct Bank{
+       std::string location;
+       int value;
+};
+
+std::vector<std::string> 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<std::string, Intersection> _intersections;
+       __gnu_cxx::hash_map<std::string, Player> _players;
+       std::string _name;
+       std::string _type;
+       std::string _position;
+};
+
+
+#endif