From: <he...@us...> - 2012-05-22 22:33:21
|
Revision: 316 http://simspark.svn.sourceforge.net/simspark/?rev=316&view=rev Author: hedayat Date: 2012-05-22 22:33:15 +0000 (Tue, 22 May 2012) Log Message: ----------- Don't allow direct goals from kickoff Don't allow dribbling on kickoff Update 0.6.6 release notes Modified Paths: -------------- trunk/rcssserver3d/ChangeLog trunk/rcssserver3d/NEWS trunk/rcssserver3d/RELEASE trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h Modified: trunk/rcssserver3d/ChangeLog =================================================================== --- trunk/rcssserver3d/ChangeLog 2012-05-22 18:22:38 UTC (rev 315) +++ trunk/rcssserver3d/ChangeLog 2012-05-22 22:33:15 UTC (rev 316) @@ -1,3 +1,13 @@ +2012-05-23 Hedayat Vatankhah <hed...@gm...> + + * NEWS: + * RELEASE: + - updated for 0.6.6 + + * plugin/soccer/soccerruleaspect/soccerruleaspect.cpp: + - do not allow direct goals from kickoff + - do not let the kickoff taker to kick the ball again befor other players + 2012-05-22 Hedayat Vatankhah <hed...@gm...> * plugin/soccer/gamestateaspect/gamestateaspect.cpp: @@ -8,6 +18,7 @@ * plugin/soccer/soccerruleaspect/soccerruleaspect.h: - a little cleanup, and fixed comment for mAutoKickOffTimeOrigin + - removed an unused variable mLastValidBallPosition * plugin/soccer/soccerruleaspect/soccerruleaspect.cpp: - update game's paused state Modified: trunk/rcssserver3d/NEWS =================================================================== --- trunk/rcssserver3d/NEWS 2012-05-22 18:22:38 UTC (rev 315) +++ trunk/rcssserver3d/NEWS 2012-05-22 22:33:15 UTC (rev 316) @@ -6,6 +6,14 @@ also increased to 20x30 meters, and free kick distance is 2.0 meters now. More detailed information about this release follows: +* Rule Changes: + - automatic referee now enforces rules whenever players are permitted to + play, rather than only in playon play mode. + - it is no longer possible to score directly from kick off, the ball should + at least touch another player before going into the goal + - in kickoff playmode, the kicker cannot touch the ball again until another + player touches it. + * Field/Dimension Changes: - New dimensions: 20x30 - Free kick distance: 2.0 Modified: trunk/rcssserver3d/RELEASE =================================================================== --- trunk/rcssserver3d/RELEASE 2012-05-22 18:22:38 UTC (rev 315) +++ trunk/rcssserver3d/RELEASE 2012-05-22 22:33:15 UTC (rev 316) @@ -7,6 +7,14 @@ also increased to 20x30 meters, and free kick distance is 2.0 meters now. More detailed information about this release follows: +* Rule Changes: + - automatic referee now enforces rules whenever players are permitted to + play, rather than only in playon play mode. + - it is no longer possible to score directly from kick off, the ball should + at least touch another player before going into the goal + - in kickoff playmode, the kicker cannot touch the ball again until another + player touches it. + * Field/Dimension Changes: - New dimensions: 20x30 - Free kick distance: 2.0 Modified: trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp 2012-05-22 18:22:38 UTC (rev 315) +++ trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp 2012-05-22 22:33:15 UTC (rev 316) @@ -119,7 +119,7 @@ if (changeSides) mNextHalfKickOff = ti; else - mNextHalfKickOff = (ti == TI_LEFT) ? TI_RIGHT : TI_LEFT; + mNextHalfKickOff = SoccerBase::OpponentTeam(ti); } } Modified: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2012-05-22 18:22:38 UTC (rev 315) +++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2012-05-22 22:33:15 UTC (rev 316) @@ -68,7 +68,9 @@ mMin2PlDistance(0), // min dist for second closest of team before being repositioned mMin3PlDistance(0), // min dist for third closest of team before being repositioned mMaxTouchGroupSize(1000), - mMaxFaultTime(0.0) // maximum time allowed for a player to commit a positional fault before being repositioned + mMaxFaultTime(0.0), // maximum time allowed for a player to commit a positional fault before being repositioned + mLastKickOffKickTime(0), + mCheckKickOffKickerFault(false) { mFreeKickPos = Vector3f(0.0,0.0,mBallRadius); } @@ -589,6 +591,40 @@ } void +SoccerRuleAspect::PunishKickOffFault( + boost::shared_ptr<oxygen::AgentAspect> agent) +{ + boost::shared_ptr<AgentState> agentState; + if (!SoccerBase::GetAgentState(agent, agentState)) + { + GetLog()->Error() << "ERROR: (SoccerRuleAspect) Cannot get " + "AgentState from an AgentAspect\n"; + } + else + { + TTeamIndex opp = SoccerBase::OpponentTeam(agentState->GetTeamIndex()); + ClearPlayersBeforeKickOff(opp); + + // put the ball back in the middle of the playing field + Vector3f pos(0, 0, mBallRadius); + MoveBall(pos); + + mGameState->KickOff(opp); + } +} + +inline bool SoccerRuleAspect::WasLastKickFromKickOff( + boost::shared_ptr<oxygen::AgentAspect> &lastKicker) +{ + TTime kickTime; + // notice that a kick is not necessarily an immediate action, it can + // take some time... + return mBallState->GetLastCollidingAgent(lastKicker, kickTime) + && kickTime - mLastKickOffKickTime < 0.1 // kick duration = 0.1 + && lastKicker == mLastKickOffTaker; +} + +void SoccerRuleAspect::ClearSelectedPlayers() { float min_dist = mFreeKickMoveDist; @@ -750,6 +786,9 @@ } if (time > mGameState->GetLastModeChange()) { + mLastKickOffKickTime = time; + mCheckKickOffKickerFault = true; + mLastKickOffTaker = agent; mGameState->SetPlayMode(PM_PlayOn); } } @@ -1099,6 +1138,8 @@ if (idx == TI_NONE) { + // sometimes, ball can't record goals due to approximation errors, + // so we check for goals analytically const salt::Vector3f ballPos = mBallBody->GetPosition(); const float xDist2Goal = fabs(ballPos.x()) - mGoalBallLineX; @@ -1129,6 +1170,19 @@ return false; } + /* don't allow goals directly from kickoff + * + * todo it is allowed in FIFA rules, so we should get rid of it e.g. by + * adding noise to the beam effector so that kickoff kicks cannot be + * precisely planned + */ + boost::shared_ptr<AgentAspect> agent; + if (WasLastKickFromKickOff(agent)) + { + PunishKickOffFault(agent); + return false; + } + // score the lucky team mGameState->ScoreTeam((idx == TI_LEFT) ? TI_RIGHT : TI_LEFT); mGameState->SetPlayMode((idx == TI_LEFT) ? PM_Goal_Right : PM_Goal_Left); @@ -1136,6 +1190,25 @@ return true; } +bool +SoccerRuleAspect::CheckKickOffTakerFault() +{ + if (!mCheckKickOffKickerFault) + return false; + + boost::shared_ptr<AgentAspect> agent; + if (!WasLastKickFromKickOff(agent)) // second kick + { + mCheckKickOffKickerFault = false; + if (agent == mLastKickOffTaker) + { + PunishKickOffFault(mLastKickOffTaker); + return true; + } + } + return false; +} + void SoccerRuleAspect::UpdatePlayOn() { @@ -1161,6 +1234,11 @@ } #endif + if (CheckKickOffTakerFault()) + { + return; + } + // other checks go here... } @@ -1176,7 +1254,7 @@ } // put the ball back in the middle of the playing field - Vector3f pos(0,0,mBallRadius); + Vector3f pos(0, 0, mBallRadius); MoveBall(pos); // kick off for the opposite team Modified: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h 2012-05-22 18:22:38 UTC (rev 315) +++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h 2012-05-22 22:33:15 UTC (rev 316) @@ -211,6 +211,9 @@ /** checks if the assistant referee should raise the flag for offside */ bool CheckOffside(); + /** checks if kickoff taker has kicked the ball again before other players */ + bool CheckKickOffTakerFault(); + /** moves the ball to pos setting its linear and angular velocity to 0 */ void MoveBall(const salt::Vector3f& pos); @@ -253,6 +256,15 @@ */ void SwapTeamSides(); + /** + * Punish agent's fault committed during kickoff + */ + void PunishKickOffFault(boost::shared_ptr<oxygen::AgentAspect> agent); + + /** returns true if last kick was happenned in kick off */ + bool WasLastKickFromKickOff( + boost::shared_ptr<oxygen::AgentAspect> &lastKicker); + protected: /** reference to the body node of the Ball */ boost::shared_ptr<oxygen::RigidBody> mBallBody; @@ -276,9 +288,6 @@ one team can touch the ball */ float mDropBallTime; - /** the point above the ground, where the ball left the field */ - salt::Vector3f mLastValidBallPos; - /** the field length (in meters) */ float mFieldLength; /** the field width (in meters) */ @@ -384,6 +393,13 @@ /** use offside law */ bool mUseOffside; + + /** the time of the kick in the last kick off mode */ + TTime mLastKickOffKickTime; + /** the player which kicked in the last kick off mode */ + boost::shared_ptr<oxygen::AgentAspect> mLastKickOffTaker; + /** if kickoff taker should be checked for single kick rule */ + bool mCheckKickOffKickerFault; }; DECLARE_CLASS(SoccerRuleAspect); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |