23 #include <boost/regex.hpp>
29 std::string
play_modes =
"before_kick_off corner_kick_l corner_kick_r free_kick_l free_kick_r goal_kick_l goal_kick_r kick_in_l kick_in_r kick_off_l kick_off_r play_on";
30 std::string
events =
"drop_ball goal_l goal_r offside_l offside_r";
34 static pthread_cond_t
cycle_cond = PTHREAD_COND_INITIALIZER;
35 static pthread_mutex_t
cycle_mutex = PTHREAD_MUTEX_INITIALIZER;
54 std::cerr <<
"Game::updateTimes(int) -> can not lock mutex" << std::endl;
62 std::cerr <<
"Game::updateTimes(int) -> can not unlock mutex" << std::endl;
66 std::cerr <<
"Game::updateTime(int) -> can not signal to blocked threads" << std::endl;
72 if (boost::regex_match(play_mode.c_str(), match,
goal_regex)) {
73 int goals = atoi((std::string() + match[2]).c_str());
79 play_mode = std::string() +
"goal_" + match[1];
81 if (
play_modes.find(play_mode) != std::string::npos) {
83 }
else if (play_mode.compare(
"time_over") == 0) {
85 }
else if (
events.find(play_mode) != std::string::npos) {
88 std::cerr <<
"Not recognized: " << play_mode;
95 std::cerr <<
"Game::nextCycle() -> can not lock mutex" << std::endl;
101 std::cerr <<
"Game::nextCycle() -> can not wait for condition" << std::endl;
108 std::cerr <<
"Game::nextCycle() -> can not unlock mutex" << std::endl;
void updatePlayMode(std::string play_mode)
static pthread_cond_t cycle_cond
boost::regex goal_regex("goal_(l|r)_(\\d+)")
static unsigned int GOALS_AGAINST
static std::string PLAY_MODE
static unsigned int GOALS
static unsigned int SIMULATION_TIME
static unsigned int GAME_TIME
static pthread_mutex_t cycle_mutex
void updateTime(int game_time)