Changes in [1:3]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main.py

    r1 r3  
    1010
    1111    def reveal_spies(self, spies):
     12        """If this player is a spy, this method will be called to reveal the identities
     13        of *all* the spies (including this player).
     14
     15        It is passed as an array of IDs.
     16
     17        """
    1218        pass
    1319
    1420    def propose_team(self, count):
     21        """Asks the player to propose a team as a team-lead.
     22
     23        Must return an array of `count` unique IDs.  The proposed team may
     24        include the player, but does not need to.
     25
     26        """
    1527        team = list(range(self.count))
    1628        shuffle(team)
     
    1830
    1931    def approve_team(self, team):
     32        """Asks the player to vote on a proposed team.
     33
     34        True indicates approval, False disapproval.  The player will be asked
     35        to vote on all teams, even one that it proposes.
     36
     37        """
    2038        return True
    2139
    2240    def observe_team_vote(self, approved, votes):
     41        """Allows the player to observe the outcome of a vote to approve a proposed
     42        team.
     43
     44        The final result is given as `approved`, and individual votes (ordered
     45        by player ID) are given as an array as `votes`.
     46
     47        """
    2348        pass
    2449
    2550    def perform_mission(self):
     51        """If this player is a spy, called to ask the player whether to fail the
     52        mission.
     53
     54        True indicates that this player will not cause a failure, False that it
     55        will cause a failure.
     56
     57        Note that some missions require 2 players to attempt a mission failure
     58        to actually fail the mission.
     59
     60        """
    2661        return False
    2762
    2863    def observe_mission(self, success, failures):
     64        """Allows the player to observe the outcome of a mission.
     65
     66        The final result is given as `success`.  The number of failures is
     67        given (as an integer) as `failures`.
     68
     69        """
    2970        pass
    3071
    3172    def observe_game(self, success):
     73        """Allows the player to observe the outcome of the game.
     74
     75        True indicates the Resistance won, False the Government (spies).
     76
     77        """
    3278        pass
    3379
     
    58104    def observe_mission(self, success, failures):
    59105        pass
    60 
    61106
    62107
     
    108153    losses = 0
    109154    captain = 0
     155    team_failures = 0
    110156
    111157    for mission in range(1, 6):
     
    129175            captain = (captain + 1) % player_count
    130176            if approved:
     177                team_failures = 0
    131178                failures = 0
    132179                for i in team:
     
    158205                break
    159206            else:
    160                 pass
    161 
    162 main(10)
     207                team_failures += 1
     208                if team_failures == 5:
     209                    print("The spies won!")
     210                    for p in players:
     211                        p.observe_game(False)
     212                    return
     213
     214
     215if __name__ == '__main__':
     216    main(10)
Note: See TracChangeset for help on using the changeset viewer.