From: <he...@us...> - 2011-04-21 13:55:54
|
Revision: 269 http://simspark.svn.sourceforge.net/simspark/?rev=269&view=rev Author: hedayat Date: 2011-04-21 13:55:47 +0000 (Thu, 21 Apr 2011) Log Message: ----------- - use float variables in CheckGoal - remove an opponent when the number of opponents in a group are greater than the number of team mates Modified Paths: -------------- trunk/rcssserver3d/ChangeLog trunk/rcssserver3d/NEWS trunk/rcssserver3d/RELEASE trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp Modified: trunk/rcssserver3d/ChangeLog =================================================================== --- trunk/rcssserver3d/ChangeLog 2011-04-20 23:19:27 UTC (rev 268) +++ trunk/rcssserver3d/ChangeLog 2011-04-21 13:55:47 UTC (rev 269) @@ -1,11 +1,23 @@ 2011-04-21 Hedayat Vatankhah <hed...@gm...> + * NEWS: + * RELEASE: + - updated for 0.6.5 to reflect removing an opponent from a touch group when + there are more opponents in the group than teammates + * plugin/soccer/soccerruleaspect/soccerruleaspect.h: - * plugin/soccer/soccerruleaspect/soccerruleaspect.cpp (SoccerRuleAspect::CheckGoal): + * plugin/soccer/soccerruleaspect/soccerruleaspect.cpp + (SoccerRuleAspect::CheckGoal): - if goal recorder's cannot detect any goals, geometrically check to make sure that no goal is actually happened. Thanks to Luis for starting the effort and Mahdi for the initial code for calculating where the ball crosses the goal geometrically. + (SoccerRuleAspect::AnalyseTouchGroups): + - reposition a player from a team with more players in a touch group. Thanks + to Nexus3D (Mehdi?) for the initial patch. It intended to reposition the + player who joined last even from the opponent team, but we don't have + this info now so remove an unspecified player from the opponent if the + last player is not going to be removed. 2011-03-28 Hedayat Vatankhah <hed...@gm...> Modified: trunk/rcssserver3d/NEWS =================================================================== --- trunk/rcssserver3d/NEWS 2011-04-20 23:19:27 UTC (rev 268) +++ trunk/rcssserver3d/NEWS 2011-04-21 13:55:47 UTC (rev 269) @@ -12,7 +12,9 @@ a high number of collisions in 9 vs 9 games: - If an agent is in touch with more than 2 agents (including himself), and he wasn't in such a situation in the previous time step - which means he is the - last to join the group - he is relocated outside of the field. + last to join the group - he is relocated outside of the field. However, if + the number of opponents in the group are more than teammates, an unspecified + opponent will be relocated instead. - If it is not clear which agent joined the group last, e.g. when 3 players were all separate at time t, but were all touching each other in time t + 1, an agent is chosen at random for relocation. Modified: trunk/rcssserver3d/RELEASE =================================================================== --- trunk/rcssserver3d/RELEASE 2011-04-20 23:19:27 UTC (rev 268) +++ trunk/rcssserver3d/RELEASE 2011-04-21 13:55:47 UTC (rev 269) @@ -13,7 +13,9 @@ a high number of collisions in 9 vs 9 games: - If an agent is in touch with more than 2 agents (including himself), and he wasn't in such a situation in the previous time step - which means he is the - last to join the group - he is relocated outside of the field. + last to join the group - he is relocated outside of the field. However, if + the number of opponents in the group are more than teammates, an unspecified + opponent will be relocated instead. - If it is not clear which agent joined the group last, e.g. when 3 players were all separate at time t, but were all touching each other in time t + 1, an agent is chosen at random for relocation. Modified: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2011-04-20 23:19:27 UTC (rev 268) +++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2011-04-21 13:55:47 UTC (rev 269) @@ -84,7 +84,7 @@ } /* Uses only Ball and Players positions and detects overcrowind near ball and areas and -players innappropriate behavior (laying on the ground or not walking for too much time) */ +players inappropriate behavior (laying on the ground or not walking for too much time) */ void SoccerRuleAspect::AutomaticSimpleReferee(TPlayMode playMode) { @@ -98,11 +98,13 @@ { CalculateDistanceArrays(TI_LEFT); // Calculates distance arrays for left team CalculateDistanceArrays(TI_RIGHT); // Calculates distance arrays for right team - AnalyseFaults(TI_LEFT); // Analyses simple faults for the left team - AnalyseFaults(TI_RIGHT); // Analyses simple faults for the right team + AnalyseFaults(TI_LEFT); // Analyzes simple faults for the left team + AnalyseFaults(TI_RIGHT); // Analyzes simple faults for the right team AnalyseTouchGroups(TI_LEFT); AnalyseTouchGroups(TI_RIGHT); - // Only apply rules during play-on + + // Only apply rules during play-on, leaves some time for agents to + // solve it themselves if (playMode == PM_PlayOn) { ClearPlayersAutomatic(TI_LEFT); // enforce standing and not overcrowding rules for left team @@ -275,12 +277,39 @@ SoccerBase::TAgentStateList::iterator i = agent_states.begin(); for (; i != agent_states.end(); ++i) { + boost::shared_ptr<TouchGroup> touchGroup = (*i)->GetOldTouchGroup(); + // Wasn't touching before, joined group making group too large - if ((*i)->GetOldTouchGroup()->size() == 1 && (*i)->GetTouchGroup()->size() > mMaxTouchGroupSize) + if (touchGroup->size() == 1 && touchGroup->size() > mMaxTouchGroupSize) { - playerFaultTime[(*i)->GetUniformNumber()][idx]++; - // Remove player from touch group so no more agents are replaced - (*i)->GetTouchGroup()->erase(*i); + // determine the team that has more players in the touch group + int pl[3] = { 0 }; + TTeamIndex oppIdx; + TouchGroup::iterator oppIt; // stores the last opponent in touch group + for (TouchGroup::iterator agentIt = touchGroup->begin(); + agentIt != touchGroup->end(); ++agentIt) + { + pl[(*agentIt)->GetTeamIndex()]++; + if ((*agentIt)->GetTeamIndex() != idx) + { + oppIdx = (*agentIt)->GetTeamIndex(); + oppIt = agentIt; + } + } + + if (pl[idx] >= touchGroup->size() - pl[idx]) + { + playerFaultTime[(*i)->GetUniformNumber()][idx]++; + // Remove player from touch group so no more agents are replaced + touchGroup->erase(*i); + } + else + { + // I am the last one to enter the group, but the number of + // opponents in the group are more than us + playerFaultTime[(*oppIt)->GetUniformNumber()][oppIdx]++; + touchGroup->erase(*oppIt); + } } } } @@ -1042,8 +1071,8 @@ return false; normBVel.Normalize(); - double velCos = normBVel.x(); - double dist = xDist2Goal / velCos; + float velCos = normBVel.x(); + float dist = xDist2Goal / velCos; salt::Vector3f crossPoint = ballPos - normBVel * dist; if (fabs(crossPoint.y()) < mGoalWidth / 2.0 && This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |