def test_loc_4(self): stage = [ "######################################", " ", " ", " ######## ", " ######## ", " #### ######## ", " ####################### E", "S ###########################", "##### ###############################", "##### ###############################" ] v_map = build_visted_map(stage) start = [9, 6] result = find_possible_moves(start, stage, v_map) print(result) assert 6 == len(result) assert [9, 5] == result[0] assert [7, 3] == result[2] assert [7, 4] == result[1] assert [7, 7] == result[3] assert [7, 8] == result[4] assert [7, 9] == result[5]
def test_fall_to_end(self): stage = [ "######################################", " ", " ", " ######## ", " ######## ", " #### ######## ", " ####################### E", "S ###########################", "##### ###############################", "##### ###############################" ] v_map = build_visted_map(stage) v_map[7][0] = 1 start = [1, 37] assert [6, 37] == fall_move(start, stage, v_map) print(v_map) for i, row in enumerate(v_map): print("ROW: {} {}".format(i, row[0])) if i == 0 or i > 6: assert row[37] == 0 else: assert row[37] == 1
def test_loc_3(self): stage = [ "######################################", " ", " ", " ######## ", " ######## ", " #### ######## ", " ####################### E", "S ###########################", "##### ###############################", "##### ###############################" ] v_map = build_visted_map(stage) v_map[7][1] = 1 start = [7, 2] result = find_possible_moves(start, stage, v_map) assert 4 == len(result) assert [7, 3] == result[0] assert [7, 4] == result[1] assert [9, 5] == result[2] assert [7, 0] == result[3]
def test_fall_move_from_above_to_start(self): stage = [ "######################################", " ", " ", " ######## ", " ######## ", " #### ######## ", " ####################### E", "S ###########################", "##### ###############################", "##### ###############################" ] v_map = build_visted_map(stage) v_map[7][0] = 1 start = [1, 0] assert None == fall_move(start, stage, v_map) print(v_map) for i, row in enumerate(v_map): print("ROW: {} {}".format(i, row[0])) if i == 0 or i > 7: assert row[0] == 0 elif i < 8: assert row[0] == 1
def test_fall_move_from_above_to_floor(self): stage = [ "######################################", " ", " ", " ######## ", " ######## ", " #### ######## ", " ####################### E", "S ###########################", "##### ###############################", "##### ###############################" ] v_map = build_visted_map(stage) v_map[7][0] = 1 start = [1, 5] assert [9, 5] == fall_move(start, stage, v_map) print(v_map) for i, row in enumerate(v_map): print("ROW: {} {}".format(i, row[0])) if i == 0: assert row[5] == 0 else: assert row[5] == 1
def test_fall_case_walled_start(self): stage = [ "# ####################################", " ", " ", " ######## ", " ######## ", " #### ######## ", " ####################### E", "S ###########################", "##### ###############################", "##### ###############################" ] v_map = build_visted_map(stage) v_map[9][6] = 1 start = [8, 3] assert None == fall_move(start, stage, v_map) print(v_map) for i, row in enumerate(v_map): print("ROW: {} {}".format(i, row[0])) if i > 7: assert row[8] == 0 else: assert row[8] == 0
def test_fall_from_sky(self): stage = [ "# ####################################", " ", " ", " ######## ", " ######## ", " #### ######## ", " ####################### E", "S ###########################", "##### ###############################", "##### ###############################" ] v_map = build_visted_map(stage) v_map[7][0] = 1 start = [-3, 1] assert [7, 1] == fall_move(start, stage, v_map) print(v_map) for i, row in enumerate(v_map): print("ROW: {} {}".format(i, row[0])) if i > 7: assert row[1] == 0 else: assert row[1] == 1
def test_case_1(self): stage = [ "######################################", " ", " ", " ######## ", " ######## ", " #### ######## ", " ####################### E", "S ###########################", "##### ###############################", "##### ###############################" ] v_map = build_visted_map(stage) start = find_start(stage) list = build_adjancy_map(start, stage, v_map) print("THE LIST: ", list) assert list["found"] == True
def test_build_visted_map(self): stage = [ "######################################", " ", " ", " ######## ", " ######## ", " #### ######## ", " ####################### E", "S ###########################", "##### ###############################", "##### ###############################" ] map = build_visted_map(stage) assert len(map) == len(stage) assert len(map[0]) == len(stage[0]) assert len(map) == 10 assert len(map[0]) == 38
def test_from_start(self): stage = [ "######################################", " ", " ", " ######## ", " ######## ", " #### ######## ", " ####################### E", "S ###########################", "##### ###############################", "##### ###############################" ] v_map = build_visted_map(stage) start = [7, 0] result = find_possible_moves(start, stage, v_map) assert 3 == len(result) assert [7, 1] == result[0] assert [7, 2] == result[1] assert [7, 3] == result[2]