Closed lazyrenee closed 3 years ago
Good catch. We need to update the documentation. Can you try to load the game first, then access the bindings?
from jericho import *
from jericho.template_action_generator import TemplateActionGenerator
# Instantiate the `FrotzEnv` environment with a game.
env = jericho.FrotzEnv('z-machine-games-master/jericho-game-suite/zork1.z5')
bindings = env.bindings
act_gen = TemplateActionGenerator(bindings)
interactive_objs = ['phone', 'keys', 'wallet']
act_gen.generate_actions(interactive_objs)
Also, for convenience we added the attribute act_gen
to the FrotzEnv
object.
env.act_gen # Which corresponds to `act_gen = TemplateActionGenerator(bindings)`
Thanks for the quick reply and the fixes, very much appreciated! It works for me.
Hi there,
I was trying to generating the action by following the doc's example.
It looks like the
jericho.load_bindings()
doesn't work anymore, and has been changed to_load_bindings()
code.However, when I try with
jericho._load_bindings()
, I got another error with the dictionary parsingKeyError: 'grammar'
I'm assuming the text-game dictionary follows the pattern as suggested here, not quite sure what might be wrong with my action generation. Or there might be a new version of the text-games?
Below are my light-testing codes and errors for reference:
File "/Users/reneejia/opt/anaconda3/lib/python3.7/site-packages/jericho/template_action_generator.py", line 32, in __init__ grammar = rom_bindings['grammar'].split(';') KeyError: 'grammar'
Thanks in advance!