Glulx

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.
activate_state_tracking()[source]

Enables state tracking.

Return type:None
close()[source]

Ends the game.

Return type:None
compute_intermediate_reward()[source]

Enables intermediate reward computation.

Return type:None
enable_extra_info(info)[source]
Return type:None
render(mode='human')[source]

Renders the current state of the game.

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

Starts game from the beginning.

Return type:GlulxGameState
Returns:Initial state of the game.
step(command)[source]

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.
game_running

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.

Parameters:
  • 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

view()[source]

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

action

Last action that was detected.

Return type:Action
admissible_commands

Return the list of admissible commands given the current state.

command_feedback

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).

command_templates
description

Description at the current location.

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

entities
extras
game_ended

Whether the game is finished or not.

Return type:bool
game_infos

Additional information about the game.

Return type:Mapping[~KT, +VT_co]
has_lost

Whether the player has lost the game or not.

has_won

Whether the player has won the game or not.

intermediate_reward

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

inventory

Player’s inventory.

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

max_score

Max score for this game.

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

objective

Objective of the game.

policy_commands

Commands to entered in order to complete the quest.

score

Current score.

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

state

Current game state.

Return type:State
verbs