- Timestamp:
- 08/20/2016 05:52:14 PM (8 years ago)
- branch-nick:
- state
- revision id:
- dsowen@fugue88.ws-20160820175214-brf0y4zu97rxsoft
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main.py
r6.1.5 r6.1.6 58 58 team_failures = 0 59 59 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 60 83 61 84 def perform_mission(): … … 86 109 print("Mission {} needs {} members".format(mission, team_size)) 87 110 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() 103 112 104 113 if approved:
Note: See TracChangeset
for help on using the changeset viewer.