示例#1
0
def _build_mock_player_pool():
    player_pool = [
        Player(name='A1', cost=5500, proj=100, pos='QB',
               team='X', matchup='X@Y'),
        Player(name='A2', cost=5500, proj=41, pos='QB',
               team='X', matchup='X@Y'),
        Player(name='A11', cost=5500, proj=50, pos='WR',
               team='X', matchup='X@Y'),
        Player(name='A3', cost=5500, proj=42, pos='WR',
               team='X', matchup='X@Y'),
        Player(name='A4', cost=5500, proj=43, pos='WR',
               team='X', matchup='X@Y'),
        Player(name='A5', cost=5500, proj=44, pos='WR',
               team='X', matchup='X@Y'),
        Player(name='A6', cost=5500, proj=45, pos='RB',
               team='X', matchup='X@Y'),
        Player(name='A7', cost=5500, proj=46, pos='RB',
               team='X', matchup='X@Y'),
        Player(name='A8', cost=5500, proj=47, pos='RB',
               team='X', matchup='X@Y'),
        Player(name='A9', cost=5500, proj=48, pos='TE',
               team='X', matchup='X@Y'),
        Player(name='A10', cost=5500, proj=49, pos='TE',
               team='X', matchup='X@Y'),
        Player(name='A12', cost=5500, proj=51, pos='DST',
               team='X', matchup='X@Y'),
        Player(name='A14', cost=5500, proj=40, pos='QB',
               team='Y', matchup='X@Y'),
        Player(name='A21', cost=5500, proj=41, pos='QB',
               team='Y', matchup='X@Y'),
        Player(name='A11', cost=5500, proj=50, pos='WR',
               team='Y', matchup='X@Y'),
        Player(name='A31', cost=5500, proj=42, pos='WR',
               team='Y', matchup='X@Y'),
        Player(name='A41', cost=5500, proj=43, pos='WR',
               team='Y', matchup='X@Y'),
        Player(name='A51', cost=5500, proj=54, pos='WR',
               team='Y', matchup='X@Y'),
        Player(name='A61', cost=5500, proj=45, pos='RB',
               team='Y', matchup='X@Y'),
        Player(name='A71', cost=5500, proj=56, pos='RB',
               team='Y', matchup='X@Y'),
        Player(name='A81', cost=5500, proj=47, pos='RB',
               team='Y', matchup='X@Y'),
        Player(name='A91', cost=5500, proj=48, pos='TE',
               team='Y', matchup='X@Y'),
        Player(name='A110', cost=5500, proj=49, pos='TE',
               team='Y', matchup='X@Y'),
        Player(name='A112', cost=5500, proj=60, pos='DST',
               team='Y', matchup='X@Y'),
    ]

    mock_dk_pool = [ShowdownPlayer(p) for p in player_pool] + \
                   [ShowdownPlayer(p, captain=True) for p in player_pool]

    return mock_dk_pool
示例#2
0
def generate_players_from_csvs(
    salary_file_location: str,
    game: str,
    projection_file_location='',
    verbose=False,
    encoding='utf-8',
    errors='replace',
    ruleset=None,
) -> list:
    players = []
    projections = None
    if projection_file_location:
        projections = _generate_projection_dict(
            projection_file_location,
            encoding,
            errors,
        )

    with open(salary_file_location, 'r', encoding=encoding,
              errors=errors) as csv_file:
        csv_data = csv.DictReader(csv_file)
        pos_key = 'Position'
        is_nhl = ruleset and ruleset.league == 'NHL'
        is_showdown = ruleset and ruleset.game_type == 'showdown'
        if is_nhl or is_showdown:
            pos_key = 'Roster Position'

        for row in csv_data:
            if ruleset and ruleset.game_type == 'pickem':
                player = TieredPlayer(
                    cost=0,  # salary not applicable in pickem
                    name=row['Name'],
                    pos=row['Position'],
                    team=row['TeamAbbrev'],
                    matchup=row['Game Info'],
                    average_score=float(row['AvgPointsPerGame']),
                    tier=row['Roster Position'],
                )
                _set_projections(
                    projections,
                    player,
                    verbose,
                )
                players.append(player)
            elif is_showdown:
                pos = row[pos_key]
                player = generate_player(
                    pos=row['Position'],
                    row=row,
                    game=game,
                )
                _set_projections(
                    projections,
                    player,
                    verbose,
                )
                captain = pos == 'CPT'
                players.append(ShowdownPlayer(
                    player,
                    captain=captain,
                ))
            else:
                for pos in row[pos_key].split('/'):
                    if is_nhl and pos == 'UTIL':
                        continue
                    player = generate_player(
                        pos=pos,
                        row=row,
                        game=game,
                    )
                    _set_projections(
                        projections,
                        player,
                        verbose,
                    )

                    players.append(player)

    return players
