Wrappers¶
- class textworld.envs.wrappers.recorder.Recorder[source]¶
Bases:
Wrapper
- Parameters:
env – environment to wrap.
- class textworld.envs.wrappers.viewer.HtmlViewer(env, open_automatically=True, port=8080)[source]¶
Bases:
Wrapper
Wrap a TextWorld environment to provide visualization.
During a playthrough, the game can be visualized via local webserver http://localhost:<port>.
:param : The TextWorld environment to wrap. :type : param env: :param : Port to use for the web viewer. :type : param port:
- close()[source]¶
Close the game.
In addition to shutting down the game, this closes the local webserver.
- step(command)[source]¶
Perform a game step.
- Parameters:
command (
str
) – Text command to send to the game engine.- Return type:
Tuple
[GameState
,float
,bool
]- Returns:
game_state – Updated game state.
score – Score for reaching this state.
done – Whether the same is done or not.
- property port¶
- class textworld.envs.wrappers.filter.Filter(env=None)[source]¶
Bases:
Wrapper
Environment wrapper to filter what information is made available.
Requested information will be included within the
infos
dictionary returned byFilter.reset()
andFilter.step(...)
. To request specific information, create atextworld.EnvInfos
and set the appropriate attributes toTrue
. Then, instantiate aFilter
wrapper with theEnvInfos
object.Example
Here is an example of how to request information and retrieve it.
>>> from textworld import EnvInfos >>> from textworld.envs.wrappers import Filter >>> request_infos = EnvInfos(description=True, inventory=True, extras=["more"]) >>> env = textworld.start(gamefile, request_infos) >>> env = Filter(env) >>> ob, infos = env.reset() >>> print(infos["description"]) >>> print(infos["inventory"]) >>> print(infos["extra.more"])
- Parameters:
env (
Optional
[Environment
]) – environment to wrap.