예제 #1
0
파일: test_maze.py 프로젝트: amos1994/LTP
 def setUp(self):
     self.maze = Maze([['#', '#', '#', '#', '#', '#', '#'],
                       ['#', '.', '.', '.', '.', '.', '#'],
                       ['#', '.', '#', '#', '#', '.', '#'],
                       ['#', '.', '.', '@', '#', '.', '#'],
                       ['#', '@', '#', '.', '@', '.', '#'],
                       ['#', '#', '#', '#', '#', '#', '#']], Rat('J', 1, 1),
                      Rat('P', 1, 4))
예제 #2
0
def test_Maze_str():
    maze = Maze([['#', '#', '#', '#', '#', '#', '#'],
                 ['#', 'J', '@', '.', 'P', '.', '#'],
                 ['#', '.', '#', '#', '#', '.', '#'],
                 ['#', '.', '.', '@', '#', '.', '#'],
                 ['#', '@', '#', '.', '@', '.', '#'],
                 ['#', '#', '#', '#', '#', '#', '#']], Rat('J', 1, 1),
                Rat('P', 1, 4))

    breakpoint()
    assert str(maze) == """#######
예제 #3
0
def test_Maze_is_wall():
    maze = Maze([['#', '#', '#', '#', '#', '#', '#'],
                 ['#', '.', '@', '.', '.', '.', '#'],
                 ['#', '.', '#', '#', '#', '.', '#'],
                 ['#', '.', '.', '@', '#', '.', '#'],
                 ['#', '@', '#', '.', '@', '.', '#'],
                 ['#', '#', '#', '#', '#', '#', '#']], Rat('J', 1, 0),
                Rat('P', 1, 4))

    assert maze.is_wall(maze.rat_1.row, maze.rat_1.col)
    assert not maze.is_wall(maze.rat_2.row, maze.rat_2.col)
예제 #4
0
def test_Maze_get_character():
    maze = Maze([['#', '#', '#', '#', '#', '#', '#'],
                 ['#', 'J', '@', '.', 'P', '.', '#'],
                 ['#', '.', '#', '#', '#', '.', '#'],
                 ['#', '.', '.', '@', '#', '.', '#'],
                 ['#', '@', '#', '.', '@', '.', '#'],
                 ['#', '#', '#', '#', '#', '#', '#']], Rat('J', 1, 1),
                Rat('P', 1, 4))

    assert maze.get_character(1, 1) == "J"
    assert maze.get_character(1, 4) == "P"
    assert maze.get_character(1, 5) == "."
예제 #5
0
def test_Maze_initialization():
    maze = Maze([['#', '#', '#', '#', '#', '#', '#'],
                 ['#', '.', '@', '.', '.', '.', '#'],
                 ['#', '.', '#', '#', '#', '.', '#'],
                 ['#', '.', '.', '@', '#', '.', '#'],
                 ['#', '@', '#', '.', '@', '.', '#'],
                 ['#', '#', '#', '#', '#', '#', '#']], Rat('J', 1, 1),
                Rat('P', 1, 4))

    assert maze.num_sprouts_left == 4
    assert str(maze.rat_1) == "J at (1, 1) ate 0 sprouts."
    assert str(maze.rat_2) == "P at (1, 4) ate 0 sprouts."
예제 #6
0
def test_Maze_move():
    maze = Maze([['#', '#', '#', '#', '#', '#', '#'],
                 ['#', 'J', '@', '.', 'P', '.', '#'],
                 ['#', '.', '#', '#', '#', '.', '#'],
                 ['#', '.', '.', '@', '#', '.', '#'],
                 ['#', '@', '#', '.', '@', '.', '#'],
                 ['#', '#', '#', '#', '#', '#', '#']], Rat('J', 1, 1),
                Rat('P', 1, 4))

    assert maze.move(maze.rat_1, 0, 1)
    assert not maze.move(maze.rat_2, -1, 0)
    assert maze.maze[maze.rat_1.row][maze.rat_1.col] == "."
    assert maze.num_sprouts_left == 3