The raw algorithm

while the game is not stopped
  // Order for acting
  sort Players/Controllers by priority

  // Actions
  for each Player/Controller
    if command available
      execute the command
      resolve action (can throw some Stimuli and Events)
    else
      do nothing


  // StimuliDispatchers
  for each StimuliDispatcher
    send Stimuli to its listeners
    
  // EventsDispatchers
  for each EventsDispatcher
    send Events to its listeners

  // Plan new actions
  // nc = number of Controllers
  // X  = number of threads for planning
  for i from 1 to (nc div X)
    for j from 1 to N
      start thread j with Controller (i * X + j) as parameter
      wait THREAD_DURATION or all threads finish
      for each thread
        if unfinished
          stop thread
          log error for Controller
          Controller does nothing next turn
  do the same thing for (nc mod X) remaining Controllers

  // End of turn
  log if turn duration is greater than TURN_DURATION
  wait some time if necessary to make the turn duration equal to TURN_DURATION