From: <sgv...@us...> - 2011-03-21 22:27:52
|
Revision: 253 http://simspark.svn.sourceforge.net/simspark/?rev=253&view=rev Author: sgvandijk Date: 2011-03-21 22:27:45 +0000 (Mon, 21 Mar 2011) Log Message: ----------- - New touch rules Modified Paths: -------------- trunk/rcssserver3d/data/rsg/agent/nao/contactjointhandler.rsg trunk/rcssserver3d/plugin/soccer/CMakeLists.txt trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.cpp trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.h trunk/rcssserver3d/plugin/soccer/export.cpp trunk/rcssserver3d/plugin/soccer/soccerbase/soccerbase.h trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h Added Paths: ----------- trunk/rcssserver3d/plugin/soccer/agentcollisionhandler/ trunk/rcssserver3d/plugin/soccer/agentcollisionhandler/agentcollisionhandler.cpp trunk/rcssserver3d/plugin/soccer/agentcollisionhandler/agentcollisionhandler.h trunk/rcssserver3d/plugin/soccer/agentcollisionhandler/agentcollisionhandler_c.cpp Modified: trunk/rcssserver3d/data/rsg/agent/nao/contactjointhandler.rsg =================================================================== --- trunk/rcssserver3d/data/rsg/agent/nao/contactjointhandler.rsg 2011-03-14 23:16:57 UTC (rev 252) +++ trunk/rcssserver3d/data/rsg/agent/nao/contactjointhandler.rsg 2011-03-21 22:27:45 UTC (rev 253) @@ -16,4 +16,8 @@ (setContactSlipMode true) (setContactSlip 5e-3) ) -) \ No newline at end of file + (nd AgentCollisionHandler + (setName handler) + ) + +) Modified: trunk/rcssserver3d/plugin/soccer/CMakeLists.txt =================================================================== --- trunk/rcssserver3d/plugin/soccer/CMakeLists.txt 2011-03-14 23:16:57 UTC (rev 252) +++ trunk/rcssserver3d/plugin/soccer/CMakeLists.txt 2011-03-21 22:27:45 UTC (rev 253) @@ -46,6 +46,7 @@ hmdp_effector/hmdpperceptor.h hmdp_effector/naospecific.h line/line.h + agentcollisionhandler/agentcollisionhandler.h ) set(soccer_LIB_SRCS @@ -120,6 +121,8 @@ hmdp_effector/naospecific.cpp line/line.cpp line/line_c.cpp + agentcollisionhandler/agentcollisionhandler.cpp + agentcollisionhandler/agentcollisionhandler_c.cpp ) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${FREETYPE_INCLUDE_DIRS} Added: trunk/rcssserver3d/plugin/soccer/agentcollisionhandler/agentcollisionhandler.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/agentcollisionhandler/agentcollisionhandler.cpp (rev 0) +++ trunk/rcssserver3d/plugin/soccer/agentcollisionhandler/agentcollisionhandler.cpp 2011-03-21 22:27:45 UTC (rev 253) @@ -0,0 +1,60 @@ +#include "agentcollisionhandler.h" +#include <oxygen/agentaspect/agentaspect.h> + +using namespace oxygen; + +void AgentCollisionHandler::OnLink() +{ +} + +void AgentCollisionHandler::HandleCollision(boost::shared_ptr<Collider> collidee, GenericContact& contact) +{ + if (!mAgentState.get()) + { + mAgentState = FindAgentState(this); + if (!mAgentState.get()) + { + GetLog()->Error() << + "(AgentCollisionHandler) Could not find own AgentState\n"; + return; + } + } + + boost::shared_ptr<AgentState> other = FindAgentState(collidee.get()); + if (other.get()) + { + boost::shared_ptr<TouchGroup> myGroup = mAgentState->GetTouchGroup(); + boost::shared_ptr<TouchGroup> otherGroup = other->GetTouchGroup(); + + // Check if not already in same group + if (myGroup == otherGroup) + return; + + // Insert agents into group with lowest index + // This ensures assignment uniqueness + if (myGroup < otherGroup) + { + myGroup->insert(otherGroup->begin(), otherGroup->end()); + otherGroup->clear(); + other->SetTouchGroup(myGroup); + } + else + { + otherGroup->insert(myGroup->begin(), myGroup->end()); + myGroup->clear(); + mAgentState->SetTouchGroup(otherGroup); + } + } +} + +boost::shared_ptr<AgentState> AgentCollisionHandler::FindAgentState(BaseNode* node) +{ + boost::shared_ptr<AgentAspect> agentAspect + = node->FindParentSupportingClass<AgentAspect>().lock(); + if (!agentAspect.get()) + { + return boost::shared_ptr<AgentState>(); + } + + return boost::shared_static_cast<AgentState>(agentAspect->FindChildSupportingClass<AgentState>(true)); +} Added: trunk/rcssserver3d/plugin/soccer/agentcollisionhandler/agentcollisionhandler.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/agentcollisionhandler/agentcollisionhandler.h (rev 0) +++ trunk/rcssserver3d/plugin/soccer/agentcollisionhandler/agentcollisionhandler.h 2011-03-21 22:27:45 UTC (rev 253) @@ -0,0 +1,62 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id: recorderhandler.h 176 2010-02-25 12:19:37Z a-held $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#ifndef AGENTCOLLISIONHANDLER_H +#define AGENTCOLLISIONHANDLER_H + +#include <oxygen/oxygen_defines.h> +#include <oxygen/physicsserver/collisionhandler.h> +#include <oxygen/physicsserver/collider.h> +#include <agentstate/agentstate.h> +#include <boost/enable_shared_from_this.hpp> + +/** \class AgentCollisionHandler is a CollisionHandler that passes + collision information of the Collider it belongs to to the owning + AgentState. +*/ +class AgentCollisionHandler : public oxygen::CollisionHandler +{ +public: + AgentCollisionHandler() : oxygen::CollisionHandler() {}; + virtual ~AgentCollisionHandler() {}; + + virtual void OnLink(); + + /** Adds to collision list if \collidee is part of another agent + + \param collidee is the geom ID of the colliders collision + partner + + \param holds the contact points between the two affected geoms + as returned from the ODE dCollide function + */ + virtual void HandleCollision + (boost::shared_ptr<oxygen::Collider> collidee, oxygen::GenericContact& contact); + +private: + boost::shared_ptr<AgentState> FindAgentState(BaseNode* node); + + boost::shared_ptr<AgentState> mAgentState; +}; + + DECLARE_CLASS(AgentCollisionHandler); + +#endif // AGENTCOLLISIONHANDLER_H Added: trunk/rcssserver3d/plugin/soccer/agentcollisionhandler/agentcollisionhandler_c.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/agentcollisionhandler/agentcollisionhandler_c.cpp (rev 0) +++ trunk/rcssserver3d/plugin/soccer/agentcollisionhandler/agentcollisionhandler_c.cpp 2011-03-21 22:27:45 UTC (rev 253) @@ -0,0 +1,30 @@ +/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id: recorderhandler_c.cpp 176 2010-02-25 12:19:37Z a-held $ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "agentcollisionhandler.h" + +void CLASS(AgentCollisionHandler)::DefineClass() +{ + DEFINE_BASECLASS(oxygen/CollisionHandler); +} + + Modified: trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.cpp 2011-03-14 23:16:57 UTC (rev 252) +++ trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.cpp 2011-03-21 22:27:45 UTC (rev 253) @@ -36,7 +36,8 @@ mHearDecay(2), mHearMateCap(2), mHearOppCap(2), mIfSelfMsg(false), mIfMateMsg(false), mIfOppMsg(false), - mSelected(false) + mSelected(false), + mOldTouchGroup(new TouchGroup), mTouchGroup(new TouchGroup) { // set mID and mUniformNumber into a joint state SetUniformNumber(0); @@ -258,3 +259,28 @@ { mSelected = false; } + +void +AgentState::NewTouchGroup() +{ + mOldTouchGroup = mTouchGroup; + mTouchGroup = boost::shared_ptr<TouchGroup>(new TouchGroup()); +} + +boost::shared_ptr<TouchGroup> +AgentState::GetOldTouchGroup() +{ + return mOldTouchGroup; +} + +void +AgentState::SetTouchGroup(boost::shared_ptr<TouchGroup> group) +{ + mTouchGroup = group; +} + +boost::shared_ptr<TouchGroup> +AgentState::GetTouchGroup() +{ + return mTouchGroup; +} Modified: trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.h 2011-03-14 23:16:57 UTC (rev 252) +++ trunk/rcssserver3d/plugin/soccer/agentstate/agentstate.h 2011-03-21 22:27:45 UTC (rev 253) @@ -30,6 +30,10 @@ class RigidBody; } +class AgentState; + +typedef std::set<boost::shared_ptr<AgentState> > TouchGroup; + class AgentState : public ObjectState { // @@ -91,10 +95,27 @@ bool GetMessage(std::string& msg, float& direction, bool teamMate); bool GetSelfMessage(std::string& msg); + /** Whether agent is selected */ bool IsSelected() const; + + /** Select agent */ void Select(bool s = true); + + /** Unselect agent */ void UnSelect(); + /** Backup old touch group and create new empty one */ + void NewTouchGroup(); + + /** Get the touch group of the previous step */ + boost::shared_ptr<TouchGroup> GetOldTouchGroup(); + + /** Get the current touch group */ + boost::shared_ptr<TouchGroup> GetTouchGroup(); + + /** Set the current touch group */ + void SetTouchGroup(boost::shared_ptr<TouchGroup> group); + protected: /** team index */ TTeamIndex mTeamIndex; @@ -138,7 +159,12 @@ /** is there any message from oponnent */ bool mIfOppMsg; + /** is this agent selected */ bool mSelected; + + boost::shared_ptr<TouchGroup> mOldTouchGroup; + boost::shared_ptr<TouchGroup> mTouchGroup; + protected: virtual void UpdateHierarchyInternal(); virtual void OnUnlink(); Modified: trunk/rcssserver3d/plugin/soccer/export.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/export.cpp 2011-03-14 23:16:57 UTC (rev 252) +++ trunk/rcssserver3d/plugin/soccer/export.cpp 2011-03-21 22:27:45 UTC (rev 253) @@ -54,6 +54,7 @@ #include "hmdp_effector/hmdpeffector.h" #include "hmdp_effector/hmdpperceptor.h" #include "line/line.h" +#include "agentcollisionhandler/agentcollisionhandler.h" ZEITGEIST_EXPORT_BEGIN() ZEITGEIST_EXPORT(SoccerControlAspect); @@ -90,5 +91,6 @@ ZEITGEIST_EXPORT(HMDPPerceptor); ZEITGEIST_EXPORT(HMDPEffector); ZEITGEIST_EXPORT(Line); + ZEITGEIST_EXPORT(AgentCollisionHandler); ZEITGEIST_EXPORT_END() Modified: trunk/rcssserver3d/plugin/soccer/soccerbase/soccerbase.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/soccerbase/soccerbase.h 2011-03-14 23:16:57 UTC (rev 252) +++ trunk/rcssserver3d/plugin/soccer/soccerbase/soccerbase.h 2011-03-21 22:27:45 UTC (rev 253) @@ -62,7 +62,7 @@ class SoccerBase { public: - typedef std::list<boost::shared_ptr<AgentState> > TAgentStateList; + typedef std::vector<boost::shared_ptr<AgentState> > TAgentStateList; typedef std::map<int, boost::shared_ptr<AgentState> > TAgentStateMap; public: Modified: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2011-03-14 23:16:57 UTC (rev 252) +++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2011-03-21 22:27:45 UTC (rev 253) @@ -30,6 +30,7 @@ #include <gamestateaspect/gamestateaspect.h> #include <ballstateaspect/ballstateaspect.h> #include <agentstate/agentstate.h> +#include <algorithm> using namespace oxygen; using namespace boost; @@ -63,6 +64,7 @@ mMinOppDistance(0), // min dist for closest Opponent to ball in order to use repositions for 2nd, 3rd player 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 { mFreeKickPos = Vector3f(0.0,0.0,mBallRadius); @@ -98,12 +100,18 @@ 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 + AnalyseTouchGroups(TI_LEFT); + AnalyseTouchGroups(TI_RIGHT); // Only apply rules during play-on if (playMode == PM_PlayOn) { ClearPlayersAutomatic(TI_LEFT); // enforce standing and not overcrowding rules for left team ClearPlayersAutomatic(TI_RIGHT); // enforce standing and not overcrowding rules for right team } + + // Reset touch groups + ResetTouchGroups(TI_LEFT); + ResetTouchGroups(TI_RIGHT); } } @@ -129,7 +137,7 @@ // Process agent state: standing, sitted, laying down, ... void -SoccerRuleAspect::processAgentState(salt::Vector3f pos, int unum, TTeamIndex idx) +SoccerRuleAspect::ProcessAgentState(salt::Vector3f pos, int unum, TTeamIndex idx) { float groundZVal = 0.15; //bellow this player is on the ground float middleZVal = 0.25; //abovce this player is standing (or trying...) @@ -184,7 +192,7 @@ { if (idx == TI_NONE || mBallState.get() == 0) return; - std::list<boost::shared_ptr<AgentState> > agent_states; + SoccerBase::TAgentStateList agent_states; if (! SoccerBase::GetAgentStates(*mBallState.get(), agent_states, idx)) return; @@ -196,7 +204,7 @@ ownGoalPos = Vector3f(mFieldLength/2.0, 0.0, 0.0); boost::shared_ptr<oxygen::Transform> agent_aspect; - std::list<boost::shared_ptr<AgentState> >::const_iterator i; + SoccerBase::TAgentStateList::const_iterator i; numPlInsideOwnArea[idx] = 0; closestPlayer[idx] = 1; @@ -246,7 +254,7 @@ playerInsideOwnArea[unum][idx] = 0; // Process agent state: standing, sitted, laying down, ... - processAgentState(agentPos, unum, idx); + ProcessAgentState(agentPos, unum, idx); } // compute rank of distance to ball @@ -255,6 +263,42 @@ SimpleOrder(distGArr, ordGArr, idx); } +void SoccerRuleAspect::AnalyseTouchGroups(TTeamIndex idx) +{ + if (idx == TI_NONE || mBallState.get() == 0) + return; + SoccerBase::TAgentStateList agent_states; + if (! SoccerBase::GetAgentStates(*mBallState.get(), agent_states, idx)) + return; + + random_shuffle(agent_states.begin(), agent_states.end()); + SoccerBase::TAgentStateList::iterator i = agent_states.begin(); + for (; i != agent_states.end(); ++i) + { + // Wasn't touching before, joined group making group too large + if ((*i)->GetOldTouchGroup()->size() == 1 && (*i)->GetTouchGroup()->size() > mMaxTouchGroupSize) + { + playerFaultTime[(*i)->GetUniformNumber()][idx]++; + // Remove player from touch group so no more agents are replaced + (*i)->GetTouchGroup()->erase(*i); + } + } +} + +void SoccerRuleAspect::ResetTouchGroups(TTeamIndex idx) +{ + SoccerBase::TAgentStateList agent_states; + if (! SoccerBase::GetAgentStates(*mBallState.get(), agent_states, idx)) + return; + + SoccerBase::TAgentStateList::const_iterator i; + for (i = agent_states.begin(); i != agent_states.end(); i++) + { + (*i)->NewTouchGroup(); + (*i)->GetTouchGroup()->insert(*i); + } +} + // Analyse Faults and Creates Fault Time Array void SoccerRuleAspect::AnalyseFaults(TTeamIndex idx) { @@ -316,14 +360,15 @@ salt::Vector3f SoccerRuleAspect::RepositionOutsidePos(salt::Vector3f posIni, int unum, TTeamIndex idx) { - salt::Vector3f pos; - float fac=1.0; - if (unum > 6) unum = 7 -unum; //because of teams that use numbers 7-11 - if (posIni.y()<1.5) fac = 1.0; else fac = -1.0; //for visualization purposes - if (idx==TI_LEFT) pos = Vector3f(-(7-unum)*0.6, 6.5*fac, 1.0); - else pos = Vector3f((7-unum)*0.6, 6.5*fac, 1.0); - //cout << "*********Player Repos Num: " << unum << " Team: " << idx << " Pos: " << pos << endl; - return pos; + salt::Vector3f pos; + // Choose x side based on team + float xFac = idx == TI_LEFT ? -0.6 : 0.6; + // Choose side on oppisite side of field + float yFac = posIni.y() < 0 ? 1.0 : -1.0; + + pos = Vector3f(xFac * (7 - unum), (mFieldWidth / 2 + 0.5) * yFac, 1.0); + + return pos; } @@ -334,20 +379,20 @@ if (idx == TI_NONE || mBallState.get() == 0) return; - std::list<boost::shared_ptr<AgentState> > agent_states; + SoccerBase::TAgentStateList agent_states; if (! SoccerBase::GetAgentStates(*mBallState.get(), agent_states, idx)) return; salt::Vector3f ballPos = mBallBody->GetPosition(); boost::shared_ptr<oxygen::Transform> agent_aspect; - std::list<boost::shared_ptr<AgentState> >::const_iterator i; + SoccerBase::TAgentStateList::const_iterator i; for (i = agent_states.begin(); i != agent_states.end(); ++i) { SoccerBase::GetTransformParent(**i, agent_aspect); Vector3f agentPos = agent_aspect->GetWorldTransform().Pos(); - int unum = (*i)->GetUniformNumber(); + int unum = (*i)->GetUniformNumber(); if (playerFaultTime[unum][idx] > mMaxFaultTime / 0.02) { // I am not a very good soccer player... I am violating the rules... @@ -367,13 +412,13 @@ { if (idx == TI_NONE || mBallState.get() == 0) return; - std::list<boost::shared_ptr<AgentState> > agent_states; + SoccerBase::TAgentStateList agent_states; if (! SoccerBase::GetAgentStates(*mBallState.get(), agent_states, idx)) return; salt::BoundingSphere sphere(pos, radius); boost::shared_ptr<oxygen::Transform> agent_aspect; - std::list<boost::shared_ptr<AgentState> >::const_iterator i; + SoccerBase::TAgentStateList::const_iterator i; for (i = agent_states.begin(); i != agent_states.end(); ++i) { SoccerBase::GetTransformParent(**i, agent_aspect); @@ -412,12 +457,12 @@ float min_dist, TTeamIndex idx) { if (idx == TI_NONE || mBallState.get() == 0) return; - std::list<boost::shared_ptr<AgentState> > agent_states; + SoccerBase::TAgentStateList agent_states; if (! SoccerBase::GetAgentStates(*mBallState.get(), agent_states, idx)) return; boost::shared_ptr<oxygen::Transform> agent_aspect; - std::list<boost::shared_ptr<AgentState> >::const_iterator i; + SoccerBase::TAgentStateList::const_iterator i; for (i = agent_states.begin(); i != agent_states.end(); ++i) { SoccerBase::GetTransformParent(**i, agent_aspect); @@ -457,7 +502,7 @@ ClearPlayers(Vector3f(0,0,0), mFreeKickDist, mFreeKickMoveDist,opp); // move the kick off team to own half field and the center circle - std::list<boost::shared_ptr<AgentState> > agent_states; + SoccerBase::TAgentStateList agent_states; if (! SoccerBase::GetAgentStates(*mBallState.get(), agent_states, idx)) return; @@ -470,7 +515,7 @@ } boost::shared_ptr<oxygen::Transform> agent_aspect; - std::list<boost::shared_ptr<AgentState> >::const_iterator i; + SoccerBase::TAgentStateList::const_iterator i; float freeKickDist2 = mFreeKickDist*mFreeKickDist; for (i = agent_states.begin(); i != agent_states.end(); ++i) { @@ -504,12 +549,12 @@ SoccerRuleAspect::ClearSelectedPlayers() { float min_dist = mFreeKickMoveDist; - std::list<boost::shared_ptr<AgentState> > agent_states; + SoccerBase::TAgentStateList agent_states; if (! SoccerBase::GetAgentStates(*mBallState.get(), agent_states, TI_NONE)) return; boost::shared_ptr<oxygen::Transform> agent_aspect; - std::list<boost::shared_ptr<AgentState> >::const_iterator i; + SoccerBase::TAgentStateList::const_iterator i; for (i = agent_states.begin(); i != agent_states.end(); ++i) { SoccerBase::GetTransformParent(**i, agent_aspect); @@ -1256,6 +1301,7 @@ SoccerBase::GetSoccerVar(*this,"MinOppDistance",mMinOppDistance); SoccerBase::GetSoccerVar(*this,"Min2PlDistance",mMin2PlDistance); SoccerBase::GetSoccerVar(*this,"Min3PlDistance",mMin3PlDistance); + SoccerBase::GetSoccerVar(*this,"MaxTouchGroupSize",mMaxTouchGroupSize); //SoccerBase::GetSoccerVar(*this,"MaxFaultTime",mMaxFaultTime); @@ -1284,13 +1330,13 @@ SoccerRuleAspect::Broadcast(const string& message, const Vector3f& pos, int number, TTeamIndex idx) { - TAgentStateList agent_states; + SoccerBase::TAgentStateList agent_states; if (! SoccerBase::GetAgentStates(*mBallState.get(), agent_states, idx)) { return; } - TAgentStateList opponent_agent_states; + SoccerBase::TAgentStateList opponent_agent_states; if (! SoccerBase::GetAgentStates(*mBallState.get(), opponent_agent_states, SoccerBase::OpponentTeam(idx))) { @@ -1308,7 +1354,7 @@ boost::shared_ptr<RigidBody> agent_body; for ( - TAgentStateList::const_iterator it = agent_states.begin(); + SoccerBase::TAgentStateList::const_iterator it = agent_states.begin(); it != agent_states.end(); it++ ) @@ -1653,13 +1699,13 @@ boost::shared_ptr<AgentState> agentState) { if (idx == TI_NONE || mBallState.get() == 0) return; - std::list<boost::shared_ptr<AgentState> > agent_states; + SoccerBase::TAgentStateList agent_states; if (! SoccerBase::GetAgentStates(*mBallState.get(), agent_states, idx)) return; salt::BoundingSphere sphere(pos, radius); boost::shared_ptr<oxygen::Transform> agent_aspect; - std::list<boost::shared_ptr<AgentState> >::const_iterator i; + SoccerBase::TAgentStateList::const_iterator i; for (i = agent_states.begin(); i != agent_states.end(); ++i) { if (agentState == (*i)) @@ -1704,11 +1750,11 @@ void SoccerRuleAspect::ResetAgentSelection() { - std::list<boost::shared_ptr<AgentState> > agent_states; + SoccerBase::TAgentStateList agent_states; if (SoccerBase::GetAgentStates(*mBallState.get(), agent_states, TI_NONE)) { - std::list<boost::shared_ptr<AgentState> >::const_iterator i; + SoccerBase::TAgentStateList::const_iterator i; for (i = agent_states.begin(); i != agent_states.end(); ++i) (*i)->UnSelect(); } @@ -1717,13 +1763,13 @@ void SoccerRuleAspect::SelectNextAgent() { - std::list<boost::shared_ptr<AgentState> > agent_states; + SoccerBase::TAgentStateList agent_states; bool selectNext = false; if (SoccerBase::GetAgentStates(*mBallState.get(), agent_states, TI_NONE) && agent_states.size() > 0) { boost::shared_ptr<AgentState> first = agent_states.front(); - std::list<boost::shared_ptr<AgentState> >::const_iterator i; + SoccerBase::TAgentStateList::const_iterator i; for (i = agent_states.begin(); i != agent_states.end(); ++i) { if ((*i)->IsSelected()) Modified: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h 2011-03-14 23:16:57 UTC (rev 252) +++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h 2011-03-21 22:27:45 UTC (rev 253) @@ -76,36 +76,44 @@ */ //salt::Vector3f RepositionInsidePos(salt::Vector3f initPos, int unum, TTeamIndex idx, float distance); - /** New rules for repositioning players that commit faults - */ - void ClearPlayersAutomatic(TTeamIndex idx); + /** New rules for repositioning players that commit faults + */ + void ClearPlayersAutomatic(TTeamIndex idx); - /** Calculates distance arrays needed for repositioning players - */ - void CalculateDistanceArrays(TTeamIndex idx); + /** Calculates distance arrays needed for repositioning players + */ + void CalculateDistanceArrays(TTeamIndex idx); - /** Calculates ordering on a distance vector */ - void SimpleOrder(float dArr[][3], int oArr[][3], TTeamIndex idx); + /** Calculates ordering on a distance vector */ + void SimpleOrder(float dArr[][3], int oArr[][3], TTeamIndex idx); - /** Agent state concerining standing, laying down on the ground are processed - */ - void processAgentState(salt::Vector3f pos, int unum, TTeamIndex idx); + /** Agent state concerining standing, laying down on the ground are processed + */ + void ProcessAgentState(salt::Vector3f pos, int unum, TTeamIndex idx); - /** Reset the fault time counter for all players and also other counters - */ - void ResetFaultCounter(TTeamIndex idx); + /** Reset the fault time counter for all players and also other counters + */ + void ResetFaultCounter(TTeamIndex idx); - /** Reset the fault time counter for a given player - */ - void ResetFaultCounterPlayer(int unum, TTeamIndex idx); + /** Reset the fault time counter for a given player + */ + void ResetFaultCounterPlayer(int unum, TTeamIndex idx); - /**Analyse Faults from players and increase fault counter of offending players - */ - void AnalyseFaults(TTeamIndex idx); + /**Analyse Faults from players and increase fault counter of offending players + */ + void AnalyseFaults(TTeamIndex idx); - /** Automatic Referee that clears players that violate the rules - */ - void AutomaticSimpleReferee(TPlayMode playMode); + /** Check whether too many agents are touching + */ + void AnalyseTouchGroups(TTeamIndex idx); + + /** Reset the touch groups + */ + void ResetTouchGroups(TTeamIndex idx); + + /** Automatic Referee that clears players that violate the rules + */ + void AutomaticSimpleReferee(TPlayMode playMode); /** broadcast a said message to all players \param message said message- @@ -302,6 +310,8 @@ float mMinOppDistance; /** maximum number of players of the defending team that may be inside own penalty area */ int mMaxPlayersInsideOwnArea; + /** maximum number of players that may be in a single touch group */ + int mMaxTouchGroupSize; /** maximum time allowed for a player to commit a positional fault before being repositioned */ int mMaxFaultTime; /* Useful arrays for dealing with agent state an faults */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |