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)
def test_level_completed(): board = [" ", " ", "<."] new_state = pacman.tick(pacman.State(board)) eq_(new_state.board, [" ", " ", " <"]) eq_(new_state.status, pacman.LEVEL_COMPLETED)
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)
def test_ghost_movement_right_near_the_wall(): state = pacman.State(["<.", "..", "@#", ".."]) new_state = pacman.tick(state) eq_(new_state.board, [" <", "..", "@#", ".."])
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)
def test_ghost_movement_right_without_dot(): state = pacman.State(["<.", "..", "o ", ".."]) new_state = pacman.tick(state) eq_(new_state.board, [" <", "..", " o", ".."])
def test_ghost_movement_right_from_dot_to_no_dot(): state = pacman.State(["<.", "..", "o.", ".."]) new_state = pacman.tick(state) eq_(new_state.board, [" <", "..", " @", ".."])
def test_wall(): state = pacman.State(["<#"]) new_state = pacman.tick(state) eq_(new_state.board, ["<#"])
def test_ghost_movement_right_near_edge(): state = pacman.State(["<.", "..", ".@", ".."]) new_state = pacman.tick(state) eq_(new_state.board, [" <", "..", "@.", ".."])
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)
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)
def test_get_score_basic(): state = pacman.State(["<."]) new_state = pacman.tick(state) eq_(new_state.score, 1)
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, ["..", "< ", ".."])
def test_single_tick(): board = pacman.State(["..", ".A", ".."]) new_state = pacman.tick(board) eq_(new_state.board, ["..", ". ", ".A"])