示例#3
0
def _build_mock_player_pool():
    player_pool = [
        Player(name='A1',
               cost=5500,
               proj=100,
               pos='QB',
               team='X',
               matchup='X@Y'),
        Player(name='A2',
               cost=5500,
               proj=41,
               pos='QB',
               team='X',
               matchup='X@Y'),
        Player(name='A11',
               cost=5500,
               proj=50,
               pos='WR',
               team='X',
               matchup='X@Y'),
        Player(name='A3',
               cost=5500,
               proj=42,
               pos='WR',
               team='X',
               matchup='X@Y'),
        Player(name='A4',
               cost=5500,
               proj=43,
               pos='WR',
               team='X',
               matchup='X@Y'),
        Player(name='A5',
               cost=5500,
               proj=44,
               pos='WR',
               team='X',
               matchup='X@Y'),
        Player(name='A6',
               cost=5500,
               proj=45,
               pos='RB',
               team='X',
               matchup='X@Y'),

        # Test that max players per team works. Everyone
        # on Y is projected for 1 point, under normal
        # opto should never be picked.
        Player(name='A7', cost=5500, proj=1, pos='RB', team='Y',
               matchup='X@Y'),
        Player(name='A8', cost=5500, proj=1, pos='RB', team='Y',
               matchup='X@Y'),
        Player(name='A9', cost=5500, proj=1, pos='TE', team='Y',
               matchup='X@Y'),
    ]

    def capt_boost(p):
        return Player(
            name=p.name,
            team=p.team,
            matchup=p.matchup,
            pos=p.pos,
            cost=p.cost * 1.5,
            proj=p.proj * 1.5,
        )

    captain_pool = [capt_boost(p) for p in player_pool]

    mock_dk_pool = []
    for p in player_pool:
        mock_dk_pool.append(ShowdownPlayer(p))
    for p in captain_pool:
        mock_dk_pool.append(ShowdownPlayer(p, captain=True))

    return mock_dk_pool
示例#4
0
def _build_mock_player_pool():
    player_pool = [
        Player(name='A1',
               cost=5500,
               proj=100,
               pos='QB',
               team='X',
               matchup='X@Y'),
        Player(name='A2',
               cost=5500,
               proj=41,
               pos='QB',
               team='X',
               matchup='X@Y'),
        Player(name='A11',
               cost=5500,
               proj=50,
               pos='WR',
               team='X',
               matchup='X@Y'),
        Player(name='A3',
               cost=5500,
               proj=42,
               pos='WR',
               team='X',
               matchup='X@Y'),
        Player(name='A4',
               cost=5500,
               proj=43,
               pos='WR',
               team='X',
               matchup='X@Y'),
        Player(name='A5',
               cost=5500,
               proj=44,
               pos='WR',
               team='X',
               matchup='X@Y'),
        Player(name='A6',
               cost=5500,
               proj=45,
               pos='RB',
               team='X',
               matchup='X@Y'),
        Player(name='A7',
               cost=5500,
               proj=46,
               pos='RB',
               team='X',
               matchup='X@Y'),
        Player(name='A8',
               cost=5500,
               proj=47,
               pos='RB',
               team='X',
               matchup='X@Y'),
        Player(name='A9',
               cost=5500,
               proj=48,
               pos='TE',
               team='X',
               matchup='X@Y'),
        Player(name='A10',
               cost=5500,
               proj=49,
               pos='TE',
               team='X',
               matchup='X@Y'),
        Player(name='A12',
               cost=5500,
               proj=51,
               pos='DST',
               team='X',
               matchup='X@Y'),
        Player(name='A14',
               cost=5500,
               proj=40,
               pos='QB',
               team='Y',
               matchup='X@Y'),
        Player(name='A21',
               cost=5500,
               proj=41,
               pos='QB',
               team='Y',
               matchup='X@Y'),
        Player(name='A11',
               cost=5500,
               proj=50,
               pos='WR',
               team='Y',
               matchup='X@Y'),
        Player(name='A31',
               cost=5500,
               proj=42,
               pos='WR',
               team='Y',
               matchup='X@Y'),
        Player(name='A41',
               cost=5500,
               proj=43,
               pos='WR',
               team='Y',
               matchup='X@Y'),
        Player(name='A51',
               cost=5500,
               proj=54,
               pos='WR',
               team='Y',
               matchup='X@Y'),
        Player(name='A61',
               cost=5500,
               proj=45,
               pos='RB',
               team='Y',
               matchup='X@Y'),
        Player(name='A71',
               cost=5500,
               proj=56,
               pos='RB',
               team='Y',
               matchup='X@Y'),
        Player(name='A81',
               cost=5500,
               proj=47,
               pos='RB',
               team='Y',
               matchup='X@Y'),
        Player(name='A91',
               cost=5500,
               proj=48,
               pos='TE',
               team='Y',
               matchup='X@Y'),
        Player(name='A110',
               cost=5500,
               proj=49,
               pos='TE',
               team='Y',
               matchup='X@Y'),
        Player(name='A112',
               cost=5500,
               proj=60,
               pos='DST',
               team='Y',
               matchup='X@Y'),
    ]

    def capt_boost(p):
        return Player(
            name=p.name,
            team=p.team,
            matchup=p.matchup,
            pos=p.pos,
            cost=p.cost * 1.5,
            proj=p.proj * 1.5,
        )

    captain_pool = [capt_boost(p) for p in player_pool]

    mock_dk_pool = []
    for p in player_pool:
        mock_dk_pool.append(ShowdownPlayer(p))
    for p in captain_pool:
        mock_dk_pool.append(ShowdownPlayer(p, captain=True))

    return mock_dk_pool
示例#5
0
    Player(name='A110', cost=5500, proj=49, pos='TE',
           team='Y', matchup='X@Y'),
    Player(name='A112', cost=5500, proj=60, pos='DST',
           team='Y', matchup='X@Y'),
]


def capt_boost(p):
    return Player(
        name=p.name,
        team=p.team,
        matchup=p.matchup,
        pos=p.pos,
        cost=p.cost * 1.5,
        proj=p.proj * 1.5,
    )


captain_pool = [capt_boost(p) for p in player_pool]

mock_dk_pool = []
for p in player_pool:
    mock_dk_pool.append(ShowdownPlayer(p))
for p in captain_pool:
    mock_dk_pool.append(ShowdownPlayer(p, captain=True))

run(
    rule_set=rules.DK_NFL_SHOWDOWN_RULE_SET,
    player_pool=mock_dk_pool,
    verbose=True
)