def test_solve_simple_tileset_with_0(): squares = [(0, 0), (0, 1), (1, 1), (1, 2)] tileset = many(DOMINO).and_repeated_exactly(0, MONOMINO) problem = Irregular(squares).tile_with_set(tileset) solution = problem.solve() expected = [[(0, 0), (0, 1)], [(1, 1), (1, 2)]] assert solution.tiling == expected
def test_solve_rotated_one_tile_problem(): tile = TETROMINOS["T"] tileset = many(tile) board = Irregular([(1, 0), (0, 1), (1, 1), (1, 2)]) problem = board.tile_with_set(tileset) solution = problem.solve() assert solution is not None
def test_solve_one_tile_problem(): tile = TETROMINOS["T"] tileset = many(tile) board = Irregular(tile) problem = board.tile_with_set(tileset) solution = problem.solve() assert solution is not None
def test_not_a_single_tile_fits(): tile = [(0, 0), (1, 0), (2, 0), (3, 0)] tileset = many(tile) board = Rectangle(2, 2) with pytest.raises(PolyominoError): problem = board.tile_with_set(tileset) problem.make_problem()
def test_solve_arbitrary_two_tile_problem(tile): tile = TETROMINOS["T"] tileset = many(tile) board = Irregular(tile + [(x, y + 100) for x, y in tile]) problem = board.tile_with_set(tileset) solution = problem.solve() assert solution is not None
def test_13_cylinder_tileset(): tileset = many(TETROMINOS["T"]) assert tileset.mandatory == [] assert tileset.optional == [] assert len(tileset.filler) == 1 assert tileset.reflections == False assert tileset.selector_size == 0
def test_one_tile_problem_is_correct_with_heuristics(): tile = TETROMINOS["T"] tileset = many(tile) board = Irregular(tile) problem = board.tile_with_set(tileset).with_heuristics() problem.make_problem() a = problem.array assert a.shape == (1, 4)
def test_rotated_one_tile_problem_is_correct(): tile = TETROMINOS["T"] tileset = many(tile) board = Irregular([(1, 0), (0, 1), (1, 1), (1, 2)]) problem = board.tile_with_set(tileset) problem.make_problem() a = problem.array assert a.shape == (1, 4)
def test_simple_problem_check_array(): tile = TETROMINOS["T"] tileset = many(tile).and_repeated_exactly(3, MONOMINO) board = Rectangle(3, 5) problem = board.tile_with_set(tileset) problem.make_problem() a = problem.array assert a.shape == (65, 18) expected_sums = np.array([2] * 45 + [4] * 20) np.testing.assert_array_equal(a.sum(axis=1), expected_sums)
def test_right_number_of_tile_positions(l, x, y): assume(l < x and l < y) assume(x * y % l == 0) tile = [(0, i) for i in range(0, l)] tileset = many(tile) board = Rectangle(x, y) size = x * y n_positions = (x - l + 1) * y + x * (y - l + 1) problem = board.tile_with_set(tileset) problem.make_problem() a = problem.array assert a.shape == (n_positions, size)
def test_not_too_many_tile_positions(tile, x, y): assume(x * y % len(tile) == 0) tileset = many(tile) rectangle = Rectangle(x, y) board = Irregular(set(rectangle.squares + tile)) assume(len(board.squares) % len(tile) == 0) expected_size = x * y max_positions = 4 * expected_size problem = board.tile_with_set(tileset) problem.make_problem() a = problem.array n_positions, size = a.shape assert size == expected_size assert n_positions <= max_positions