33# Copyright (c) Microsoft Corporation. All rights reserved.
44# Licensed under the MIT license.
55
6-
6+ import os
77import argparse
8+ from os .path import join as pjoin
9+
810import numpy as np
911
1012import textworld
@@ -14,8 +16,8 @@ def parse_args():
1416 general_parser = argparse .ArgumentParser (add_help = False )
1517
1618 general_group = general_parser .add_argument_group ('General settings' )
17- general_group .add_argument ("--output" , default = "./gen_games /" , metavar = "PATH" ,
18- help = "Output folder to save generated game files ." )
19+ general_group .add_argument ("--output" , default = "./tw_games /" , metavar = "PATH" ,
20+ help = "Path where to save the generated game." )
1921 general_group .add_argument ('--seed' , type = int )
2022 general_group .add_argument ("--view" , action = "store_true" ,
2123 help = "Display the resulting game." )
@@ -64,18 +66,21 @@ if __name__ == "__main__":
6466
6567 print ("Global seed: {}" .format (args .seed ))
6668
67- grammar_flags = {
68- "theme" : args .theme ,
69- "include_adj" : args .include_adj ,
70- "only_last_action" : args .only_last_action ,
71- "blend_instructions" : args .blend_instructions ,
72- "blend_descriptions" : args .blend_descriptions ,
73- "ambiguous_instructions" : args .ambiguous_instructions ,
74- }
69+ options = textworld .GameOptions ()
70+ options .grammar_options .theme = args .theme
71+ options .grammar_options .include_adj = args .include_adj
72+ options .grammar_options .only_last_action = args .only_last_action
73+ options .grammar_options .blend_instructions = args .blend_instructions
74+ options .grammar_options .blend_descriptions = args .blend_descriptions
75+ options .grammar_options .ambiguous_instructions = args .ambiguous_instructions
7576
7677 if args .subcommand == "custom" :
77- game_file , game = textworld .make (args .world_size , args .nb_objects , args .quest_length , args .quest_breadth , grammar_flags ,
78- seed = args .seed , games_dir = args .output )
78+ options .nb_rooms = args .world_size
79+ options .nb_objects = args .nb_objects
80+ options .quest_length = args .quest_length
81+ options .quest_breadth = args .quest_breadth
82+ options .seeds = args .seed
83+ game_file , game = textworld .make (options , args .output )
7984
8085 elif args .subcommand == "challenge" :
8186 _ , challenge , level = args .challenge .split ("-" )
@@ -84,8 +89,8 @@ if __name__ == "__main__":
8489
8590 level = int (level .lstrip ("level" ))
8691 make_game = textworld .challenges .CHALLENGES [challenge ]
87- game = make_game (level = level , grammar_flags = grammar_flags , seeds = args . seed )
88- game_file = textworld .generator .compile_game (game , games_folder = args .output )
92+ game = make_game (level , options )
93+ game_file = textworld .generator .compile_game (game , args .output )
8994
9095 print ("Game generated: {}" .format (game_file ))
9196 if args .verbose :
0 commit comments