示例#1
0
def test_non_contiguous2():
    board = Board()
    tile1 = Tile(Color.RED, Shape.X)
    tile2 = Tile(Color.RED, Shape.CIRCLE)
    move = [(Position(0, 0), tile1), (Position(2, 0), tile2)]
    result = board.is_allowed(move)
    assert not result
示例#2
0
def test_different_color_and_shape():
    board = Board()
    tile1 = Tile(Color.RED, Shape.X)
    tile2 = Tile(Color.GREEN, Shape.CIRCLE)
    move = [(Position(0, 0), tile1), (Position(0, 1), tile2)]
    result = board.is_allowed(move)
    assert not result
示例#3
0
def test_duplicate_position():
    board = Board()
    tile1 = Tile(Color.RED, Shape.X)
    tile2 = Tile(Color.RED, Shape.DIAMOND)
    move = [(Position(0, 0), tile1), (Position(0, 0), tile2)]
    result = board.is_allowed(move)
    assert not result
示例#4
0
def testRepeatedMovePosition():
    tile1 = Tile(Color.RED, Shape.CIRCLE)
    tile2 = Tile(Color.RED, Shape.CLOVER)
    board = Board()
    move = [(Position(0, 0), tile1), (Position(0, 0), tile2)]
    result = board.is_allowed(move)
    assert not result
示例#5
0
def test_valid_move():
    tile1 = Tile(Color.RED, Shape.X)
    board = Board([(Position(0, 0), tile1)])
    tile2 = Tile(Color.RED, Shape.CIRCLE)
    score = board.make_move([(Position(0, 1), tile2)])
    assert score == 2
    tiles = board.tiles
    expected = [(Position(0, 0), tile1), (Position(0, 1), tile2)]
    assert expected == tiles
示例#6
0
def test_illegal_multi_tile_column():
    tile1 = Tile(Color.RED, Shape.X)
    tile2 = Tile(Color.RED, Shape.CIRCLE)
    board = Board([(Position(0, 0), tile1), (Position(0, 1), tile2)])
    tile1 = Tile(Color.YELLOW, Shape.X)
    tile2 = Tile(Color.YELLOW, Shape.CLOVER)
    result = board.is_allowed([(Position(1, 0), tile1), (Position(1,
                                                                  1), tile2)])
    assert not result
示例#7
0
def test_illegal_move():
    tile1 = Tile(Color.RED, Shape.X)
    board = Board([(Position(0, 0), tile1)])
    tile2 = Tile(Color.GREEN, Shape.CIRCLE)
    with pytest.raises(ValueError):
        board.make_move([(Position(0, 1), tile2)])
    tiles = board.tiles
    expected = [Position(Position(0, 0), tile1)]
    assert expected == tiles
示例#8
0
def testMoveOvershadowsExistingTile():
    tile1 = Tile(Color.RED, Shape.CIRCLE)
    tile2 = Tile(Color.RED, Shape.CLOVER)
    board = Board([(Position(0, 0), tile1), (Position(0, 1), tile2)])
    tile1 = Tile(Color.RED, Shape.DIAMOND)
    tile2 = Tile(Color.RED, Shape.SQUARE)
    move = [(Position(0, 1), tile1), (Position(1, 1), tile2)]
    result = board.is_allowed(move)
    assert not result
示例#9
0
def test_second_column_strike():
    tile1 = Tile(Color.RED, Shape.CIRCLE)
    tile2 = Tile(Color.RED, Shape.CLOVER)
    tile3 = Tile(Color.RED, Shape.DIAMOND)
    tile4 = Tile(Color.RED, Shape.CLOVER)
    placements = [(Position(0, 1), tile1), (Position(0, 0), tile2),
                  (Position(0, -1), tile3), (Position(1, -1), tile4)]
    board = Board(placements)
    tile5 = Tile(Color.RED, Shape.CLOVER)
    tile6 = Tile(Color.RED, Shape.CIRCLE)
    move = [(Position(1, 1), tile5), (Position(1, 2), tile6)]
    result = board.is_allowed(move)
    assert result
示例#10
0
def test_qwirkle_score():
    tile1 = Tile(Color.RED, Shape.CIRCLE)
    tile2 = Tile(Color.RED, Shape.CLOVER)
    tile3 = Tile(Color.RED, Shape.DIAMOND)
    tile4 = Tile(Color.RED, Shape.SQUARE)
    tile5 = Tile(Color.RED, Shape.STAR)
    tile6 = Tile(Color.RED, Shape.X)
    board = Board()
    move = [(Position(0, 0), tile1), (Position(1, 0), tile2),
            (Position(2, 0), tile3), (Position(3, 0), tile4),
            (Position(4, 0), tile5), (Position(5, 0), tile6)]
    score = board.make_move(move)
    assert score == 12
