Changeset 6.1.6


Ignore:
Timestamp:
08/20/2016 05:52:14 PM (8 years ago)
Author:
David Owen <dsowen@fugue88.ws>
branch-nick:
state
revision id:
dsowen@fugue88.ws-20160820175214-brf0y4zu97rxsoft
Message:

Extracted assemble_team()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main.py

    r6.1.5 r6.1.6  
    5858    team_failures = 0
    5959    mission = 1
     60    team = None
     61    approved = None
     62
     63    def assemble_team():
     64        nonlocal approved, captain, team
     65
     66        print("Captain is {}".format(captain))
     67        team = players[captain].propose_team(team_size)
     68        print("He proposed {}".format(team))
     69
     70        votes = [p.approve_team(team) for p in players]
     71        approvals = sum(votes)
     72        approved = approvals > team_size / 2
     73
     74        print("Team {}: {} for, {} against".format(
     75            {True: "approved", False: "rejected"}[approved],
     76            approvals, player_count - approvals
     77        ))
     78
     79        for p in players:
     80            p.observe_team_vote(approved, votes)
     81
     82        captain = (captain + 1) % player_count
    6083
    6184    def perform_mission():
     
    86109        print("Mission {} needs {} members".format(mission, team_size))
    87110        for attempt in range(5):
    88             print("Captain is {}".format(captain))
    89             team = players[captain].propose_team(team_size)
    90             print("He proposed {}".format(team))
    91             votes = [p.approve_team(team) for p in players]
    92             approvals = sum(votes)
    93             approved = approvals > team_size / 2
    94             print("Team {}: {} for, {} against".format(
    95                 {True: "approved", False: "rejected"}[approved],
    96                 approvals, player_count - approvals
    97             ))
    98 
    99             for p in players:
    100                 p.observe_team_vote(approved, votes)
    101 
    102             captain = (captain + 1) % player_count
     111            assemble_team()
    103112
    104113            if approved:
Note: See TracChangeset for help on using the changeset viewer.