The Global Clock

Although the game evolves without player intervention, there is an internal ``clock'' that determines when events take place and ensures the correct ordering of events. COMMAND durations, movement speeds, etc. are all defined in terms of ticks of this GLOBAL CLOCK signal. Every time a new event is created, it is added to a global schedule, along with a note specifying when the event will take place. Every time the global clock ticks, the game engine checks to see if any events are scheduled at that time unit and carries out those events.

For example, suppose that the current schedule is as follows:

EVENT Produce($ u_{3}$,$ c_{135}$) Move($ u_{17}$,$ c_{12}$) Attack($ u_{11}$,$ u_{9}$) Spawn($ b_{2}$,Serf)
SCHED TIME 1138 1141 1149 1160

and that the current GLOBAL TIME is 1137. On the next clock tick, the GLOBAL TIME becomes 1138 and the event Produce, applied to UNIT $ u_{3}$ and cell $ c_{135}$, takes place and is removed from the schedule. After Produceing, UNIT $ u_{3}$ is re-scheduled to Produce again at time step 1158 ($ c_{135}$ is a forest cell and produces wood; see Section [*]). Now the schedule appears as follows:

EVENT Move($ u_{17}$,$ c_{12}$) Attack($ u_{11}$,$ u_{9}$) Produce($ u_{3}$,$ c_{135}$) Spawn($ b_{2}$,Serf)
SCHED TIME 1141 1149 1158 1160

On time steps 1139 and 1140 nothing happens. On time step 1141, the Move event takes place and is removed from the schedule. This scheduling and action loop continues until the game ends (Section [*]).

If an event is encountered whose conditions no longer apply (e.g., a Produce event is scheduled for UNIT $ u_{3}$, but $ u_{3}$ no longer exists when the event is encountered), the event MUST be silently dropped. However, care must be taken to de-schedule any events for a UNIT whose COMMAND is changed. For example, suppose that UNIT $ u_{97}$ is scheduled to execute a Build command at GLOBAL TIME 27893, but at GLOBAL TIME 27695, the player changes $ u_{97}$'s COMMAND to Move. The Build COMMAND MUST be de-scheduled before the Move command is scheduled to ensure that $ u_{97}$ does not execute two mutually exclusive COMMANDs.

The GLOBAL CLOCK is maintained on the server to ensure that all clients schedule events according to the same time base.

Terran Lane 2005-11-10