Exemplo n.º 1
0
        rule2 = Rule(c3, [(50, maze1), (50, maze2)])
        with self.assertRaises(ValueError):
            Grammar([rule1, rule2])
        rules = []
        try:
            for wall_number in range(5):
                for combination in combinations(Directions, wall_number):
                    rules.append(Rule(Cell(combination), [(100, maze3)]))
            grammar = Grammar(rules)
        except ValueError:
            self.fail("This grammar should be valid but raised an exception")

if __name__ == '__main__':
    c1 = Cell({Directions.N})
    c2 = Cell({Directions.S})
    c3 = Cell({Directions.N, Directions.E})
    c4 = Cell({})
    maze3 = Maze(2, 1, {(0, 0): c2, (1, 0): c3})
    rules = []
    for wall_number in range(5):
        for combination in combinations(Directions, wall_number):
            rules.append(Rule(Cell(combination), [(100, maze3)]))
    grammar = Grammar(rules)
    print(grammar)

    maze3.pretty_print()
    maze4 = grammar.iterate(maze3)
    maze4.pretty_print()
    
    # unittest.main()