コード例 #1
0
def test_JEN_random_player(board_16x16) -> None:
    goal = BlobGoal((138, 151, 71))
    player = SmartPlayer(2, goal, 2)
    player._proceed = True
    move = player.generate_move(board_16x16)
    assert move is PASS or SMASH or COMBINE or ROTATE_COUNTER_CLOCKWISE or \
    ROTATE_CLOCKWISE or SWAP_VERTICAL or SWAP_HORIZONTAL
コード例 #2
0
def test_player(game_board2):
    random.seed(1)
    goal = BlobGoal(COLOUR_LIST[1])
    player = RandomPlayer(1, goal)
    player._proceed = True
    move = player.generate_move(game_board2)
    print(move)
    player2 = SmartPlayer(1, goal, 100)
    player2._proceed = True
    move2 = player2.generate_move(game_board2)
    print(move2)
コード例 #3
0
def test_JEN_smart_player_not_smart_moves(board_16x16) -> None:
    goal = PerimeterGoal((199, 44, 58))
    player = SmartPlayer(3, goal, 10)
    player._proceed = True
    move = player.generate_move(board_16x16)
    assert move is not COMBINE
    assert move is not ROTATE_CLOCKWISE
    assert move is not ROTATE_COUNTER_CLOCKWISE
    assert move is not SWAP_HORIZONTAL
    assert move is not SWAP_VERTICAL
    assert move is PASS or SMASH
コード例 #4
0
def test_JEN_smart_player(board_16x16) -> None:
    goal = BlobGoal((138, 151, 71))
    player = SmartPlayer(2, goal, 2)
    player._proceed = True
    score1 = goal.score(board_16x16)
    move = player.generate_move(board_16x16)
    while move is SMASH:
        move.generate_move()
    score2 = goal.score(board_16x16)
    assert move is not None
    assert score2 >= score1
コード例 #5
0
def test_unit_board():
    random.seed(1)
    board = generate_board(1, BOARD_SIZE)
    goal = BlobGoal(COLOUR_LIST[1])
    player = RandomPlayer(1, goal)
    player._proceed = True
    move = player.generate_move(board)
    print(move)
    player2 = SmartPlayer(1, goal, 1)
    player2._proceed = True
    move2 = player2.generate_move(board)
    print(move2)
コード例 #6
0
def test_smart_player_generate_move() -> None:
    """ Test the SmartPlayer class' generate_move method. """
    goal = BlobGoal((0, 0, 0))
    player1 = SmartPlayer(1, goal, 4)
    player1._proceed = True
    b1 = Block((0, 0), 1000, (0, 0, 0), 0, 2)

    b1_score = goal.score(b1)

    move1 = player1.generate_move(b1)

    assert isinstance(move1, tuple) and isinstance(move1[0], str) and \
           (isinstance(move1[1], int) or move1[1] is None) and \
           isinstance(move1[2], Block)

    if move1[0:2] == ('rotate', 1):
        assert move1[2].rotate(1)
        assert goal.score(b1) > b1_score
    elif move1[0:2] == ('rotate', 3):
        assert move1[2].rotate(3)
        assert goal.score(b1) > b1_score
    elif move1[0:2] == ('swap', 0):
        assert move1[2].swap(0)
        assert goal.score(b1) > b1_score
    elif move1[0:2] == ('swap', 1):
        assert move1[2].swap(1)
        assert goal.score(b1) > b1_score
    elif move1[0:2] == ('paint', None):
        assert move1[2].paint(self.goal.colour)
        assert goal.score(b1) > b1_score
    elif move1[0:2] == ('combine', None):
        assert move1[2].combine()
        assert goal.score(b1) > b1_score
    else:
        assert move1[0:2] == ('pass', None)
        assert goal.score(b1) == b1_score
コード例 #7
0
ファイル: test.py プロジェクト: Fenil-P/Blocky
 def test_SPGM_good_idea(self) -> None:
     borde = standard_borde()
     bobbito = SmartPlayer(1, BlobGoal(DAFFODIL_DELIGHT))
     bobbito._proceed = True
     assert bobbito.generate_move(borde) == 1 \
            or bobbito.generate_move(borde) == 2