def deserialize(cls, data: Mapping) -> "Game": """ Creates a `Game` from serialized data. Args: data: Serialized data with the needed information to build a `Game` object. """ world = World.deserialize(data["world"]) grammar = None if "grammar" in data: grammar = Grammar(data["grammar"]) quests = [Quest.deserialize(d) for d in data["quests"]] game = cls(world, grammar, quests) game._infos = {k: EntityInfo.deserialize(v) for k, v in data["infos"]} game.state = State.deserialize(data["state"]) game._rules = {k: Rule.deserialize(v) for k, v in data["rules"]} game._types = VariableTypeTree.deserialize(data["types"]) game.metadata = data.get("metadata", {}) return game
def deserialize(cls, data: Mapping) -> "Game": """ Creates a `Game` from serialized data. Args: data: Serialized data with the needed information to build a `Game` object. """ world = World.deserialize(data["world"]) game = cls(world) if "grammar" in data: game.grammar = Grammar(data["grammar"]) game.quests = [Quest.deserialize(d) for d in data["quests"]] game._infos = {k: EntityInfo.deserialize(v) for k, v in data["infos"]} game.state = State.deserialize(data["state"]) game.kb = KnowledgeBase.deserialize(data["KB"]) game.metadata = data.get("metadata", {}) game._objective = data.get("objective", None) return game