Template Action Generator

The TemplateActionGenerator is designed to facilitate action generation using a game-specific template-action space.

class jericho.template_action_generator.TemplateActionGenerator(rom_bindings)

Generates actions using the template-action-space.

Parameters:rom_bindings (Dictionary) – Game-specific bindings from jericho.FrotzEnv.bindings().
generate_actions(objs)

Given a list of objects present at the current location, returns a list of possible actions. This list represents all combinations of templates filled with the provided objects.

Parameters:objs (List of strings) – Candidate interactive objects present at the current location.
Returns:List of action-strings.
Example:
>>> import jericho
>>> env = jericho.FrotzEnv(rom_path)
>>> interactive_objs = ['phone', 'keys', 'wallet']
>>> env.act_gen.generate_actions(interactive_objs)
['wake', 'wake up', 'wash', ..., 'examine wallet', 'remove phone', 'taste keys']
generate_template_actions(objs, obj_ids)

Given a list of objects and their corresponding vocab_ids, returns a list of possible TemplateActions. This list represents all combinations of templates filled with the provided objects.

Parameters:
  • objs (List of strings) – Candidate interactive objects present at the current location.
  • obj_ids (List of int) – List of ids corresponding to the tokens of each object.
Returns:

List of jericho.defines.TemplateAction.

Example:
>>> import jericho
>>> env = jericho.FrotzEnv(rom_path)
>>> interactive_objs = ['phone', 'keys', 'wallet']
>>> interactive_obj_ids = [718, 325, 64]
>>> env.act_gen.generate_template_actions(interactive_objs, interactive_obj_ids)
[
  TemplateAction(action='wake', template_id=0, obj_ids=[]),
  TemplateAction(action='wake up', template_id=1, obj_ids=[]),
  ...
  TemplateAction(action='turn phone on', template_id=55, obj_ids=[718]),
  TemplateAction(action='put wallet on keys', template_id=65, obj_ids=[64, 325])
 ]