-
Notifications
You must be signed in to change notification settings - Fork 0
/
spy.py
46 lines (30 loc) · 1023 Bytes
/
spy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from random import *
class Spy:
def __init__(self, num_players, my_index, round_counts, spy_indicies):
self.identity = 'spy'
self.num_players = num_players
self.my_index = my_index
self.round_counts = round_counts
self.spy_indicies = spy_indicies
# game states
self.round = 0
self.missions_lost = 0
self.mission_history = {}
def __str__(self):
return self.identity
def select_mission_team(self):
mission_team = []
num_players_on_mission = self.round_counts[self.round]
# putting myself on the team
mission_team.append(self.my_index)
while len(mission_team) < num_players_on_mission:
rand_player_index = randint(0, self.num_players - 1)
if rand_player_index not in mission_team:
mission_team.append(rand_player_index)
return mission_team
# Vote 1 for approve, 0 for disapprove
def vote_on_mission(self, mission_team):
return 1
# Return a 'P' or 'F'
def go_on_mission(self, mission_team):
return 'F'