Thunderbots Project
Loading...
Searching...
No Matches
GameState Class Reference

Holds the state of the game according to the referee. More...

#include <game_state.h>

Public Types

enum  PlayState {
  HALT , STOP , SETUP , READY ,
  PLAYING
}
 
enum  RestartReason {
  NONE , KICKOFF , DIRECT , INDIRECT ,
  PENALTY , BALL_PLACEMENT
}
 

Public Member Functions

 GameState (const TbotsProto::GameState &game_state_proto)
 
void updateRefereeCommand (RefereeCommand gameState)
 
void updateBall (const Ball &ball)
 
void setRestartCompleted ()
 
const RefereeCommand & getRefereeCommand () const
 
RestartReason getRestartReason () const
 
bool isHalted () const
 
bool isStopped () const
 
bool isPlaying () const
 
bool isKickoff () const
 
bool isPenalty () const
 
bool isBallPlacement () const
 
bool isOurRestart () const
 
bool isDirectFree () const
 
bool isIndirectFree () const
 
bool isOurKickoff () const
 
bool isOurPenalty () const
 
bool isOurDirectFree () const
 
bool isOurIndirectFree () const
 
bool isOurFreeKick () const
 
bool isOurBallPlacement () const
 
bool isTheirKickoff () const
 
bool isTheirPenalty () const
 
bool isTheirDirectFree () const
 
bool isTheirIndirectFree () const
 
bool isTheirFreeKick () const
 
bool isTheirBallPlacement () const
 
PlayState getPlayState (void) const
 
bool isSetupRestart () const
 
bool isSetupState () const
 
bool isReadyState () const
 
bool canKick () const
 
bool stayAwayFromBall () const
 
bool stayOnSide () const
 
bool stayBehindPenaltyLine () const
 
bool operator== (const GameState &other) const
 
bool operator!= (const GameState &other) const
 
std::optional< PointgetBallPlacementPoint (void) const
 
std::optional< BallgetBall (void) const
 
void setBallPlacementPoint (Point placementPoint)
 

Detailed Description

Holds the state of the game according to the referee.

Contains information on what period of the game it is, what type of play to run, team scores, time remaining, etc. During normal gameplay, the information in this class is received from the ssl-game-controller program over the network.

Taken from https://github.com/RoboJackets/robocup-software/

Constructor & Destructor Documentation

◆ GameState()

GameState ( const TbotsProto::GameState &  game_state_proto)
explicit

Creates a new game state based on the TbotsProto::GameState protobuf representation

Parameters
game_state_protoThe TbotsProto::GameState protobuf which this game state should be based on

Member Function Documentation

◆ canKick()

bool canKick ( ) const

Returns true if we can kick the ball.

Returns
true if we can kick the ball.

◆ getBall()

std::optional< Ball > getBall ( void  ) const

Returns the ball

Returns
the ball state if one is specified, otherwise std::nullopt

◆ getBallPlacementPoint()

std::optional< Point > getBallPlacementPoint ( void  ) const

Returns the point on the field where the ball should be placed if one is specified.

Returns
the requested ball placement position on the field if one is specified, otherwise std::nullopt

◆ getPlayState()

GameState::PlayState getPlayState ( void  ) const

Returns the play state

Returns
play state

◆ getRefereeCommand()

const RefereeCommand & getRefereeCommand ( ) const

Returns the current Referee command

Returns
the current Referee command

◆ getRestartReason()

GameState::RestartReason getRestartReason ( ) const

Returns the current restart reason

Returns
the current restart reason

◆ isBallPlacement()

bool isBallPlacement ( ) const

Returns true if ball placement is occurring. See Robocup SSL Rules Law 9.2.

Returns
true if ball placement is occurring.

◆ isDirectFree()

bool isDirectFree ( ) const

Returns true if a direct free kick is occurring. See Robocup SSL Rules Law 13.

Returns
true if a direct free kick is occurring

◆ isHalted()

bool isHalted ( ) const

Returns true if robots may not move.

Returns
true if robots should halt.

◆ isIndirectFree()

bool isIndirectFree ( ) const

Returns true if an indirect free kick is occurring. See Robocup SSL Rules Law 13.

Returns
true if a direct free kick is occurring

◆ isKickoff()

bool isKickoff ( ) const

Returns true if a kickoff is occurring. See Robocup SSL Rules Law 8.2.

Returns
true if a kickoff is occurring.

◆ isOurBallPlacement()

bool isOurBallPlacement ( ) const

Returns true if we are doing ball placement.

Returns
true if we are doing ball placement.

◆ isOurDirectFree()

bool isOurDirectFree ( ) const

Returns true if we are taking a direct free kick.

Returns
true if we are taking a direct free kick.

◆ isOurFreeKick()

bool isOurFreeKick ( ) const

Returns true if we are doing any type of free kick.

Returns
true if we are doing any type of free kick.

◆ isOurIndirectFree()

