def test_bad_exit(): box = generate_empty_box(2, 2, 2) entrance = PanelCoordinate(level=0, y=0, x=0, panel=LEFT) exit = PanelCoordinate(level=1, y=1, x=1, panel=LEFT) with pytest.raises(ValueError) as err: generate_path(entrance, exit, box) assert err.value.message == INVALID_EXIT
def test_impossible_entrance_exit_combo_for_odd_box(): box = generate_empty_box(3, 3, 3) entrance = PanelCoordinate(level=0, y=0, x=0, panel=LEFT) exit = PanelCoordinate(level=0, y=1, x=0, panel=LEFT) # sainity check assert get_coordinate_color(entrance) != get_coordinate_color(exit) with pytest.raises(ValueError) as err: generate_path(entrance, exit, box) assert err.value.message == IMPOSSIBLE_TO_FILL_SPACE
def test_small_two_by_two_box(): box = generate_empty_box(1, 2, 2) entrance = PanelCoordinate(0, 0, 0, LEFT) _exit = PanelCoordinate(0, 1, 0, LEFT) path = generate_path( entrance=entrance, _exit=_exit, box=box, ) assert path == (RIGHT, BACK, LEFT, LEFT)
def test_three_by_three_box(): solutions = ( ('right', 'right', 'back', 'left', 'left', 'back', 'right', 'right', 'right'), ('back', 'back', 'right', 'front', 'front', 'right', 'back', 'back', 'right'), ) box = generate_empty_box(1, 3, 3) entrance = PanelCoordinate(0, 0, 0, LEFT) _exit = PanelCoordinate(0, 2, 2, RIGHT) path = generate_path( entrance=entrance, _exit=_exit, box=box, ) assert path in solutions
def find_paths(): entrance = PanelCoordinate(1, 3, 1, 'back') _exit = PanelCoordinate(1, 0, 1, 'front') while True: path = generate_path( entrance, _exit, generate_empty_box(4, 4, 4), tracker_getter=get_learning_tracker, get_choices_callback=get_learning_move_choices, ) filename = path_to_file_path(path) if os.path.exists(filename): continue print "writing: {0}".format(filename) box = apply_path_to_box(entrance, path, generate_empty_box(4, 4, 4)) export_box(filename, box)
def test_good_entrance_and_exit(): box = generate_empty_box(2, 2, 2) entrance = PanelCoordinate(level=0, y=0, x=0, panel=LEFT) exit = PanelCoordinate(level=1, y=1, x=1, panel=RIGHT) generate_path(entrance, exit, box)