From: <he...@us...> - 2013-06-12 19:49:27
|
Revision: 364 http://sourceforge.net/p/simspark/svn/364 Author: hedayat Date: 2013-06-12 19:49:24 +0000 (Wed, 12 Jun 2013) Log Message: ----------- Fix bugs in goal counting and other areas when teams change sides in the second half. Disabling changing team sides by default, since it is what we currently use in competitions. Update release notes accordingly Modified Paths: -------------- trunk/rcssserver3d/ChangeLog trunk/rcssserver3d/NEWS trunk/rcssserver3d/RELEASE trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp trunk/rcssserver3d/rcssserver3d/naosoccersim.rb Modified: trunk/rcssserver3d/ChangeLog =================================================================== --- trunk/rcssserver3d/ChangeLog 2013-06-12 15:07:21 UTC (rev 363) +++ trunk/rcssserver3d/ChangeLog 2013-06-12 19:49:24 UTC (rev 364) @@ -1,3 +1,14 @@ +2013-06-13 Hedayat Vatankhah <hed...@gm...> + + * NEWS: + * RELEASE: + - added a note about fixing side changing bug in 0.6.7 release + + * rcssserver3d/naosoccersim.rb: + - disabled ChangeSidesInSecondHalf by default for 0.6.7 release, since this + is what we use currently in competitions. But it should work fine if + enabled. + 2013-06-12 Hedayat Vatankhah <hed...@gm...> * NEWS: @@ -11,10 +22,18 @@ * rcssserver3d/naorobottypes.rb: * plugin/soccer/soccerruleaspect/soccerruleaspect.cpp: - re-formatted for better readability & consistency + (SoccerRuleAspect::SwapTeamSides): + - swap gamestateaspect internal team data too (should fix bugs related to + changing team's sides in the second half) * rcssserver3d/naosoccersim.rb: - - add charging foul parameters to silent 'variable not found' errors + - added charging foul parameters to silent 'variable not found' errors + * plugin/soccer/gamestateaspect/gamestateaspect.h: + * plugin/soccer/gamestateaspect/gamestateaspect.cpp: + - added new functions to swap teams internal data structures when they + change sides + 2013-06-12 Sander van Dijk <sgv...@gm...> * plugin/soccer/soccerruleaspect/soccerruleaspect.h: Modified: trunk/rcssserver3d/NEWS =================================================================== --- trunk/rcssserver3d/NEWS 2013-06-12 15:07:21 UTC (rev 363) +++ trunk/rcssserver3d/NEWS 2013-06-12 19:49:24 UTC (rev 364) @@ -40,6 +40,9 @@ by Patrick) - A player can kick the ball in kickoff if there are only 2 players in the field to support current penalty mode. + - Fixed bugs in goal counting when changing team sides in the second half. + Now, this feature should work fine. However, it is disabled by default now + since we don't use it currently in the competitions. [0.6.6] It's time for a new release! This release comes with a number of bug fixes and Modified: trunk/rcssserver3d/RELEASE =================================================================== --- trunk/rcssserver3d/RELEASE 2013-06-12 15:07:21 UTC (rev 363) +++ trunk/rcssserver3d/RELEASE 2013-06-12 19:49:24 UTC (rev 364) @@ -41,6 +41,9 @@ by Patrick) - A player can kick the ball in kickoff if there are only 2 players in the field to support current penalty mode. + - Fixed bugs in goal counting when changing team sides in the second half. + Now, this feature should work fine. However, it is disabled by default now + since we don't use it currently in the competitions. You can get the package on the Simspark page on SourceForge at http://sourceforge.net/projects/simspark/ Modified: trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp 2013-06-12 15:07:21 UTC (rev 363) +++ trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp 2013-06-12 19:49:24 UTC (rev 364) @@ -20,6 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gamestateaspect.h" +#include <algorithm> #include <zeitgeist/logserver/logserver.h> #include <soccerbase/soccerbase.h> #include <agentstate/agentstate.h> @@ -53,6 +54,9 @@ mGamePaused = true; mMaxHeteroTypeCount = 3; mMaxTotalHeteroCount = 9; + mInternalIndex[TI_NONE] = -1; + mInternalIndex[TI_LEFT] = 0; + mInternalIndex[TI_RIGHT] = 1; } GameStateAspect::~GameStateAspect() @@ -163,30 +167,19 @@ void GameStateAspect::SetTeamName(TTeamIndex idx, const std::string& name) { - switch (idx) - { - case TI_LEFT: - mTeamName[0] = name; - break; - case TI_RIGHT: - mTeamName[1] = name; - break; - } + int i = GetInternalIndex(idx); + if (i > -1) + mTeamName[i] = name; return; } std::string GameStateAspect::GetTeamName(TTeamIndex idx) const { - switch (idx) - { - case TI_LEFT: - return mTeamName[0]; - case TI_RIGHT: - return mTeamName[1]; - default: + int i = GetInternalIndex(idx); + if (i < 0) return ""; - } + return mTeamName[i]; } TTeamIndex @@ -197,34 +190,30 @@ if (mTeamName[i].empty()) { mTeamName[i] = teamName; - return static_cast<TTeamIndex>(i + TI_LEFT); + return GetInternalIndex(TI_LEFT) == i ? TI_LEFT : TI_RIGHT; } if (mTeamName[i] == teamName) { - return static_cast<TTeamIndex>(i + TI_LEFT); + return GetInternalIndex(TI_LEFT) == i ? TI_LEFT : TI_RIGHT; } } return TI_NONE; } +inline int +GameStateAspect::GetInternalIndex(TTeamIndex idx) const +{ + return mInternalIndex[idx]; +} + bool GameStateAspect::InsertUnum(TTeamIndex idx, int unum) { - int i; - - switch (idx) - { - case TI_LEFT: - i = 0; - break; - case TI_RIGHT: - i = 1; - break; - default: + int i = GetInternalIndex(idx); + if (i < 0) return false; - } TUnumSet& set = mUnumSet[i]; @@ -244,19 +233,9 @@ bool GameStateAspect::EraseUnum(TTeamIndex idx, int unum) { - int i; - - switch (idx) - { - case TI_LEFT: - i = 0; - break; - case TI_RIGHT: - i = 1; - break; - default: + int i = GetInternalIndex(idx); + if (i < 0) return false; - } TUnumSet& set = mUnumSet[i]; @@ -275,19 +254,9 @@ bool GameStateAspect::InsertRobotType(TTeamIndex idx, int type) { - int i; - - switch (idx) - { - case TI_LEFT: - i = 0; - break; - case TI_RIGHT: - i = 1; - break; - default: + int i = GetInternalIndex(idx); + if (i < 0) return false; - } if (type) // heterogeneous player { @@ -321,19 +290,9 @@ bool GameStateAspect::EraseRobotType(TTeamIndex idx, int type) { - int i; - - switch (idx) - { - case TI_LEFT: - i = 0; - break; - case TI_RIGHT: - i = 1; - break; - default: + int i = GetInternalIndex(idx); + if (i < 0) return false; - } if (mRobotTypeCount[i].size() <= type || !mRobotTypeCount[i][type]) { @@ -447,30 +406,21 @@ void GameStateAspect::ScoreTeam(TTeamIndex idx) { - switch (idx) - { - case TI_LEFT: - ++mScore[0]; - break; - case TI_RIGHT: - ++mScore[1]; - break; - } - return; + int i = GetInternalIndex(idx); + if (i < 0) + return; + + ++mScore[i]; } int GameStateAspect::GetScore(TTeamIndex idx) const { - switch (idx) - { - case TI_LEFT: - return mScore[0]; - case TI_RIGHT: - return mScore[1]; - default: + int i = GetInternalIndex(idx); + if (i < 0) return 0; - } + + return mScore[i]; } Vector3f @@ -553,18 +503,9 @@ int GameStateAspect::RequestUniformNumber(TTeamIndex ti) const { - int idx; - switch (ti) - { - case TI_LEFT: - idx = 0; - break; - case TI_RIGHT: - idx = 1; - break; - default: + int idx = GetInternalIndex(ti); + if (idx < 0) return 0; - } for (int i = 1; i <=11; ++i) if (mUnumSet[idx].find(i) == mUnumSet[idx].end()) @@ -593,3 +534,8 @@ { mGamePaused = paused; } + +void GameStateAspect::SwapTeamIndexes() +{ + swap(mInternalIndex[TI_LEFT], mInternalIndex[TI_RIGHT]); +} Modified: trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h 2013-06-12 15:07:21 UTC (rev 363) +++ trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h 2013-06-12 19:49:24 UTC (rev 364) @@ -119,6 +119,9 @@ /** sets the game running state (paused or not) */ void SetPaused(bool paused); + /** swaps the team index (side) of current teams */ + void SwapTeamIndexes(); + protected: /** setup the init positions for the agents */ virtual void OnLink(); @@ -152,6 +155,13 @@ */ TTeamIndex GetTeamIndex(const std::string& teamName); + /** + * @param[in] idx the team index + * @return the internal index used for indexing variables storing data + * about teams. If idx is TI_NONE, it will return -1 + */ + int GetInternalIndex(TTeamIndex idx) const; + protected: /** the current play mode */ TPlayMode mPlayMode; @@ -177,6 +187,10 @@ /** the team that has to start the next half */ TTeamIndex mNextHalfKickOff; + /** the internal index for a team, since its TTeamIndex might change in + * the second half */ + int mInternalIndex[3]; + /** 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 2013-06-12 15:07:21 UTC (rev 363) +++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2013-06-12 19:49:24 UTC (rev 364) @@ -138,8 +138,9 @@ void SoccerRuleAspect::ResetFoulCounter(TTeamIndex idx) { - for(int t=1; t<=11; t++) { - ResetFoulCounterPlayer(t,idx); + for (int t = 1; t <= 11; t++) + { + ResetFoulCounterPlayer(t, idx); } } @@ -800,11 +801,17 @@ if (! SoccerBase::GetAgentStates(*mBallState.get(), agent_states)) return; + mGameState->SwapTeamIndexes(); + SoccerBase::TAgentStateList::iterator it; for (it = agent_states.begin(); it != agent_states.end(); ++it) { (*it)->SetTeamIndex(SoccerBase::OpponentTeam((*it)->GetTeamIndex())); } + + // make sure that team names (and probably other things) are updated on + // monitors + GetActiveScene()->SetModified(true); } void Modified: trunk/rcssserver3d/rcssserver3d/naosoccersim.rb =================================================================== --- trunk/rcssserver3d/rcssserver3d/naosoccersim.rb 2013-06-12 15:07:21 UTC (rev 363) +++ trunk/rcssserver3d/rcssserver3d/naosoccersim.rb 2013-06-12 19:49:24 UTC (rev 364) @@ -56,7 +56,7 @@ addSoccerVar('CoinTossForKickOff', false) addSoccerVar('AutomaticQuit', false) -addSoccerVar('ChangeSidesInSecondHalf', true) +addSoccerVar('ChangeSidesInSecondHalf', false) # agent parameters addSoccerVar('AgentRadius', 0.4) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |