exception textworld.envs.glulx.git_glulx_ml.ExtraInfosIsMissingError(info)[source]

Bases: NameError

Thrown if extra information is required without enabling it first via tw-extra-infos CMD.

exception textworld.envs.glulx.git_glulx_ml.MissingGameInfosError[source]

Bases: NameError

Thrown if an action requiring GameInfos is used on a game without GameInfos, such as a Frotz game or a Glulx game not generated by TextWorld.

exception textworld.envs.glulx.git_glulx_ml.OraclePolicyIsRequiredError(info)[source]

Bases: NameError

Thrown if an action requiring an Oracle-based reward policy is called without the intermediate reward being active.

exception textworld.envs.glulx.git_glulx_ml.StateTrackingIsRequiredError(info)[source]

Bases: NameError

Thrown if an action requiring state tracking is performed while state tracking is not enabled.

class textworld.envs.glulx.git_glulx_ml.GitGlulxMLEnvironment(gamefile)[source]

Bases: textworld.core.Environment

Environment to support playing Glulx games generated by TextWorld.

TextWorld supports playing text-based games that were compiled for the Glulx virtual machine. The main advantage of using Glulx over Z-Machine is it uses 32-bit data and addresses, so it can handle game files up to four gigabytes long. This comes handy when we want to generate large world with a lot of objects in it.

We use a customized version of git-glulx as the glulx interpreter. That way we don’t rely on stdin/stdout to communicate with the interpreter but instead use UNIX message queues.

Creates a GitGlulxML from the given gamefile

Parameters:gamefile (str) – The name of the gamefile to load.

Enables state tracking.

Return type:None

Ends the game.

Return type:None

Enables intermediate reward computation.

Return type:None
Return type:None

Renders the current state of the game.

Parameters:mode (str) – The mode to use for rendering.
Return type:None

Starts game from the beginning.

Return type:GlulxGameState
Returns:Initial state of the game.

Performs a given command.

Parameters:command (str) – Text command to send to the interpreter.
Return type:Tuple[GlulxGameState, float, bool]
Returns:A tuple containing the new game state, a reward for performing that command and reaching this new state, and whether the game is finished or not.

Determines if the game is still running.

Return type:bool
metadata = {'render.modes': ['human', 'ansi', 'text']}
class textworld.envs.glulx.git_glulx_ml.GlulxGameState(*args, **kwargs)[source]

Bases: textworld.core.GameState

Encapsulates the state of a Glulx game. This is the primary interface to the Glulx game driver.

Takes the same parameters as textworld.GameState :param args: The arguments :param kwargs: The kwargs

init(output, game, state_tracking=False, compute_intermediate_reward=False)[source]

Initialize the game state and set tracking parameters. The tracking parameters, state_tracking and compute_intermediate_reward, are computationally expensive, so are disabled by default.

  • output (str) – Introduction text displayed when a game starts.
  • game (Game) – The glulx game to run
  • state_tracking (bool) – Whether to use state tracking
  • compute_intermediate_reward (bool) – Whether to compute the intermediate reward
update(command, output)[source]

Updates the GameState with the command from the agent and the output from the interpreter. :type command: str :param command: The command sent to the interpreter :type output: str :param output: The output from the interpreter :rtype: GlulxGameState :return: A GameState of the current state


Returns a view of this Game as a GameState :rtype: GlulxGameState :return: A GameState reflecting the current state


Last action that was detected.

Return type:Action

Return the list of admissible commands given the current state.


Return the parser response related to the previous command.

This corresponds to the feedback without the room description, the inventory and the objective (if they are present).


Description at the current location.

It’s usually the output of the “look” command.


Whether the game is finished or not.

Return type:bool

Additional information about the game.

Return type:Mapping[~KT, +VT_co]

Whether the player has lost the game or not.


Whether the player has won the game or not.


Reward indicating how useful the last action was for solving the quest.


Player’s inventory.

It’s usually the output of the “inventory” command.


Max score for this game.

It’s usually the output of the “score” command.


Objective of the game.


Commands to entered in order to complete the quest.


Current score.

It’s usually the output of the “score” command.


Current game state.

Return type:State