def main():
    args = parse_args()
    game = Game.load(args.game.replace('.ulx', '.json'))
    options = ChainingOptions()
    options.backward = False
    options.max_depth = args.quest_length
    options.max_breadth = args.quest_breadth
    options.rules_per_depth = {}
    options.create_variables = False
    options.rng = np.random.RandomState(args.seed)
    chains = []
    for i in range(args.nb_quests):
        chain = sample_quest(game.world.state, options)
        chains.append(chain)
    inform7 = Inform7Game(game)
    print_chains(chains, inform7)
    filename_world = pjoin(args.output, 'sample_world.png')
    filename_tree = pjoin(args.output, 'sample_tree.svg')
    filename_graph = pjoin(args.output, 'sample_graph.svg')
    (G, labels) = build_tree_from_chains(chains, inform7)
    if (len(G) > 0):
        image = visualize(game)
        image.save(filename_world)
        tree = nx.bfs_tree(G, 'root')
        save_graph_to_svg(tree, labels, filename_tree)
        save_graph_to_svg(G, labels, filename_graph)
    else:
        try:
            os.remove(filename_world)
            os.remove(filename_tree)
            os.remove(filename_graph)
        except OSError:
            pass
def main():
    args = parse_args()
    game = Game.load(args.game.replace('.ulx', '.json'))
    options = ChainingOptions()
    options.backward = False
    options.max_depth = args.quest_length
    options.max_breadth = args.quest_breadth
    options.rules_per_depth = {}
    options.create_variables = False
    options.rng = np.random.RandomState(args.seed)
    chains = []
    for i in range(args.nb_quests):
        chain = sample_quest(game.world.state, options)
        chains.append(chain)
    inform7 = Inform7Game(game)
    print_chains(chains, inform7)
    filename_world = pjoin(args.output, 'sample_world.png')
    filename_tree = pjoin(args.output, 'sample_tree.svg')
    filename_graph = pjoin(args.output, 'sample_graph.svg')
    (G, labels) = build_tree_from_chains(chains, inform7)
    if (len(G) > 0):
        image = visualize(game)
        image.save(filename_world)
        tree = nx.bfs_tree(G, 'root')
        save_graph_to_svg(tree, labels, filename_tree)
        save_graph_to_svg(G, labels, filename_graph)
    else:
        try:
            os.remove(filename_world)
            os.remove(filename_tree)
            os.remove(filename_graph)
        except OSError:
            pass