|
From: <he...@us...> - 2012-05-22 18:22:45
|
Revision: 315
http://simspark.svn.sourceforge.net/simspark/?rev=315&view=rev
Author: hedayat
Date: 2012-05-22 18:22:38 +0000 (Tue, 22 May 2012)
Log Message:
-----------
Add a "paused" game state (when teams are not playing, e.g. Goal left/right play modes)
Apply automatic referee rules always while the game is 'running', and reset all counters when 'paused'.
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
Modified: trunk/rcssserver3d/ChangeLog
===================================================================
--- trunk/rcssserver3d/ChangeLog 2012-05-20 21:42:25 UTC (rev 314)
+++ trunk/rcssserver3d/ChangeLog 2012-05-22 18:22:38 UTC (rev 315)
@@ -1,3 +1,19 @@
+2012-05-22 Hedayat Vatankhah <hed...@gm...>
+
+ * plugin/soccer/gamestateaspect/gamestateaspect.cpp:
+ * plugin/soccer/gamestateaspect/gamestateaspect.h:
+ - added knowledge about a 'paused' state, in which game is not really
+ running (waiting for the referee to allow the game to continue, e.g. in
+ goal left/right state or at the beginning of a kick in state)
+
+ * plugin/soccer/soccerruleaspect/soccerruleaspect.h:
+ - a little cleanup, and fixed comment for mAutoKickOffTimeOrigin
+
+ * plugin/soccer/soccerruleaspect/soccerruleaspect.cpp:
+ - update game's paused state
+ - consider the referee rules always while the game is running (not paused),
+ and reset all counters otherwise.
+
2012-05-21 Hedayat Vatankhah <hed...@gm...>
* NEWS:
Modified: trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp
===================================================================
--- trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp 2012-05-20 21:42:25 UTC (rev 314)
+++ trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.cpp 2012-05-22 18:22:38 UTC (rev 315)
@@ -45,6 +45,7 @@
mLeftInit = Vector3f(0,0,0);
mRightInit = Vector3f(0,0,0);
mFinished = false;
+ mGamePaused = true;
}
GameStateAspect::~GameStateAspect()
@@ -479,3 +480,13 @@
mScore[0] = scoreLeft;
mScore[1] = scoreRight;
}
+
+bool GameStateAspect::IsPaused() const
+{
+ return mGamePaused;
+}
+
+void GameStateAspect::SetPaused(bool paused)
+{
+ mGamePaused = paused;
+}
Modified: trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h
===================================================================
--- trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h 2012-05-20 21:42:25 UTC (rev 314)
+++ trunk/rcssserver3d/plugin/soccer/gamestateaspect/gamestateaspect.h 2012-05-22 18:22:38 UTC (rev 315)
@@ -112,6 +112,12 @@
/** sets the current game scores. useful if you start a game in the middle */
void SetScores(int scoreLeft, int scoreRight);
+ /** returns if the game is paused */
+ bool IsPaused() const;
+
+ /** sets the game running state (paused or not) */
+ void SetPaused(bool paused);
+
protected:
/** setup the init positions for the agents */
virtual void OnLink();
@@ -175,8 +181,12 @@
/** the radius of an agent */
float mAgentRadius;
+
/** flag if the simulation should be stopped */
bool mFinished;
+
+ /** flag if the game is running or paused (e.g. in goal_left/right state) */
+ bool mGamePaused;
};
DECLARE_CLASS(GameStateAspect);
Modified: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp
===================================================================
--- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2012-05-20 21:42:25 UTC (rev 314)
+++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2012-05-22 18:22:38 UTC (rev 315)
@@ -91,8 +91,9 @@
void
SoccerRuleAspect::AutomaticSimpleReferee(TPlayMode playMode)
{
- // Reset counters before kickoff
- if (playMode == PM_BeforeKickOff)
+ // Reset counters and do not consider players' faults when game is not
+ // running
+ if (mGameState->IsPaused())
{
ResetFaultCounter(TI_LEFT);
ResetFaultCounter(TI_RIGHT);
@@ -106,13 +107,8 @@
AnalyseTouchGroups(TI_LEFT);
AnalyseTouchGroups(TI_RIGHT);
- // 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
- ClearPlayersAutomatic(TI_RIGHT); // enforce standing and not overcrowding rules for right team
- }
+ 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);
@@ -704,6 +700,7 @@
Vector3f pos(0,0,mBallRadius);
MoveBall(pos);
+ mGameState->SetPaused(true);
ClearPlayers(mRightHalf, mFreeKickMoveDist, TI_LEFT);
ClearPlayers(mLeftHalf, mFreeKickMoveDist, TI_RIGHT);
@@ -729,6 +726,8 @@
void
SoccerRuleAspect::UpdateKickOff(TTeamIndex idx)
{
+ mGameState->SetPaused(false);
+
ClearPlayersBeforeKickOff(idx);
// if no player touched the ball for mDropBallTime, we move away
@@ -761,8 +760,11 @@
// do nothing for the duration of mKickInPauseTime
if (mGameState->GetModeTime() < mKickInPauseTime)
{
+ mGameState->SetPaused(true);
return;
}
+ mGameState->SetPaused(false);
+
// move away opponent team
ClearPlayers(mFreeKickPos, mFreeKickDist, mFreeKickMoveDist,
SoccerBase::OpponentTeam(idx));
@@ -810,8 +812,10 @@
// do nothing for the duration of mKickInPauseTime
if (mGameState->GetModeTime() < mKickInPauseTime)
{
+ mGameState->SetPaused(true);
return;
}
+ mGameState->SetPaused(false);
//---------------
salt::Vector2f ball_pos(mFreeKickPos.x(), mFreeKickPos.y());
@@ -880,8 +884,11 @@
// do nothing for the duration of mKickInPauseTime
if (mGameState->GetModeTime() < mKickInPauseTime)
{
+ mGameState->SetPaused(true);
return;
}
+ mGameState->SetPaused(false);
+
// move away opponent team
ClearPlayers(idx == TI_LEFT ? mLeftPenaltyArea : mRightPenaltyArea,
mFreeKickMoveDist, SoccerBase::OpponentTeam(idx));
@@ -936,8 +943,11 @@
// do nothing for the duration of mKickInPauseTime
if (mGameState->GetModeTime() < mKickInPauseTime)
{
+ mGameState->SetPaused(true);
return;
}
+ mGameState->SetPaused(false);
+
// move away opponent team
ClearPlayers(mFreeKickPos, mFreeKickDist, mFreeKickMoveDist,
SoccerBase::OpponentTeam(idx));
@@ -1129,6 +1139,8 @@
void
SoccerRuleAspect::UpdatePlayOn()
{
+ mGameState->SetPaused(false);
+
// check if the ball is in one of the goals
if (CheckGoal())
{
@@ -1155,6 +1167,8 @@
void
SoccerRuleAspect::UpdateGoal()
{
+ mGameState->SetPaused(true);
+
// check if the pause time after the goal has elapsed
if (mGameState->GetModeTime() < mGoalPauseTime)
{
@@ -1182,6 +1196,8 @@
void
SoccerRuleAspect::UpdateGameOver()
{
+ mGameState->SetPaused(true);
+
// wait for 10 seconds to finish
if (mGameState->GetModeTime() < 9 || !mAutomaticQuit)
{
Modified: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h
===================================================================
--- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h 2012-05-20 21:42:25 UTC (rev 314)
+++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h 2012-05-22 18:22:38 UTC (rev 315)
@@ -265,6 +265,7 @@
/** the radius of the Ball */
float mBallRadius;
+
/** the length of the pause after a goal */
float mGoalPauseTime;
/** the length of the pause after the ball left the field */
@@ -274,8 +275,10 @@
/** the time we wait before dropping the ball in play modes where only
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) */
@@ -286,8 +289,10 @@
float mGoalHeight;
/** the absolute x coordinate of the goal which ball should pass (in meters) */
float mGoalBallLineX;
+
/** the point on the field where we do the kick in, free kick etc. */
salt::Vector3f mFreeKickPos;
+
/** the distance opponents have to keep during free kicks, kick ins etc. */
float mFreeKickDist;
/** the (least) distance opponents will be moved away if they are to close
@@ -295,6 +300,7 @@
float mFreeKickMoveDist;
/** the distance from the back line the ball should be placed at for a goal kick */
float mGoalKickDist;
+
/** flag if the simulator should do the kick off automatically after the agent */
bool mAutomaticKickOff;
/** time to wait until we kick off automatically */
@@ -305,7 +311,7 @@
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 */
+ /** the time origin from which mWaitBeforeKickOff is calculated */
float mAutoKickOffTimeOrigin;
//FCP 2010 - New Parameters (added by FCPortugal for Singapure 2010)
@@ -329,6 +335,7 @@
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 */
salt::Vector3f playerPos[12][3]; //Players Positions - not used
int playerGround[12][3]; //Time Players are on the ground
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|