It occured to me that it might be beneficial to show the state transition diagram for the above state machine.
+--------------------------------------------------+
| |
| _______ |
| left / \ right |
| +------------|initial|-----------------+ |
| | \_______/ | |
| | | |
| | +--------+ | |
| ___V___ | | | |
|left / \ right | _V__V_V_
+-----| red |--------------+ | left / \ right
\_______/ | +------| blue |------+
^ | \________/ |
| | |
| | |
| __V____ |
| left / \ right |
| +-----| end |------+ |
| | \_______/ | |
| | ^ ^ | |
| | | | | |
| +-------+ +---------+ |
| |
+-------------------------------------------------+
-- All code is 100% tested and functional unless otherwise noted.