def test_diagonal_locations_for_size_13(): """ Same as above, but for size 13. Only checks one location per sector """ maze, _ = create_maze_and_leftover(size=13) assert maze[BoardLocation(4, 8)].rotation == 90 assert maze[BoardLocation(8, 8)].rotation == 180 assert maze[BoardLocation(8, 4)].rotation == 270 assert maze[BoardLocation(4, 4)].rotation == 0
def test_create_maze_and_leftover_no_cross_for_size_11(): """ Tests create_maze_and_leftover. Checks that there is no cross maze card for size 11, because it is not of the form 4k + 1. """ maze, leftover = create_maze_and_leftover() assert leftover.out_paths != MazeCard.CROSS for location in maze.maze_locations: assert maze[location].out_paths != MazeCard.CROSS
def test_create_maze_and_leftover_fixed_pieces_for_size_9(): """ Tests create_maze_and_leftover. Checks corners, fixed t-juncts, and cross center. """ maze, _ = create_maze_and_leftover(size=9) _assert_corners(maze) _assert_fixed_pieces_t_juncts(maze) _assert_cross_center(maze)
def test_diagonal_locations_for_size_7(): """ Checks that the maze cards on the diagonals are rotated such that the cards on the center-to-NE look like a T (T_JUNCT rotated by 90), and the clockwise subsequent ones are successively rotated by 90 degrees. """ maze, _ = create_maze_and_leftover() assert maze[BoardLocation(2, 4)].rotation == 90 assert maze[BoardLocation(4, 4)].rotation == 180 assert maze[BoardLocation(4, 2)].rotation == 270 assert maze[BoardLocation(2, 2)].rotation == 0
def test_create_maze_and_leftover_distribution_for_size_7(): """ Tests create_maze_and_leftover. Checks maze card type distribution. """ maze, leftover = create_maze_and_leftover() out_paths = [maze[location].out_paths for location in maze.maze_locations] out_paths.append(leftover.out_paths) assert len(out_paths) == 50 counts = Counter(out_paths) assert counts[MazeCard.CORNER] == 19 assert counts[MazeCard.T_JUNCT] == 18 assert counts[MazeCard.STRAIGHT] == 13
def test_create_maze_and_leftover_distribution_for_size_13(): """ Tests create_maze_and_leftover. Checks maze card type distribution for non-fixed cards in a maze of size 13. The distribution should by approximately equal to the non-fixed distribution of the original game, i.e. (15, 6, 13) for corners, t-juncts, and straights. """ size = 13 maze, leftover = create_maze_and_leftover(size=size) out_paths = [maze[location].out_paths for location in maze.maze_locations] out_paths.append(leftover.out_paths) assert len(out_paths) == 170 non_fixed = len(out_paths) - 49 counts = Counter(out_paths) assert counts[MazeCard.CROSS] == 1 approx_expected_corners = math.floor(15 / 34 * non_fixed + 4) approx_expected_t_juncts = math.floor(6 / 34 * non_fixed + 44) approx_expected_straights = math.floor(13 / 34 * non_fixed) assert approx_expected_corners <= counts[MazeCard.CORNER] <= approx_expected_corners + 1 assert approx_expected_t_juncts <= counts[MazeCard.T_JUNCT] <= approx_expected_t_juncts + 1 assert approx_expected_straights <= counts[MazeCard.STRAIGHT] <= approx_expected_straights + 1
def test_create_maze_and_leftover_fixed_pieces_for_size_7(): """ Tests create_maze_and_leftover. Checks corners and fixed t-juncts. """ maze, _ = create_maze_and_leftover() _assert_corners(maze) _assert_fixed_pieces_t_juncts(maze)
def test_create_maze_and_leftover_unique_ids_for_size_7(): """ Tests create_maze_and_leftover. Checks unique ids. """ maze, leftover = create_maze_and_leftover() ids = _assert_unique_ids(maze) assert leftover.identifier not in ids