Chapter 2.2.3 - The States
All states have to be derived by Strategies::State (described in strategies/state.h). This abstract class provides the following methods:
It is called every time a new game starts to clear the states and set the initial setting.
For each message XY (e.g. collisions, coordinates, radar infos) the Realtime Battle Server is able to send during a running game (see rtb protocol for details), the corresponding method of the current state is invoked. For example, if you are interested in your energy level, simply overwrite the method
All client states are also inherited from Strategies::ClientState (strategies/clientstate.h) that additionally provides the following methods:
This method is called after all messages from the RealTimeBattle server are received in this round and were already sent to the master server. Use this message to do all calculations that can be made until the server tips will arrive.
This method is called for every server tip sent by the server states of the corresponding server coordinator in the master server. Use this method to react according the tips of the master server part of your strategy.
If this method is called, you should send the pending commands to the Realtime Battle server.
Use these messages to send any kind of allowed commands XY to the Realtime Battle server (e.g. to shoot, use method
sendRTBMessageShoot()), see the header file and the rtb protocol for details.
Use this method to switch to another client state. This is necessary if your robot wants to change to another internal state (for example from attacking to braking). Since the new state is described by a scalar value, it is a good idea to define an enumeration for the different states (see notes about writing a strategy).
All server states are also inherited from Strategies::ServerState (strategies/serverstate.h) that additionally provides the following methods:
Use this method to send a strategy defined server tip to the corresponding client coordinator / current client state.
If this method is invoked, you should send your last server tips to the client.
With this method, you can switch to another server state. Also in this case you should make use of an enumeration to identify you states (see notes about writing a strategy).