         state.distance += speed
     }
 
+    /// Updates the `state`'s `currentSpeed` to the next `timeStep`'s speed
     func updateGameSpeed(timeStep: Int) {
         state.currentSpeed = Int(speedMultiplier * log(Double(timeStep+1))) + initialGameSpeed
     }

        initGhostEventQueue(ghostStore.eventSequence, ghostPlayerNumber: ghostPlayerNumber!)
    }
    
    var score: Int {
        return state.distance
    }
    
    var speed: Int {
        return state.currentSpeed
    }
    
    private func initGhostEventQueue(eventSequence: [PlayerEvent], ghostPlayerNumber: Int) {
        let ghostSequence = eventSequence.map {
            (event: $0.event, playerNumber: ghostPlayerNumber, timeStep: $0.timeStep,

class LogicEngine {

    // MARK: Properties
    /// GCD dispatch source that runs LogicEngine in the background
    private var dispatchTimer: dispatch_source_t?
    
    let state: GameState
    private let obstacleGenerator: ObstacleGenerator
    