bool isOurIndirectFree ( ) const

Returns true if we are taking an indirect free kick.

Returns
true if we are taking an indirect free kick.

◆ isOurKickoff()

bool isOurKickoff ( ) const

Returns true if we are taking the kickoff.

Returns
true if we are taking the kickoff.

◆ isOurPenalty()

bool isOurPenalty ( ) const

Returns true if we are taking the penalty kick.

Returns
true if we are taking the penalty kick.

◆ isOurRestart()

bool isOurRestart ( ) const

Returns true if our team is doing the restart, e.g. when we get an indirect kick This function will have undefined behaviour if a restart is not being prepared for or occurring, such as after a transition to HALT or STOP, because of how GameController state transitions work.

Returns
true if our team is doing the restart

◆ isPenalty()

bool isPenalty ( ) const

Returns true if a penalty is occurring. See Robocup SSL Rules Law 14.

Returns
true if a penalty is occurring.

◆ isPlaying()

bool isPlaying ( ) const

Returns true if the game is in play.

Returns
true if game is in play.

◆ isReadyState()

bool isReadyState ( ) const

Returns true if we are ready for a kickoff or restart.

Returns
true if we are ready for a kickoff or restart.

◆ isSetupRestart()

bool isSetupRestart ( ) const

Returns true if robots should be setting up for a restart e.g. if a free kick is going to occur.

Returns
true if robots should be setting up for a restart

◆ isSetupState()

bool isSetupState ( ) const

Returns true if we are currently getting ready for a kickoff or restart. e.g. Getting ready to kick the ball for a free kick.

Returns
true if we are currently getting ready for a kickoff or restart

◆ isStopped()

bool isStopped ( ) const

Returns true if robots must stay a set distance away from the ball. See Robocup SSL Rules Law 5.5

Returns
true if robots should stay away from the ball.

◆ isTheirBallPlacement()

bool isTheirBallPlacement ( ) const

Returns true if opposing side is doing ball placement.

Returns
true if opposing side is doing ball placement.

◆ isTheirDirectFree()

bool isTheirDirectFree ( ) const

Returns true if opposing side is taking a direct free kick.

Returns
true if opposing side is taking a direct free kick.

◆ isTheirFreeKick()

bool isTheirFreeKick ( ) const

Returns true if opposing side is taking any type of free kick.

Returns
true if opposing side is taking any type of free kick.

◆ isTheirIndirectFree()

bool isTheirIndirectFree ( ) const

Returns true if opposing side is taking an indirect free kick.

Returns
true if opposing side is taking an indirect free kick.

◆ isTheirKickoff()

bool isTheirKickoff ( ) const

Returns true if opposing side is doing kickoff.

Returns
true if opposing side is doing kickoff.

◆ isTheirPenalty()

bool isTheirPenalty ( ) const

Returns true if opposing side is taking a penalty kick.

Returns
true if opposing side is taking a penalty kick.

◆ operator!=()

bool operator!= ( const GameState other) const

Defines the inequality operator for a GameState

Parameters
otherThe GameState to compare against for equality
Returns
True if the other GameState is not equal to this GameState and true otherwise

◆ operator==()

bool operator== ( const GameState other) const

Defines the equality operator for a GameState

Parameters
otherThe GameState to compare against for equality
Returns
True if the other GameState is equal to this GameState and false otherwise

◆ setBallPlacementPoint()

void setBallPlacementPoint ( Point  placementPoint)

Sets the point on the field where the ball should be placed. See Robocup SSL Rules Law 9.2.

Parameters
placementPointthe point where the ball should be placed.

◆ setRestartCompleted()

void setRestartCompleted ( )

Clears restart state and enters normal play. Should be called when state transitions from a restart setup state such as PREPARE_KICKOFF_FRIENDLY into NORMAL_START.

◆ stayAwayFromBall()

bool stayAwayFromBall ( ) const

Returns true if we should stay a set distance from the ball. See Robocup SSL Rules Law 13.4, 5.5, 8.2.1, 9.2

Returns
true if robots should stay a set distance from the ball.

◆ stayBehindPenaltyLine()

bool stayBehindPenaltyLine ( ) const

Returns true if our robots except the penalty kicker should stay on our side of the field.

Returns
true if our robots except the penalty kicker should stay on our side of the field.

◆ stayOnSide()

bool stayOnSide ( ) const

Returns true if robots should stay on their team's side of the field. See Robocup SSL Rules Law 8.2.1.

Returns
true if robots should stay on their team's side of the field.

◆ updateBall()

void updateBall ( const Ball ball)

Updates the state of the ball used in calculating game state transitions

Parameters
ballThe new ball

◆ updateRefereeCommand()

void updateRefereeCommand ( RefereeCommand  gameState)

Updates the game state with a value from backend_input

Parameters
gameStatethe RefereeCommand from backend_input

The documentation for this class was generated from the following files: