Commit e79acb54 authored by Matthew Hausknecht's avatar Matthew Hausknecht

reintroduce osx compatibility.

parent 30f6e304
......@@ -7,6 +7,9 @@ option(INSTALL_ADDITIONAL_TEAMS "Install additional team binaries" ON)
add_definitions(-DELOG -std=c++11)
find_package(BOOST 1.45.0 COMPONENTS scoped_ptr)
include_directories(${Boost_INCLUDE_DIRS})
ExternalProject_Add(rcssserver
GIT_REPOSITORY "https://github.com/mhauskn/rcssserver.git"
GIT_TAG "master"
......
......@@ -305,7 +305,9 @@ class Trainer(object):
def disconnectPlayer(self, player, player_num, on_offense):
"""Wait on a launched player to disconnect from the server. """
team_name = self._offenseTeamName if on_offense else self._defenseTeamName
self.send('(disconnect_player %s %d)'%(team_name, player_num))
while (team_name, str(player_num)) in self._connectedPlayers:
self.send('(disconnect_player %s %d)'%(team_name, player_num))
self.getConnectedPlayers()
player.kill()
def getConnectedPlayers(self):
......
#!/bin/bash
./bin/HFO --offense-agents=2 --no-sync &
./bin/HFO --offense-agents=2 --no-sync --fullstate &
sleep 5
./example/communication_agent 6000 &
sleep 5
......
......@@ -193,9 +193,15 @@ Bhv_BasicTackle::executeOld( PlayerAgent * agent )
bool
Bhv_BasicTackle::executeV12( PlayerAgent * agent )
{
#ifdef __APPLE__
static GameTime s_last_execute_time( 0, 0 );
static bool s_result = false;
static AngleDeg s_best_angle = 0.0;
#else
static thread_local GameTime s_last_execute_time( 0, 0 );
static thread_local bool s_result = false;
static thread_local AngleDeg s_best_angle = 0.0;
#endif
const WorldModel & wm = agent->world();
......
......@@ -122,11 +122,19 @@ Force_Pass::get_best_pass( const WorldModel & world,
double * first_speed,
int * receiver )
{
#ifdef __APPLE__
static GameTime S_last_calc_time( 0, 0 );
static bool S_last_calc_valid = false;
static Vector2D S_last_calc_target;
static double S_last_calc_speed = 0.0;
static int S_last_calc_receiver = Unum_Unknown;
#else
static thread_local GameTime S_last_calc_time( 0, 0 );
static thread_local bool S_last_calc_valid = false;
static thread_local Vector2D S_last_calc_target;
static thread_local double S_last_calc_speed = 0.0;
static thread_local int S_last_calc_receiver = Unum_Unknown;
#endif
if ( S_last_calc_time == world.time() )
{
......@@ -208,11 +216,19 @@ bool
Force_Pass::get_pass_to_player( const WorldModel & world,
int receiver_unum )
{
#ifdef __APPLE__
static GameTime S_last_calc_time( 0, 0 );
static bool S_last_calc_valid = false;
static Vector2D S_last_calc_target;
static double S_last_calc_speed = 0.0;
static int S_last_calc_receiver = Unum_Unknown;
#else
static thread_local GameTime S_last_calc_time( 0, 0 );
static thread_local bool S_last_calc_valid = false;
static thread_local Vector2D S_last_calc_target;
static thread_local double S_last_calc_speed = 0.0;
static thread_local int S_last_calc_receiver = Unum_Unknown;
#endif
if ( S_last_calc_time == world.time() )
{
......
......@@ -53,9 +53,15 @@
bool
Bhv_GoalieFreeKick::execute( rcsc::PlayerAgent * agent )
{
#ifdef __APPLE__
static bool s_first_move = false;
static bool s_second_move = false;
static int s_second_wait_count = 0;
#else
static thread_local bool s_first_move = false;
static thread_local bool s_second_move = false;
static thread_local int s_second_wait_count = 0;
#endif
rcsc::dlog.addText( rcsc::Logger::TEAM,
__FILE__": Bhf_GoalieFreeKick" );
......
......@@ -622,7 +622,11 @@ bool
Bhv_PenaltyKick::doDribble( PlayerAgent * agent )
{
static const int CONTINUAL_COUNT = 20;
#ifdef __APPLE__
static int S_target_continual_count = CONTINUAL_COUNT;
#else
static thread_local int S_target_continual_count = CONTINUAL_COUNT;
#endif
const ServerParam & SP = ServerParam::i();
const WorldModel & wm = agent->world();
......
......@@ -51,7 +51,11 @@ using namespace rcsc;
bool
Bhv_PrepareSetPlayKick::execute( PlayerAgent * agent )
{
#ifdef __APPLE__
static int s_rest_wait_cycle = -1;
#else
static thread_local int s_rest_wait_cycle = -1;
#endif
// not reach the ball side
if ( Bhv_GoToStaticBall( M_ball_place_angle ).execute( agent ) )
......
......@@ -113,8 +113,13 @@ ActGen_DirectPass::generate( std::vector< ActionStatePair > * result,
const std::vector< ActionStatePair > & path ) const
{
static const int VALID_PLAYER_THRESHOLD = 10;
#ifdef __APPLE__
static GameTime s_last_call_time( 0, 0 );
static int s_action_count = 0;
#else
static thread_local GameTime s_last_call_time( 0, 0 );
static thread_local int s_action_count = 0;
#endif
if ( current_wm.time() != s_last_call_time )
{
......
......@@ -56,8 +56,13 @@ ActGen_SimpleDribble::generate( std::vector< ActionStatePair > * result,
const WorldModel & current_wm,
const std::vector< ActionStatePair > & path ) const
{
#ifdef __APPLE__
static GameTime s_last_call_time( 0, 0 );
static int s_action_count = 0;
#else
static thread_local GameTime s_last_call_time( 0, 0 );
static thread_local int s_action_count = 0;
#endif
if ( current_wm.time() != s_last_call_time )
{
......
......@@ -57,7 +57,11 @@ ActionChainHolder::ActionChainHolder()
ActionChainHolder &
ActionChainHolder::instance()
{
#ifdef __APPLE__
static ActionChainHolder s_instance;
#else
static thread_local ActionChainHolder s_instance;
#endif
return s_instance;
}
......@@ -119,9 +123,15 @@ ActionChainHolder::actionGenerator() const
void
ActionChainHolder::update( const WorldModel & wm )
{
#ifdef __APPLE__
static GameTime s_update_time( 0, 0 );
static FieldEvaluator::ConstPtr s_update_evaluator;
static ActionGenerator::ConstPtr s_update_generator;
#else
static thread_local GameTime s_update_time( 0, 0 );
static thread_local FieldEvaluator::ConstPtr s_update_evaluator;
static thread_local ActionGenerator::ConstPtr s_update_generator;
#endif
if ( s_update_time == wm.time()
&& s_update_evaluator == M_evaluator
......
......@@ -484,8 +484,13 @@ Bhv_ChainAction::doTurnToForward( PlayerAgent * agent )
Vector2D
Bhv_ChainAction::getKeepBallVel( const WorldModel & wm )
{
#ifdef __APPLE__
static GameTime s_update_time( 0, 0 );
static Vector2D s_best_ball_vel( 0.0, 0.0 );
#else
static thread_local GameTime s_update_time( 0, 0 );
static thread_local Vector2D s_best_ball_vel( 0.0, 0.0 );
#endif
if ( s_update_time == wm.time() )
{
......
......@@ -661,8 +661,13 @@ Bhv_PassKickFindReceiver::doKeepBall( rcsc::PlayerAgent * agent,
rcsc::Vector2D
Bhv_PassKickFindReceiver::getKeepBallVel( const rcsc::WorldModel & wm )
{
#ifdef __APPLE__
static GameTime s_update_time( 0, 0 );
static Vector2D s_best_ball_vel( 0.0, 0.0 );
#else
static thread_local GameTime s_update_time( 0, 0 );
static thread_local Vector2D s_best_ball_vel( 0.0, 0.0 );
#endif
if ( s_update_time == wm.time() )
{
......
......@@ -73,7 +73,11 @@ ClearGenerator::ClearGenerator()
ClearGenerator &
ClearGenerator::instance()
{
#ifdef __APPLE__
static ClearGenerator s_instance;
#else
static thread_local ClearGenerator s_instance;
#endif
return s_instance;
}
......
......@@ -91,7 +91,11 @@ CrossGenerator::CrossGenerator()
CrossGenerator &
CrossGenerator::instance()
{
#ifdef __APPLE__
static CrossGenerator s_instance;
#else
static thread_local CrossGenerator s_instance;
#endif
return s_instance;
}
......@@ -117,7 +121,11 @@ CrossGenerator::clear()
void
CrossGenerator::generate( const WorldModel & wm )
{
#ifdef __APPLE__
static GameTime s_update_time( -1, 0 );
#else
static thread_local GameTime s_update_time( -1, 0 );
#endif
if ( s_update_time == wm.time() )
{
return;
......
......@@ -72,7 +72,11 @@ FieldAnalyzer::FieldAnalyzer()
FieldAnalyzer &
FieldAnalyzer::instance()
{
#ifdef __APPLE__
static FieldAnalyzer s_instance;
#else
static thread_local FieldAnalyzer s_instance;
#endif
return s_instance;
}
......@@ -1204,7 +1208,11 @@ FieldAnalyzer::get_blocker( const WorldModel & wm,
void
FieldAnalyzer::update( const WorldModel & wm )
{
#ifdef __APPLE__
static GameTime s_update_time( 0, 0 );
#else
static thread_local GameTime s_update_time( 0, 0 );
#endif
if ( s_update_time == wm.time() )
{
......
......@@ -96,7 +96,11 @@ SelfPassGenerator::SelfPassGenerator()
SelfPassGenerator &
SelfPassGenerator::instance()
{
#ifdef __APPLE__
static SelfPassGenerator s_instance;
#else
static thread_local SelfPassGenerator s_instance;
#endif
return s_instance;
}
......@@ -166,7 +170,11 @@ SelfPassGenerator::createCourses( const WorldModel & wm )
static const int ANGLE_DIVS = 60;
static const double ANGLE_STEP = 360.0 / ANGLE_DIVS;
#ifdef __APPLE__
static std::vector< Vector2D > self_cache( 24 );
#else
static thread_local std::vector< Vector2D > self_cache( 24 );
#endif
const ServerParam & SP = ServerParam::i();
......
......@@ -76,7 +76,11 @@ ShootGenerator::ShootGenerator()
ShootGenerator &
ShootGenerator::instance()
{
#ifdef __APPLE__
static ShootGenerator s_instance;
#else
static thread_local ShootGenerator s_instance;
#endif
return s_instance;
}
......@@ -98,7 +102,11 @@ ShootGenerator::clear()
void
ShootGenerator::generate( const WorldModel & wm, bool consider_shot_distance )
{
#ifdef __APPLE__
static GameTime s_update_time( 0, 0 );
#else
static thread_local GameTime s_update_time( 0, 0 );
#endif
if ( s_update_time == wm.time() )
{
......
......@@ -98,7 +98,11 @@ ShortDribbleGenerator::ShortDribbleGenerator()
ShortDribbleGenerator &
ShortDribbleGenerator::instance()
{
#ifdef __APPLE__
static ShortDribbleGenerator s_instance;
#else
static thread_local ShortDribbleGenerator s_instance;
#endif
return s_instance;
}
......@@ -526,7 +530,11 @@ ShortDribbleGenerator::simulateKickTurnsDashes( const WorldModel & wm,
static const int min_dash = 2;
//static const int min_dash = 1;
#ifdef __APPLE__
static std::vector< Vector2D > self_cache;
#else
static thread_local std::vector< Vector2D > self_cache;
#endif
//
// create self position cache
......
......@@ -153,7 +153,11 @@ StrictCheckPassGenerator::StrictCheckPassGenerator()
StrictCheckPassGenerator &
StrictCheckPassGenerator::instance()
{
#ifdef __APPLE__
static StrictCheckPassGenerator s_instance;
#else
static thread_local StrictCheckPassGenerator s_instance;
#endif
return s_instance;
}
......
......@@ -184,7 +184,11 @@ TackleGenerator::TackleGenerator()
TackleGenerator &
TackleGenerator::instance()
{
#ifdef __APPLE__
static TackleGenerator s_instance;
#else
static thread_local TackleGenerator s_instance;
#endif
return s_instance;
}
......@@ -206,7 +210,11 @@ TackleGenerator::clear()
void
TackleGenerator::generate( const WorldModel & wm )
{
#ifdef __APPLE__
static GameTime s_update_time( 0, 0 );
#else
static thread_local GameTime s_update_time( 0, 0 );
#endif
if ( s_update_time == wm.time() )
{
......
......@@ -248,7 +248,11 @@ SampleCoach::handlePlayerType()
void
SampleCoach::doSubstitute()
{
#ifdef __APPLE__
static bool S_first_substituted = false;
#else
static thread_local bool S_first_substituted = false;
#endif
if ( ! S_first_substituted
&& world().time().cycle() == 0
......@@ -646,7 +650,11 @@ SampleCoach::sayPlayerTypes()
(say (freeform "(player_type ...)"))
*/
#ifdef __APPLE__
static GameTime s_last_send_time( 0, 0 );
#else
static thread_local GameTime s_last_send_time( 0, 0 );
#endif
if ( ! config().useFreeform() )
{
......
......@@ -1534,7 +1534,11 @@ SampleCommunication::sayDefenseLine( PlayerAgent * agent )
bool
SampleCommunication::sayPlayers( PlayerAgent * agent )
{
#ifdef __APPLE__
static GameTime s_last_time( -1, 0 );
#else
static thread_local GameTime s_last_time( -1, 0 );
#endif
const int len = agent->effector().getSayMessageLength();
if ( len + OnePlayerMessage::slength() > ServerParam::i().playerSayMsgSize() )
......
......@@ -132,10 +132,15 @@ SampleTrainer::sampleAction()
{
// sample training to test a ball interception.
#ifdef __APPLE__
static int s_state = 0;
static int s_wait_counter = 0;
static Vector2D s_last_player_move_pos;
#else
static thread_local int s_state = 0;
static thread_local int s_wait_counter = 0;
static thread_local Vector2D s_last_player_move_pos;
#endif
if ( world().existKickablePlayer() )
{
......@@ -171,7 +176,11 @@ SampleTrainer::sampleAction()
}
// change player type
{
#ifdef __APPLE__
static int type = 0;
#else
static thread_local int type = 0;
#endif
doChangePlayerType( world().teamNameLeft(), 1, type );
type = ( type + 1 ) % PlayerParam::i().playerTypes();
}
......@@ -233,7 +242,11 @@ SampleTrainer::recoverForever()
void
SampleTrainer::doSubstitute()
{
#ifdef __APPLE__
static bool s_substitute = false;
#else
static thread_local bool s_substitute = false;
#endif
if ( ! s_substitute
&& world().time().cycle() == 0
&& world().time().stopped() >= 10 )
......@@ -257,7 +270,11 @@ SampleTrainer::doSubstitute()
&& world().time().cycle() % 100 == 1
&& ! world().teamNameLeft().empty() )
{
#ifdef __APPLE__
static int type = 0;
#else
static thread_local int type = 0;
#endif
doChangePlayerType( world().teamNameLeft(), 1, type );
type = ( type + 1 ) % PlayerParam::i().playerTypes();
}
......
......@@ -56,7 +56,11 @@
SoccerRole::Creators &
SoccerRole::creators()
{
#ifdef __APPLE__
static Creators s_instance;
#else
static thread_local Creators s_instance;
#endif
return s_instance;
}
......
......@@ -140,7 +140,11 @@ Strategy::Strategy()
Strategy &
Strategy::instance()
{
#ifdef __APPLE__
static Strategy s_instance;
#else
static thread_local Strategy s_instance;
#endif
return s_instance;
}
......@@ -183,7 +187,11 @@ Strategy::init( CmdLineParser & cmd_parser )
bool
Strategy::read( const std::string & formation_dir )
{
#ifdef __APPLE__
static bool s_initialized = false;
#else
static thread_local bool s_initialized = false;
#endif
if ( s_initialized )
{
......@@ -434,7 +442,11 @@ Strategy::createFormation( const std::string & type_name ) const
void
Strategy::update( const WorldModel & wm )
{
#ifdef __APPLE__
static GameTime s_update_time( -1, 0 );
#else
static thread_local GameTime s_update_time( -1, 0 );
#endif
if ( s_update_time == wm.time() )
{
......@@ -625,7 +637,11 @@ Strategy::updateSituation( const WorldModel & wm )
void
Strategy::updatePosition( const WorldModel & wm )
{
#ifdef __APPLE__
static GameTime s_update_time( 0, 0 );
#else
static thread_local GameTime s_update_time( 0, 0 );
#endif
if ( s_update_time == wm.time() )
{
return;
......@@ -1129,7 +1145,11 @@ Strategy::get_ball_area( const Vector2D & ball_pos )
double
Strategy::get_normal_dash_power( const WorldModel & wm )
{
#ifdef __APPLE__
static bool s_recover_mode = false;
#else
static thread_local bool s_recover_mode = false;
#endif
if ( wm.self().staminaModel().capacityIsEmpty() )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment