             self.outputs = Array(outputs.values)
         } else {
             self.outputs = []
+        }
+        
+        if let observers = observers {
+            self.observers = Array(observers.values)
+        } else {
+            self.observers = []
         }
 
         self.onStateUpdate = onStateUpdate

            _ = self.context?.evaluateScript("game.receiveInput(sensor, input)")
        }
    }
}

import JavaScriptCore

public typealias StateUpdateBlock = (String) -> Void
public typealias ObserverBlock = (Any?) -> Void

public class Game {
    fileprivate let context = JSContext()

    public let inputs:[Input]
    public let outputs:[Output]
    public let observers:[ObserverBlock]

    public var onStateUpdate: StateUpdateBlock?

    public init(story:String, inputs:[String:Input]?, outputs:[String:Output]?, observers:[String:ObserverBlock]?, onStateUpdate:StateUpdateBlock?) {
        if let inputs = inputs {
            self.inputs = Array(inputs.values)
        } else {