示例#11
0
def L_shaped_board():
    tile1 = Tile(Color.RED, Shape.X)
    tile2 = Tile(Color.RED, Shape.CIRCLE)
    tile3 = Tile(Color.RED, Shape.SQUARE)
    tile4 = Tile(Color.RED, Shape.CLOVER)
    tile5 = Tile(Color.GREEN, Shape.CLOVER)
    tile6 = Tile(Color.ORANGE, Shape.CLOVER)
    tile7 = Tile(Color.YELLOW, Shape.CLOVER)
    return Board([(Position(0, 0), tile1), (Position(1, 0), tile2),
                  (Position(2, 0), tile3), (Position(3, 0), tile4),
                  (Position(3, 1), tile5), (Position(3, 2), tile6),
                  (Position(3, 3), tile7)])
示例#12
0
def test_one_tile_above_right_off_center(one_tile):
    board = Board()
    move = (Position(1, 1), one_tile)
    result = board.is_allowed([move])
    assert not result
def test_example_j():
    starting_position = TILES[:19]
    board = Board(starting_position)
    move = TILES[19:20]
    score = board.make_move(move)
    assert score == 9
def test_example_k():
    starting_position = TILES[:20]
    board = Board(starting_position)
    move = TILES[20:23]
    score = board.make_move(move)
    assert score == 18
def test_example_l():
    starting_position = TILES[:23]
    board = Board(starting_position)
    move = TILES[23:25]
    score = board.make_move(move)
    assert score == 9
示例#16
0
def one_piece_board():
    tile = Tile(Color.RED, Shape.X)
    return Board([(Position(0, 0), tile)])
def test_example_f():
    starting_position = TILES[:11]
    board = Board(starting_position)
    move = TILES[11:13]
    score = board.make_move(move)
    assert score == 6
def test_example_i():
    starting_position = TILES[:17]
    board = Board(starting_position)
    move = TILES[17:19]
    score = board.make_move(move)
    assert score == 10
def test_example_b():
    starting_position = TILES[:3]
    board = Board(starting_position)
    move = TILES[3:6]
    score = board.make_move(move)
    assert score == 7
def test_example_a():
    board = Board()
    move = TILES[:3]
    score = board.make_move(move)
    assert score == 3
def test_all():
    # a
    board = Board()
    move = TILES[:3]
    score = board.make_move(move)
    assert score == 3
    # b
    move = TILES[3:6]
    score = board.make_move(move)
    assert score == 7
    # c
    move = TILES[6:7]
    score = board.make_move(move)
    assert 4 == score
    # d
    move = TILES[7:9]
    score = board.make_move(move)
    assert score == 6
    # e
    move = TILES[9:11]
    score = board.make_move(move)
    assert score == 7
    # f
    move = TILES[11:13]
    score = board.make_move(move)
    assert score == 6
    # g
    move = TILES[13:15]
    score = board.make_move(move)
    assert score == 3
    # h
    move = TILES[15:17]
    score = board.make_move(move)
    assert score == 3
    # i
    move = TILES[17:19]
    score = board.make_move(move)
    assert score == 10
    # j
    move = TILES[19:20]
    score = board.make_move(move)
    assert score == 9
    # k
    move = TILES[20:23]
    score = board.make_move(move)
    assert score == 18
    # l
    move = TILES[23:25]
    score = board.make_move(move)
    assert score == 9
示例#22
0
def test_one_tile_belove_left_off_center(one_tile):
    board = Board()
    move = (Position(-1, -1), one_tile)
    result = board.is_allowed([move])
    assert not result
def test_example_h():
    starting_position = TILES[:15]
    board = Board(starting_position)
    move = TILES[15:17]
    score = board.make_move(move)
    assert score == 3
示例#24
0
def test_origin_diagonal(two_tiles):
    board = Board()
    move = [(Position(1, 1), two_tiles[0]), (Position(0, 0), two_tiles[1])]
    result = board.is_allowed(move)
    assert not result
def test_example_d():
    starting_position = TILES[:7]
    board = Board(starting_position)
    move = TILES[7:9]
    score = board.make_move(move)
    assert score == 6
示例#26
0
def test_origin_down(two_tiles):
    board = Board()
    move = [(Position(0, 0), two_tiles[0]), (Position(0, -1), two_tiles[1])]
    result = board.is_allowed(move)
    assert result
def test_example_e():
    starting_position = TILES[:9]
    board = Board(starting_position)
    move = TILES[9:11]
    score = board.make_move(move)
    assert score == 7
示例#28
0
def test_one_tile_in_cener(one_tile):
    board = Board()
    move = (Position(0, 0), one_tile)
    result = board.is_allowed([move])
    assert result
def test_example_c():
    starting_position = TILES[:6]
    board = Board(starting_position)
    move = TILES[6:7]
    score = board.make_move(move)
    assert 4 == score