def test_Highest_Greedy_Score__Several_Disks_Not_All_Placable( score, max_score): """Function highest_greedy_score: Several disks that can not all be dropped.""" max_score.value += 14 try: set_up() test_board = Board.init_board( 2, ((cracked_disk_value_2, wrapped_disk_value_1), (wrapped_disk_value_2_B, ))) test_board_copy = Board.get_board_copy(test_board) disks_to_drop = [ visible_disk_value_2, visible_disk_value_2_B, wrapped_disk_value_2_C, wrapped_disk_value_2_D, wrapped_disk_value_2_E, wrapped_disk_value_1_B, wrapped_disk_value_1_C, wrapped_disk_value_1_D ] disks_to_drop_copy = list.copy(disks_to_drop) for i in range(0, len(disks_to_drop_copy)): disks_to_drop_copy[i] = Disk.get_disk_copy(disks_to_drop_copy[i]) highest_score, columns = \ Drop7.highest_greedy_score(test_board, disks_to_drop) assert highest_score == 14 assert columns == (2, 2, 2, 2, 1, 1) assert disks_to_drop == disks_to_drop_copy[6:] actual_score = Drop7.play(test_board_copy, disks_to_drop_copy[:6], columns) assert actual_score == highest_score assert are_equal_boards(test_board, test_board_copy) score.value += 14 except: pass
def test_Highest_Greedy_Score__Single_Placable_Disk(score, max_score): """Function highest_greedy_score: Single disk.""" max_score.value += 6 try: set_up() test_board_6_copy = Board.get_board_copy(test_board_6) disks_to_drop = [visible_disk_value_2_B] disks_to_drop_copy = list.copy(disks_to_drop) highest_score, columns = \ Drop7.highest_greedy_score(test_board_6, disks_to_drop) assert highest_score == 6 assert columns == (6, ) assert len(disks_to_drop) == 0 actual_score = Drop7.play(test_board_6_copy, disks_to_drop_copy, columns) assert actual_score == highest_score assert are_equal_boards(test_board_6, test_board_6_copy) score.value += 6 except: pass
def test_Highest_Greedy_Score__Several_Placable_Disks(score, max_score): """Function highest_greedy_score: Several disks that can all be dropped.""" max_score.value += 14 try: set_up() test_board_6_copy = Board.get_board_copy(test_board_6) disks_to_drop = [ visible_disk_value_4_C, visible_disk_value_5_B, visible_disk_value_3_C ] disks_to_drop_copy = list.copy(disks_to_drop) highest_score, columns = \ Drop7.highest_greedy_score(test_board_6, disks_to_drop) assert highest_score == 40 assert columns == (1, 4, 6) assert len(disks_to_drop) == 0 actual_score = Drop7.play(test_board_6_copy, disks_to_drop_copy, columns) assert actual_score == highest_score assert are_equal_boards(test_board_6, test_board_6_copy) score.value += 14 except: pass
def test_Best_Column_For_Disk_SeveralColumns(score, max_score): """Function best_columns_for_disk: several columns""" max_score.value += 10 try: set_up() board = Board.init_board \ (dimension=6, given_disks= \ ((cracked_disk_value_4,), (cracked_disk_value_4_B, visible_disk_value_5, cracked_disk_value_1, wrapped_disk_value_4), (wrapped_disk_value_4_B, cracked_disk_value_4_C), (visible_disk_value_5_B, wrapped_disk_value_5, visible_disk_value_5_C, visible_disk_value_5_D), (), (cracked_disk_value_1_B, visible_disk_value_5_E, visible_disk_value_5_F, visible_disk_value_5_G) )) board_copy = Board.get_board_copy(board) best_column, highest_score = Drop7.best_drop_for_disk( board, visible_disk_value_2) assert (best_column, highest_score) == (6, 14) actual_score = Drop7.play(board_copy, [visible_disk_value_2], [best_column]) assert actual_score == highest_score assert are_equal_boards(board, board_copy) score.value += 10 except: pass
def test_Best_Columns_For_Disk_SingleColumn(score, max_score): """Function best_columns_for_disk: single column""" max_score.value += 8 try: set_up() board = Board.init_board \ (dimension=6, given_disks= \ ((wrapped_disk_value_3,), (wrapped_disk_value_5, cracked_disk_value_2, cracked_disk_value_1, wrapped_disk_value_4), (wrapped_disk_value_4_B, cracked_disk_value_3), (cracked_disk_value_4, visible_disk_value_5, visible_disk_value_3, cracked_disk_value_5), (), (wrapped_disk_value_3_B, visible_disk_value_3_B))) board_copy = Board.get_board_copy(board) best_column, highest_score = Drop7.best_drop_for_disk( board, visible_disk_value_5_B) assert (best_column, highest_score) == (4, 16) actual_score = Drop7.play(board_copy, [visible_disk_value_5_B], [best_column]) assert actual_score == highest_score assert are_equal_boards(board, board_copy) score.value += 8 except: pass