- parts = name.split(".")
- obj = self._state
- for p in parts[:-1]:
- if isinstance(obj, dict):
- obj = obj[p]
- elif isinstance(obj, list):
- obj = obj[int(p)]
- else:
- raise KeyError("%r not found in world" % (name,))
- obj[parts[-1]] = value
+ obj, key = self._get_obj(name)
+ obj.append(value)
+
+ def _apply_pop(self, action, updates):
+ for name, pos in updates.items():
+ obj, key = self._get_obj(name)
+ obj.pop(pos)
+
+ def _apply_reset(self, action):
+ self._state = self._build_initial_state()
+
+ def _apply_unknown(self, action, *args, **kw):
+ raise ValueError("Unknown world event action: %r" % (action,))