示例#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)
示例#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)
示例#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)
示例#4
0
def test_ghost_movement_right_near_the_wall():
    state = pacman.State(["<.", "..", "@#", ".."])
    new_state = pacman.tick(state)
    eq_(new_state.board, [" <", "..", "@#", ".."])
示例#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)
示例#6
0
def test_ghost_movement_right_without_dot():
    state = pacman.State(["<.", "..", "o ", ".."])
    new_state = pacman.tick(state)
    eq_(new_state.board, [" <", "..", " o", ".."])
示例#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, [" <", "..", " @", ".."])
示例#8
0
def test_wall():
    state = pacman.State(["<#"])
    new_state = pacman.tick(state)
    eq_(new_state.board, ["<#"])
示例#9
0
def test_ghost_movement_right_near_edge():
    state = pacman.State(["<.", "..", ".@", ".."])
    new_state = pacman.tick(state)
    eq_(new_state.board, [" <", "..", "@.", ".."])
示例#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)
示例#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)
示例#12
0
def test_get_score_basic():
    state = pacman.State(["<."])
    new_state = pacman.tick(state)

    eq_(new_state.score, 1)
示例#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, ["..", "< ", ".."])
示例#14
0
def test_single_tick():
    board = pacman.State(["..", ".A", ".."])
    new_state = pacman.tick(board)
    eq_(new_state.board, ["..", ". ", ".A"])