Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_world_observations(agent_host):
- """ get world observations from the agent's most recent world state
- args: malmo agent host (created beforehand in an outer scope)
- return: world observation (dict of info:value)
- """
- world_state = agent_host.peekWorldState()
- while True:
- # valid world state: get observations
- if world_state.number_of_observations_since_last_state > 0:
- msg = world_state.observations[-1].text
- obs = json.loads(msg)
- # check for any errors
- for err in world_state.errors:
- logging.error(err)
- if "entities" not in obs:
- logging.error("no entities in the world")
- exit(1)
- return obs
- # invalid world state: get another one asap
- else:
- world_state = agent_host.getWorldState()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement