22 #include <boost/regex.hpp>
37 this->hostname = std::string(hostname);
55 if (
self)
delete self;
61 std::string message =
"(init " +
team_name +
" (version 15.1)";
65 message = message +
" (goalie))";
68 message =
"(init (version 15.1))";
72 message = message +
")";
76 message = message +
")";
79 boost::regex error(
"\\(error\\s+([\\w\\_]+)\\)");
84 if (boost::regex_match(message.c_str(), match, error)) {
85 std::cerr <<
"Controller::connect() -> " << match[1] << std::endl;
88 boost::regex player_response(
"\\(init\\s+(l|r)\\s+(\\d+)\\s+([\\w\\_]+)\\)");
89 boost::regex coach_response(
"\\(init\\s+(l|r)\\s+ok\\)");
98 if (boost::regex_match(message.c_str(), match, coach_response)) {
102 std::cerr <<
"Controller::connect() -> Does not match response for coach" << std::endl;
106 if (boost::regex_match(message.c_str(), match, player_response)) {
108 unum = atoi((std::string() + match[2]).c_str());
112 std::cerr <<
"Controller::connect() -> Does not match response for player" << std::endl;
122 self->addPlayerType(message);
Parser * parser
Pointer to inner Parser Object.
void connect()
The main connection, should be called before anything else in Phoenix2D.
void disconnect()
Disconnect service.
Server * server
Pointer to inner Server Object.
bool connected
Connection status.
Commands The Commans lorem Ipsum
World * getWorld()
World getter.
bool sendMessage(std::string msg)
World * world
Pointer to inner World Object.
Parser The Parser lorem Ipsum
Self The Self lorem Ipsum
std::string receiveMessage()
Commands * commands
Pointer to inner Commans Object.
World The World lorem Ipsum
Controller(const char *teamName, char agentType, const char *hostname)
Default Constructor.
Reader * reader
Pointer to inner Reader Object.
Commands * getCommands()
Commands getter.
Connect * c
Pointer to inner Connect Object.
Server The Server lorem Ipsum
void reconnect()
Reconnection Logic.
Reader The Reader lorem Ipsum
Self * getSelf()
Self getter.
static char AGENT_TYPE
p = Player, t = Trainer
~Controller()
Default Destructor.