From: <he...@us...> - 2012-04-09 20:46:50
|
Revision: 303 http://simspark.svn.sourceforge.net/simspark/?rev=303&view=rev Author: hedayat Date: 2012-04-09 20:46:44 +0000 (Mon, 09 Apr 2012) Log Message: ----------- Automatic KickOff should work fine in all cases and correctly select the kickoff side for the second half. Wait for the specified time before automatic kickoff from when the first agent connects rather than when the simulator is started. Modified Paths: -------------- trunk/rcssserver3d/ChangeLog trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h trunk/rcssserver3d/rcssserver3d/naosoccersim.rb Modified: trunk/rcssserver3d/ChangeLog =================================================================== --- trunk/rcssserver3d/ChangeLog 2012-04-08 21:39:34 UTC (rev 302) +++ trunk/rcssserver3d/ChangeLog 2012-04-09 20:46:44 UTC (rev 303) @@ -1,9 +1,29 @@ +2012-04-10 Hedayat Vatankhah <hed...@gm...> + + * plugin/soccer/soccerruleaspect/soccerruleaspect.cpp + (SoccerRuleAspect::UpdateBeforeKickOff): + - WaitBeforeKickOff is now calculated from when the first agent connects + rather than from the beginning of the before kickoff playmode (when the + simulator is started) + 2012-04-09 Hedayat Vatankhah <hed...@gm...> + * plugin/soccer/gamestateaspect/gamestateaspect.h (GameStateAspect): + * plugin/soccer/gamestateaspect/gamestateaspect.cpp (GameStateAspect::KickOff): + - Fix KickOff for the second half: give the ball to the other team in all + cases (both when the teams change their sides in the second half and when + they don't). + * plugin/soccer/soccerruleaspect/soccerruleaspect.h: * plugin/soccer/soccerruleaspect/soccerruleaspect.cpp (SoccerRuleAspect::SwapTeamSides): - * rcssserver3d/naosoccersim.rb: - change teams' sides in the second half if enabled (enabled by default) + + * rcssserver3d/naosoccersim.rb: + - add new variables for the above changes: CoinTossForKickOff and + ChangeSidesInSecondHalf. The former specifies if in the automatic kickoff + mode, the first half kick off is always given to the left team or is + determined randomly. The latter specifies if the teams should change + their sides in the second half. 2012-04-07 Hedayat Vatankhah <hed...@gm...> Modified: trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp 2012-04-08 21:39:34 UTC (rev 302) +++ trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp 2012-04-09 20:46:44 UTC (rev 303) @@ -40,8 +40,8 @@ mGameHalf = GH_FIRST; mScore[0] = 0; mScore[1] = 0; - mLastKickOff = TI_NONE; - //mSecondHalfKickOff = TI_NONE; + mLastKickOffGameHalf = GH_NONE; + mNextHalfKickOff = TI_NONE; mLeftInit = Vector3f(0,0,0); mRightInit = Vector3f(0,0,0); mFinished = false; @@ -97,77 +97,35 @@ } -// let the monitor handle who kicks off in 2nd half. void GameStateAspect::KickOff(TTeamIndex ti) { - // throw a coin to determine which team kicks off + // throw a coin to determine which team kicks off, except if a new half + // is started in which the opposite team should kick off if (ti == TI_NONE) { ti = (salt::UniformRNG<>(0,1)() <= 0.5) ? TI_LEFT : TI_RIGHT; + + if (mGameHalf != mLastKickOffGameHalf) + { + if (mNextHalfKickOff != TI_NONE) + ti = mNextHalfKickOff; + + bool changeSides; + SoccerBase::GetSoccerVar(*this, "ChangeSidesInSecondHalf", + changeSides); + + if (changeSides) + mNextHalfKickOff = ti; + else + mNextHalfKickOff = (ti == TI_LEFT) ? TI_RIGHT : TI_LEFT; + } } SetPlayMode((ti == TI_LEFT) ? PM_KickOff_Left : PM_KickOff_Right); - - if (mLastKickOff == TI_NONE) - mLastKickOff = ti; + mLastKickOffGameHalf = mGameHalf; } - - -// void -// GameStateAspect::KickOff(TTeamIndex ti) -// { -// if (mGameHalf == GH_FIRST) -// { -// // throw a coin to determine which team kicks off -// if (ti == TI_NONE) -// { -// ti = (salt::UniformRNG<>(0,1)() <= 0.5) ? TI_LEFT : TI_RIGHT; -// } - -// SetPlayMode((ti == TI_LEFT) ? PM_KickOff_Left : PM_KickOff_Right); - -// if (mLastKickOff == TI_NONE) -// mLastKickOff = ti; -// } -// else -// { -// // in the second half, let the opposite team kick off -// SetPlayMode((mLastKickOff == TI_LEFT) ? PM_KickOff_Right : PM_KickOff_Left); -// } -// } -//--------------------------------------------- -// void -// GameStateAspect::KickOff(TTeamIndex ti) -// { -// if (mGameHalf == GH_FIRST) -// { -// // throw a coin to determine which team kicks off -// if (ti == TI_NONE) -// { -// ti = (salt::UniformRNG<>(0,1)() <= 0.5) ? TI_LEFT : TI_RIGHT; -// } - -// SetPlayMode((ti == TI_LEFT) ? PM_KickOff_Left : PM_KickOff_Right); - -// mLastKickOff = ti; -// if (mSecondHalfKickOff == TI_NONE) -// { -// //clog << "setting mSecondHalfKickOff\n"; - -// mSecondHalfKickOff = -// (mLastKickOff == TI_LEFT) ? TI_RIGHT : TI_LEFT; -// } -// } -// else -// { -// // in the second half, let the opposite team kick off -// SetPlayMode((mSecondHalfKickOff == TI_LEFT) ? PM_KickOff_Left : PM_KickOff_Right); -// } -// } - -//--------------------------------------------- TTime GameStateAspect::GetTime() const { @@ -481,6 +439,11 @@ fieldWidth/2 - mAgentRadius*2, mAgentRadius ); + + bool coinTossKickOff = true; + SoccerBase::GetSoccerVar(*this, "CoinTossForKickOff", coinTossKickOff); + if (!coinTossKickOff) + mNextHalfKickOff = TI_LEFT; } int Modified: trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h 2012-04-08 21:39:34 UTC (rev 302) +++ trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h 2012-04-09 20:46:44 UTC (rev 303) @@ -153,10 +153,10 @@ TGameHalf mGameHalf; /** the team that had the last KickOff */ - TTeamIndex mLastKickOff; + TGameHalf mLastKickOffGameHalf; -// /** the team that has to start the second half */ -// TTeamIndex mSecondHalfKickOff; + /** the team that has to start the next half */ + TTeamIndex mNextHalfKickOff; /** the names of the two teams */ std::string mTeamName[2]; Modified: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2012-04-08 21:39:34 UTC (rev 302) +++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2012-04-09 20:46:44 UTC (rev 303) @@ -51,6 +51,7 @@ mSingleHalfTime(false), mAutomaticQuit(true), mChangeSidesInSecondHalf(true), + mAutoKickOffTimeOrigin(1000000.0), mSayMsgSize(20), mAudioCutDist(50.0), mFirstCollidingAgent(true), @@ -713,7 +714,13 @@ mInOffsideRightPlayers.clear(); #endif - if (mAutomaticKickOff && mGameState->GetModeTime() > mWaitBeforeKickOff) + float kickOffWaitTime = 0; + if (mAutoKickOffTimeOrigin > mGameState->GetModeTime()) + mAutoKickOffTimeOrigin = mGameState->GetModeTime(); + else + kickOffWaitTime = mGameState->GetModeTime() - mAutoKickOffTimeOrigin; + + if (mAutomaticKickOff && kickOffWaitTime > mWaitBeforeKickOff) { mGameState->KickOff(); } Modified: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h 2012-04-08 21:39:34 UTC (rev 302) +++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h 2012-04-09 20:46:44 UTC (rev 303) @@ -305,6 +305,8 @@ bool mAutomaticQuit; /** flag if the side of the teams should be changed in the second half*/ bool mChangeSidesInSecondHalf; + /** time to wait until we kick off automatically */ + float mAutoKickOffTimeOrigin; //FCP 2010 - New Parameters (added by FCPortugal for Singapure 2010) /** max time player may be sitted or laying down before being repositioned */ Modified: trunk/rcssserver3d/rcssserver3d/naosoccersim.rb =================================================================== --- trunk/rcssserver3d/rcssserver3d/naosoccersim.rb 2012-04-08 21:39:34 UTC (rev 302) +++ trunk/rcssserver3d/rcssserver3d/naosoccersim.rb 2012-04-09 20:46:44 UTC (rev 303) @@ -48,11 +48,15 @@ addSoccerVar('FreeKickDistance', 1.3) addSoccerVar('FreeKickMoveDist', 1.5) addSoccerVar('GoalKickDist', 1.0) +addSoccerVar('BorderSize', 0.0) # prevent complaining about missing variable + +# soccer game settings addSoccerVar('AutomaticKickOff', false) -addSoccerVar('WaitBeforeKickOff', 2.0) +addSoccerVar('WaitBeforeKickOff', 5.0) +addSoccerVar('CoinTossForKickOff', false) + addSoccerVar('AutomaticQuit', true) addSoccerVar('ChangeSidesInSecondHalf', true) -addSoccerVar('BorderSize', 0.0) # prevent complaining about missing variable # agent parameters addSoccerVar('AgentRadius', 0.4) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |