# Option play-soccer Selects gamestate according to game manager messages and buttons. ## State Machine ## State initial-ready-and-set
If that state is active,
> | The option initial-ready-and-set is executed.
> | These output symbols are set:
| profiler-collect-mode | = | profiler-collect-mode.dont-collect-profiles
| profiler-write-mode | = | profiler-write-mode.dont-write-profiles
The decision tree:
Pseudo code of the decision tree:
if ( |
( |
( | game.state == game.state.ready | )
( | game.state == game.state.set | )
( | game.state == game.state.initial | )
| )
&& |
( | game.time-since-last-message < 500 | )
| ) | // initial, ready, or set message received
{
transition-to-state(initial-ready-and-set);
}
else if ( |
( | game.state == game.state.penalized | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // penalized message received
{
transition-to-state(penalized);
}
else if ( |
( | game.state == game.state.finished | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // finished message received
{
transition-to-state(finished);
}
else
{
if ( | subsequent-option-reached-target-state | ) | // game started (reached target state)
{
transition-to-state(playing);
}
else
{
transition-to-state(initial-ready-and-set);
}
}
## State playing
If that state is active,
> | The option playing is executed.
> | These output symbols are set:
| sent-game-state | = | sent-game-state.playing
| profiler-collect-mode | = | profiler-collect-mode.dont-collect-profiles
| profiler-write-mode | = | profiler-write-mode.dont-write-profiles
The decision tree:
Pseudo code of the decision tree:
if ( |
( |
( | game.state == game.state.ready | )
( | game.state == game.state.set | )
( | game.state == game.state.initial | )
| )
&& |
( | game.time-since-last-message < 500 | )
| ) | // initial, ready, or set message received
{
transition-to-state(initial-ready-and-set);
}
else if ( |
( | game.state == game.state.penalized | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // penalized message received
{
transition-to-state(penalized);
}
else if ( |
( | game.state == game.state.finished | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // finished message received
{
transition-to-state(finished);
}
else
{
if ( | robot-state.any-back-button-pressed-for-one-second | ) | // one of the back switches pressed for more than one second
{
transition-to-state(penalized);
}
else
{
transition-to-state(playing);
}
}
## State penalized
If that state is active,
> | The basic behavior stand is executed.
> | These output symbols are set:
| head-control-mode | = | head-control-mode.look-between-feet
| sent-game-state | = | sent-game-state.penalized
| leds.back-middle-white | = | back-middle-white.lloo
| profiler-collect-mode | = | profiler-collect-mode.dont-collect-profiles
| profiler-write-mode | = | profiler-write-mode.dont-write-profiles
The decision tree:
Pseudo code of the decision tree:
if ( |
( |
( | game.state == game.state.ready | )
( | game.state == game.state.set | )
( | game.state == game.state.initial | )
| )
&& |
( | game.time-since-last-message < 500 | )
| ) | // initial, ready, or set message received
{
transition-to-state(initial-ready-and-set);
}
else if ( |
( | game.state == game.state.penalized | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // penalized message received
{
transition-to-state(penalized);
}
else if ( |
( | game.state == game.state.finished | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // finished message received
{
transition-to-state(finished);
}
else
{
if ( | robot-state.head-button-pressed-for-three-seconds | ) | // head pressed for 3 seconds
{
transition-to-state(initial-ready-and-set);
}
else if ( | robot-state.head-button-pressed-short-and-released | ) | // head pressed short
{
transition-to-state(playing);
}
else if ( |
( | game.state == game.state.playing | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // playing message received
{
transition-to-state(playing);
}
else
{
transition-to-state(penalized);
}
}
## State finished
If that state is active,
> | The option finished is executed.
> | These output symbols are set:
| profiler-collect-mode | = | profiler-collect-mode.dont-collect-profiles
| profiler-write-mode | = | profiler-write-mode.dont-write-profiles
The decision tree:
Pseudo code of the decision tree:
if ( |
( |
( | game.state == game.state.ready | )
( | game.state == game.state.set | )
( | game.state == game.state.initial | )
| )
&& |
( | game.time-since-last-message < 500 | )
| ) | // initial, ready, or set message received
{
transition-to-state(initial-ready-and-set);
}
else if ( |
( | game.state == game.state.penalized | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // penalized message received
{
transition-to-state(penalized);
}
else if ( |
( | game.state == game.state.finished | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // finished message received
{
transition-to-state(finished);
}
else
{
if ( |
( | game.state == game.state.playing | )
&& |
( | game.time-since-last-message < 500 | )
| ) | // playing message received
{
transition-to-state(playing);
}
else
{
transition-to-state(finished);
}
}