# Option initial-ready-and-set A state machine for the initial, ready, and set game state. ## State Machine ## State initial-opponent-kick-off
If that state is active,
> | The option initial-set-team-color is executed.
> | These output symbols are set:
| sent-game-state | = | sent-game-state.initial
| head-control-mode | = | head-control-mode.look-straight-ahead
| leds.back-middle-orange | = | back-middle-orange.oooo
| leds.back-front-white | = | back-front-white.lloo
| leds.back-middle-white | = | back-middle-white.lloo
| leds.back-rear-white | = | back-rear-white.lloo
The decision tree:
Pseudo code of the decision tree:
if ( | game.own-team-scored | ) | // own team scored
{
transition-to-state(own-team-scored);
}
else if ( | game.opponent-team-scored | ) | // opponent team scored
{
transition-to-state(opponent-team-scored);
}
else if ( |
( | robot-state.middle-back-button-pressed-short | )
&& |
( | time-of-state-execution > 1000 | )
| ) | // middle back pressed short
{
transition-to-state(initial-own-kick-off);
}
else if ( |
( | game.state == game.state.ready | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // ready message received
{
transition-to-state(ready-opponent-kick-off);
}
else if ( |
( | game.state == game.state.set | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // set message received
{
transition-to-state(set-opponent-kick-off);
}
else if ( |
( | game.state == game.state.playing | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // playing message received
{
transition-to-state(playing);
}
else if ( | another-player-is-in-ready-state | ) | // another player is already in ready state
{
transition-to-state(ready-opponent-kick-off);
}
else if ( |
( | robot-state.head-button-pressed-short | )
&& |
( | time-of-state-execution > 1000 | )
| ) | // head pressed short
{
transition-to-state(ready-opponent-kick-off);
}
else if ( |
( | game.kickoff == game.kickoff.own | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // own kick off message received
{
transition-to-state(initial-own-kick-off);
}
else
{
transition-to-state(initial-opponent-kick-off);
}
## State own-team-scored
If that state is active,
> | The option own-team-scored is executed.
> | These output symbols are set:
| leds.back-front-white | = | back-front-white.llll
| leds.back-middle-white | = | back-middle-white.oooo
| leds.back-rear-white | = | back-rear-white.llll
The decision tree:
Pseudo code of the decision tree:
if ( | subsequent-option-reached-target-state | ) | // cheering finished
{
transition-to-state(ready-opponent-kick-off);
}
else
{
transition-to-state(own-team-scored);
}
## State ready-opponent-kick-off
If that state is active,
> | The option go-to-kickoff-position is executed. Parameters:
| go-to-kickoff-position.x | = | kickoff.x( kickoff.rolenumber , 0 ) ;
| go-to-kickoff-position.y | = | kickoff.y( kickoff.rolenumber , 0 ) ;
| go-to-kickoff-position.angle | = | kickoff.angle( kickoff.rolenumber , 0 ) ;
> | These output symbols are set:
| sent-game-state | = | sent-game-state.ready
| leds.back-middle-orange | = | back-middle-orange.oooo
| leds.back-front-white | = | back-front-white.llll
| leds.back-middle-white | = | back-middle-white.oooo
| leds.back-rear-white | = | back-rear-white.llll
The decision tree:
Pseudo code of the decision tree:
if ( |
( | robot-state.head-button-pressed-short | )
&& |
( | time-of-state-execution > 1000 | )
| ) | // head pressed short
{
transition-to-state(set-opponent-kick-off);
}
else if ( |
( | game.state == game.state.initial | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // initial message received
{
transition-to-state(initial-opponent-kick-off);
}
else if ( |
( | game.state == game.state.set | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // set message received
{
transition-to-state(set-opponent-kick-off);
}
else if ( | game.state == game.state.playing | ) | // playing message received
{
transition-to-state(playing);
}
else if ( | subsequent-option-reached-target-state | ) | // arrived
{
transition-to-state(set-opponent-kick-off);
}
else if ( |
( | game.kickoff == game.kickoff.own | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // own kick off message received
{
transition-to-state(ready-own-kick-off);
}
else
{
transition-to-state(ready-opponent-kick-off);
}
## State set-opponent-kick-off
If that state is active,
> | The basic behavior stand is executed.
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-auto
| sent-game-state | = | sent-game-state.set
| leds.back-middle-orange | = | back-middle-orange.oooo
| leds.back-front-white | = | back-front-white.llll
| leds.back-middle-white | = | back-middle-white.lloo
| leds.back-rear-white | = | back-rear-white.llll
The decision tree:
Pseudo code of the decision tree:
if ( |
( | robot-state.head-button-pressed-short | )
&& |
( | time-of-state-execution > 1000 | )
| ) | // head pressed short
{
transition-to-state(playing);
}
else if ( |
( | game.state == game.state.initial | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // initial message received
{
transition-to-state(initial-opponent-kick-off);
}
else if ( |
( | game.state == game.state.ready | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // ready message received
{
transition-to-state(ready-opponent-kick-off);
}
else if ( |
( | game.state == game.state.playing | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // playing message received
{
transition-to-state(playing);
}
else if ( |
( | game.kickoff == game.kickoff.own | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // own kick off message received
{
transition-to-state(set-own-kick-off);
}
else
{
transition-to-state(set-opponent-kick-off);
}
## State initial-own-kick-off
If that state is active,
> | The option initial-set-team-color is executed.
> | These output symbols are set:
| sent-game-state | = | sent-game-state.initial
| head-control-mode | = | head-control-mode.look-straight-ahead
| leds.back-middle-orange | = | back-middle-orange.llll
| leds.back-front-white | = | back-front-white.lloo
| leds.back-middle-white | = | back-middle-white.lloo
| leds.back-rear-white | = | back-rear-white.lloo
The decision tree:
Pseudo code of the decision tree:
if ( |
( | robot-state.middle-back-button-pressed-short | )
&& |
( | time-of-state-execution > 1000 | )
| ) | // middle back pressed short
{
transition-to-state(initial-opponent-kick-off);
}
else if ( |
( | game.state == game.state.ready | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // ready message received
{
transition-to-state(ready-own-kick-off);
}
else if ( |
( | game.state == game.state.set | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // set message received
{
transition-to-state(set-own-kick-off);
}
else if ( |
( | game.state == game.state.playing | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // playing message received
{
transition-to-state(playing);
}
else if ( | another-player-is-in-ready-state | ) | // another player is already in ready state
{
transition-to-state(ready-own-kick-off);
}
else if ( |
( | robot-state.head-button-pressed-short | )
&& |
( | time-of-state-execution > 1000 | )
| ) | // head pressed short
{
transition-to-state(ready-own-kick-off);
}
else if ( |
( | game.kickoff == game.kickoff.opponent | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // opponent kick off message received
{
transition-to-state(initial-opponent-kick-off);
}
else
{
transition-to-state(initial-own-kick-off);
}
## State opponent-team-scored
If that state is active,
> | The option opponent-team-scored is executed.
> | These output symbols are set:
| leds.back-front-white | = | back-front-white.llll
| leds.back-middle-white | = | back-middle-white.oooo
| leds.back-rear-white | = | back-rear-white.llll
The decision tree:
Pseudo code of the decision tree:
if ( | subsequent-option-reached-target-state | ) | // cheering finished
{
transition-to-state(ready-own-kick-off);
}
else
{
transition-to-state(opponent-team-scored);
}
## State ready-own-kick-off
If that state is active,
> | The option go-to-kickoff-position is executed. Parameters:
| go-to-kickoff-position.x | = | kickoff.x( kickoff.rolenumber , 1 ) ;
| go-to-kickoff-position.y | = | kickoff.y( kickoff.rolenumber , 1 ) ;
| go-to-kickoff-position.angle | = | kickoff.angle( kickoff.rolenumber , 1 ) ;
> | These output symbols are set:
| sent-game-state | = | sent-game-state.ready
| leds.back-middle-orange | = | back-middle-orange.llll
| leds.back-front-white | = | back-front-white.llll
| leds.back-middle-white | = | back-middle-white.oooo
| leds.back-rear-white | = | back-rear-white.llll
The decision tree:
Pseudo code of the decision tree:
if ( |
( | robot-state.head-button-pressed-short | )
&& |
( | time-of-state-execution > 1000 | )
| ) | // head pressed short
{
transition-to-state(set-own-kick-off);
}
else if ( |
( | game.state == game.state.initial | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // initial message received
{
transition-to-state(initial-own-kick-off);
}
else if ( |
( | game.state == game.state.set | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // set message received
{
transition-to-state(set-own-kick-off);
}
else if ( |
( | game.state == game.state.playing | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // playing message received
{
transition-to-state(playing);
}
else if ( | subsequent-option-reached-target-state | ) | // arrived
{
transition-to-state(set-own-kick-off);
}
else if ( |
( | game.kickoff == game.kickoff.opponent | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // opponent kick off message received
{
transition-to-state(ready-opponent-kick-off);
}
else
{
transition-to-state(ready-own-kick-off);
}
## State set-own-kick-off
If that state is active,
> | The option set-before-own-kickoff is executed.
> | These output symbols are set:
| head-control-mode | = | head-control-mode.search-auto
| sent-game-state | = | sent-game-state.set
| leds.back-middle-orange | = | back-middle-orange.llll
| leds.back-front-white | = | back-front-white.llll
| leds.back-middle-white | = | back-middle-white.lloo
| leds.back-rear-white | = | back-rear-white.llll
The decision tree:
Pseudo code of the decision tree:
if ( |
( | robot-state.head-button-pressed-short | )
&& |
( | time-of-state-execution > 1000 | )
| ) | // head pressed short
{
transition-to-state(playing);
}
else if ( |
( | game.state == game.state.initial | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // initial message received
{
transition-to-state(initial-own-kick-off);
}
else if ( |
( | game.state == game.state.ready | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // ready message received
{
transition-to-state(ready-own-kick-off);
}
else if ( |
( | game.state == game.state.playing | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // playing message received
{
transition-to-state(playing);
}
else if ( |
( | game.kickoff == game.kickoff.opponent | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // opponent kick off message received
{
transition-to-state(set-opponent-kick-off);
}
else
{
transition-to-state(set-own-kick-off);
}
## State playing
This state is a target state.
If that state is active,
> | The option playing is executed.
> | These output symbols are set:
| sent-game-state | = | sent-game-state.playing
The decision tree:
Pseudo code of the decision tree:
if ( |
( | game.state == game.state.initial | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // initial message received
{
transition-to-state(initial-opponent-kick-off);
}
else if ( |
( | game.state == game.state.ready | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // ready message received
{
transition-to-state(ready-opponent-kick-off);
}
else if ( |
( | game.state == game.state.set | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // set message received
{
transition-to-state(set-opponent-kick-off);
}
else
{
transition-to-state(playing);
}