Ejemplo n.º 1
0
def test_level_end_to_end():
    board = ["<.", ".."]

    new_state = pacman.tick(pacman.State(board))
    eq_(new_state.board, [" <", ".."])
    eq_(new_state.status, pacman.LEVEL_IN_PROGRESS)

    pacman.add_user_input(pacman.DOWN)
    new_state = pacman.tick(new_state)
    eq_(new_state.board, ["  ", ".A"])
    eq_(new_state.status, pacman.LEVEL_IN_PROGRESS)

    pacman.add_user_input(pacman.LEFT)
    new_state = pacman.tick(new_state)
    eq_(new_state.board, ["  ", "> "])
    eq_(new_state.status, pacman.LEVEL_COMPLETED)
Ejemplo n.º 2
0
def test_level_completed():
    board = ["  ", "  ", "<."]
    new_state = pacman.tick(pacman.State(board))
    eq_(new_state.board, ["  ", "  ", " <"])
    eq_(new_state.status, pacman.LEVEL_COMPLETED)
Ejemplo n.º 3
0
def test_level_in_progress():
    board = ["  ", "..", "<."]
    new_state = pacman.tick(pacman.State(board))
    eq_(new_state.board, ["  ", "..", " <"])
    eq_(new_state.status, pacman.LEVEL_IN_PROGRESS)
Ejemplo n.º 4
0
def test_ghost_movement_right_near_the_wall():
    state = pacman.State(["<.", "..", "@#", ".."])
    new_state = pacman.tick(state)
    eq_(new_state.board, [" <", "..", "@#", ".."])
Ejemplo n.º 5
0
def test_ghost_movement_to_pacman():
    state = pacman.State(["..", "..", "@.", ".V"])
    new_state = pacman.tick(state)
    state = pacman.State(["..", "..", ".@", ". "])
    eq_(new_state.status, pacman.LEVEL_FAILED)
Ejemplo n.º 6
0
def test_ghost_movement_right_without_dot():
    state = pacman.State(["<.", "..", "o ", ".."])
    new_state = pacman.tick(state)
    eq_(new_state.board, [" <", "..", " o", ".."])
Ejemplo n.º 7
0
def test_ghost_movement_right_from_dot_to_no_dot():
    state = pacman.State(["<.", "..", "o.", ".."])
    new_state = pacman.tick(state)
    eq_(new_state.board, [" <", "..", " @", ".."])
Ejemplo n.º 8
0
def test_wall():
    state = pacman.State(["<#"])
    new_state = pacman.tick(state)
    eq_(new_state.board, ["<#"])
Ejemplo n.º 9
0
def test_ghost_movement_right_near_edge():
    state = pacman.State(["<.", "..", ".@", ".."])
    new_state = pacman.tick(state)
    eq_(new_state.board, [" <", "..", "@.", ".."])
Ejemplo n.º 10
0
def test_get_score_2score_and_wrap():
    state = pacman.State([".<."])
    new_state = pacman.tick(state)
    new_state = pacman.tick(new_state)

    eq_(new_state.score, 2)
Ejemplo n.º 11
0
def test_get_score_2score_and_space():
    state = pacman.State(["<. ."])
    new_state = pacman.tick(state)
    new_state = pacman.tick(new_state)

    eq_(new_state.score, 1)
Ejemplo n.º 12
0
def test_get_score_basic():
    state = pacman.State(["<."])
    new_state = pacman.tick(state)

    eq_(new_state.score, 1)
Ejemplo n.º 13
0
def test_double_tick_with_user_input():
    state = pacman.State(["..", ".A", ".."])
    pacman.add_user_input(pacman.LEFT)
    pacman.add_user_input(pacman.RIGHT)
    new_state = pacman.tick(state)
    eq_(new_state.board, ["..", "< ", ".."])
Ejemplo n.º 14
0
def test_single_tick():
    board = pacman.State(["..", ".A", ".."])
    new_state = pacman.tick(board)
    eq_(new_state.board, ["..", ". ", ".A"])