Esempio n. 1
0
def brute_force(players):
    max_value = 0  # Define our max value starting point.
    numOfCombinations = nCr(len(players), 9)  # Figure out how many teams

    for i, combo in enumerate(itertools.combinations(players, 9)):
        #  Display our progress to the screen
        progress = "\r[{0}/{1}]".format(i, numOfCombinations)
        sys.stdout.write(progress)
        sys.stdout.flush()

        # Create the team
        team = Team(combo)

        # Decide if this team is good or not
        if team.has_positions() and team.get_salary() <= 50000:
            team_value = team.get_value()
            if team_value >= max_value:
                max_value = team_value
                team.display()
Esempio n. 2
0
def brute_force(players):
    max_value = 0  # Define our max value starting point.
    numOfCombinations = nCr(len(players), 9)  # Figure out how many teams

    for i, combo in enumerate(itertools.combinations(players, 9)):
        #  Display our progress to the screen
        progress = "\r[{0}/{1}]".format(i, numOfCombinations)
        sys.stdout.write(progress)
        sys.stdout.flush()

        # Create the team
        team = Team(combo)

        # Decide if this team is good or not
        if team.has_positions() and team.get_salary() <= 50000:
            team_value = team.get_value()
            if team_value >= max_value:
                max_value = team_value
                team.display()
Esempio n. 3
0
def default(players):
    max_value = 0  # Define our max value starting point.
    numOfCombinations = nCr(len(players), 9)  # Figure out how many teams

    qbs = []
    rbs = []
    wrs = []
    flex = []
    tes = []
    defs = []
    for player in players:
        if player.get_position() == "QB":
            qbs.append(player)
        elif player.get_position() == "RB":
            rbs.append(player)
            flex.append(player)
        elif player.get_position() == "WR":
            wrs.append(player)
            flex.append(player)
        elif player.get_position() == "TE":
            tes.append(player)
            flex.append(player)
        elif player.get_position() == "DST":
            defs.append(player)

    print "Calculating cartesian product..."
    teams = cartesian((qbs, rbs, rbs, wrs, wrs, wrs, tes, flex, defs))

    print "Looking for best team..."
    numberOfTeams = len(teams)
    for i, team in enumerate(teams):
        team = Team(team)

        # Decide if this team is good or not
        if team.is_valid() and team.get_salary() <= 50000:
            progress = "\r[{0}/{1}]".format(i, numberOfTeams)
            sys.stdout.write(progress)
            sys.stdout.flush()
            team_value = team.get_value()
            if team_value >= max_value:
                max_value = team_value
                team.display()
Esempio n. 4
0
def default(players):
    max_value = 0  # Define our max value starting point.
    numOfCombinations = nCr(len(players), 9)  # Figure out how many teams

    qbs = []
    rbs = []
    wrs = []
    flex = []
    tes = []
    defs = []
    for player in players:
        if player.get_position() == "QB":
            qbs.append(player)
        elif player.get_position() == "RB":
            rbs.append(player)
            flex.append(player)
        elif player.get_position() == "WR":
            wrs.append(player)
            flex.append(player)
        elif player.get_position() == "TE":
            tes.append(player)
            flex.append(player)
        elif player.get_position() == "DST":
            defs.append(player)

    print "Calculating cartesian product..."
    teams = cartesian((qbs, rbs, rbs, wrs, wrs, wrs, tes, flex, defs))

    print "Looking for best team..."
    numberOfTeams = len(teams)
    for i, team in enumerate(teams):
        team = Team(team)

        # Decide if this team is good or not
        if team.is_valid() and team.get_salary() <= 50000:
            progress = "\r[{0}/{1}]".format(i, numberOfTeams)
            sys.stdout.write(progress)
            sys.stdout.flush()
            team_value = team.get_value()
            if team_value >= max_value:
                max_value = team_value
                team.display()