Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
def test_Highest_Greedy_Score__NoDisks(score, max_score):
    """Function highest_greedy_score: No disks."""
    max_score.value += 3
    try:
        set_up()
        test_board_4_copy = Board.get_board_copy(test_board_4)
        highest_score, columns = Drop7.highest_greedy_score(test_board_4, [])
        assert highest_score == 0
        assert len(columns) == 0
        assert are_identical_boards(test_board_4, test_board_4_alias)
        assert are_equal_boards(test_board_4, test_board_4_copy)
        score.value += 3
    except:
        pass
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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