Exemplo n.º 1
0
def main():
    # set up our data
    # generate some players
    players = []
    for i in range(100):
        players.append(generate_player())

    # set up 6 teams
    teams = [
        Team('Chelsea'),
        Team('Man City'),
        Team('Arsenal'),
        Team('West Ham'),
        Team('Hull City'),
        Team('Swansea'),
    ]

    for team in teams:
        for player_num in range(11):
            # give them 11 starting players
            selected_player = random.choice(players)
            team.players.append(selected_player)
            players.remove(selected_player)

    # we have a single league
    first_league = League('Premiership League', teams, players)

    # create the manager
    manager = TeamManager(random.choice(teams), first_league)

    print('Season begins')
    for i in range(10):
        manager.manage()
        first_league.play_round()
    print('Season ends')
Exemplo n.º 2
0
def main():
    # set up the data
    # set up 8 teams
    # only one manager per team
    # only one league

    players = []
    for i in range(100):
        players.append(generate_player())

    # more teams will be added later on
    teams = [
        Team('Toronto Raptors'),
        Team('Los Angeles Lakers'),
        Team('Houston Rockets'),
        Team("Golden State Warriors"),
        Team('Oklahoma City Thunder'),
        Team('Philadelphia 76ers'),
        Team('Portland Trail Blazers'),
        Team('Milwaukee Bucks')
    ]

    for team in teams:
        # give them 5 starting players
        for player_num in range(5):
            selected_player = random.choice(players)
            team.players.append(selected_player)
            players.remove(selected_player)

    # one league
    first_league = League('NBA')
    first_league.set_teams(teams)
Exemplo n.º 3
0
def main():
    #set up our data
    #generate some players
    players = []
    for i in range(100):
        players.append(generate_player())

    #set up 5 teams
    teams = [
        Team('Patriots'),
        Team('Giants'),
        Team('Raiders'),
        Team('Steelers'),
        Team('Seahawks'),
        Team('Cowboys'),
    ]
    for team in teams:
        for player_num in range(11):

            #give them 11 starting players
            selected_player = random.choice(players)
            team.players.append(selected_player)
            players.remove(selected_player)

    #we have a single league
    first_league = League('National Football League', teams, players)

    # create the manager
    manager = TeamManager(random.choice(teams), first_league)

    print('Season begins')
    for i in range(10):
        manager.manage()
        first_league.play_round()
    print('Season ends')
Exemplo n.º 4
0
def pos_comparison():
    p = generate_player()
    print(p)
    print('Player plays: ' + str(p.pos()) + ' and has overall: ' +
          str(p.overall_rating()))
    for pos in Pos.pos_list():
        print('If player played ' + str(pos) + ' then overall would be ' +
              str(p.overall_rating_new_pos(pos)))
Exemplo n.º 5
0
def plot_overall_ratings(n):
    ratings = []
    lowest = 100
    highest = 0
    for i in range(0, n):
        r = generate_player().overall_rating()
        if r > highest: highest = r
        if r < lowest: lowest = r
        ratings.append(r)

    n, bins, patches = plt.hist(ratings, highest - lowest, facecolor='green')

    plt.xlabel('Overall Rating')
    plt.ylabel('Numbers')
    plt.axis([0, 100, 0, 60])

    plt.show()
Exemplo n.º 6
0
def main():
    # Set Up

    # Generate some players
    players = []
    for i in range(100):
        players.append(generate_player())

    # Set up 5 teams
    teams = [
        Team("Chelsea"),
        Team("Man City"),
        Team("Arsenal"),
        Team("West Ham"),
        Team("Man Utd"),
        Team("Hull City"),
    ]

    # Giving players to team
    for team in teams:
        for player_num in range(11):
            selected_player = random.choice(players)
            team.players.append(selected_player)
            players.remove(selected_player)

    # We have a single league
    first_league = League("Premiership League", teams, players)
    first_league.set_teams(teams)

    # create the manager
    manager = TeamManager(random.choice(teams), first_league)

    print("Season begins...")
    for i in range(10):
        manager.manage()
        first_league.play_round()
    print("Season ends...")

    print("*" * 30)
    print("Your final score card.")
    manager.get_team_status()
    print("*" * 30)
Exemplo n.º 7
0
def main():
    # generate some players
    players = []
    for i in range(100):
        players.append(generate_player())

    # set up the teams
    teams = [
        Team('chelsea'),
        Team('Man City'),
        Team('Hull City'),
        Team('West Hamy'),
        Team('Arsenal'),
        Team('Swansea')
    ]

    for team in teams:
        for player_num in range(11):
            # give the team some players
            selected_player = random.choice(players)
            team.players.append(selected_player)
            players.remove(selected_player)

    # create a manager
        manager = Team_Manager(random.choice(teams))

    # we have a single league
    first_league = League('Premiership League')
    first_league.add_teams(teams)

    print('season begins ')
    for i in range(10):
        first_league.play_round()
    print('Season ends')

    # print the players and teams and league
    for team in first_league.teams:
        print(team.name)
        for player in team.players:
            print(player.name),
        print("\n")
Exemplo n.º 8
0
def player_group(n):
    for i in range(0, n):
        p = generate_player()
        print(str(p) + '|| Overall: ' + str(p.overall_rating()) + '\n')