New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run z-machine games in parallel #182
Comments
Hi @YunqiuXu, you can still use Here's how. import textworld.gym
env_id = textworld.gym.register_games(['zork1.z5', 'zork2.z5', 'zork3.z5'])
batch_env_id = textworld.gym.make_batch(env_id, batch_size=5)
env = gym.make(batch_env_id)
obs, infos = env.reset()
for i, ob in enumerate(obs):
print(ob)
print("----") NB: of course, for Z-Machine games, no additional infos can be requested, i.e., the second argument of |
Hi @MarcCote , thanks for your reply. I tried your code but there's still some error:
Maybe the error is due to the Is there any method to tackle this? BTW I could run single .z5 game successfully via benchmark.py and I found some z5-related information in https://github.com/microsoft/TextWorld/blob/master/benchmark/games.json |
Okay, I see why. We fixed that in the master branch. We are planning on making a new TextWorld release next week (which will include that fix). In the meantime, you can install the master branch using Regarding the .z5 games generated via benchmark, those are running fine because they were generated by TextWorld along with their .json file. Unfortunately, non-TextWorld games do not some with a .json containing the needed metadata. |
Hi @MarcCote , if |
Hi @vzhong, I think it is easier to understand with an example. Let's assume we have 5 games and batch_size of 2: # E = [g1, g2, g3, g4, g5]
benv_id = textworld.gym.make_batch(env_id, batch_size=2) # Duplicating the environment.
env = gym.make(benv_id)
# E1 = [g1, g2, g3, g4, g5]
# E2 = [g1, g2, g3, g4, g5]
env.seed(123) # Shuffle the order in which the games are going to be played.
# E1 = [g3, g1, g5, g4, g2]
# E2 = [g5, g2, g3, g1, g4]
env.reset() #Playing [g3, g5]
env.reset() #Playing [g1, g1]
...
env.reset() #Playing [g2, g4] As you can see you, in the end, you are playing 2*5 games per "epoch", where each game is seen I understand this behavior differs from what traditionally the term "batch" means. If you actually wanted to split the games in batch, you will have to register |
ah I see - thank you for the detailed response! |
Hi, is there any method to run multiple z-machine games (e.g. zork1.z5) in parallel.
For games generated by
tw-make
this can be done viatextworld.gym.make_batch
, but how can I achieve this on z-machine games?The text was updated successfully, but these errors were encountered: