-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.py
76 lines (66 loc) · 1.79 KB
/
util.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from actions import *
influenceList = ['ambassador', 'assassin', 'captain', 'contessa', 'duke']
influenceToAction = {
'ambassador': 'exchange',
'assassin': 'assassinate',
'captain' : 'steal',
'duke': 'tax'
}
#actionToInfluence
actionToInfluence = {
'exchange': ['ambassador'],
'assassinate': ['assassin'],
'steal': ['captain'],
'tax': ['duke']
}
#blockToInfluence
blockToInfluence = {
'steal': ['ambassador', 'captain'],
'assassinate': ['contessa'],
'foreign aid': ['duke']
}
influenceToBlock = {
'ambassador' : 'steal',
'captain' : 'steal',
'contessa' : 'assassinate',
'duke:' : 'foreign aid'
}
actionToReaction = {
'action': [Block, Challenge, Discard],
'block': [Challenge, Discard],
'challenge': [Discard]
}
reactionToNextAction = {
Action: 'action',
Block: 'block',
Challenge: 'challenge',
Discard: 'discard'
}
basicActions = ['income', 'foreign aid', 'coup']
specialActions = ['steal', 'assassinate', 'exchange', 'tax']
blocks = ['steal', 'assassinate', 'foreign aid']
def ActionGenerator(actionList, playerIndex=0, otherPlayers=[], numInfluences=0):
result = []
actionSet = set(actionList)
for action in actionSet:
if action == 'income':
result += [Income()]
elif action == 'foreign aid':
result += [ForeignAid()]
elif action == 'coup':
result += [Coup(x) for x in otherPlayers]
elif action == 'block':
result += [Block(playerIndex)]
elif action == 'challenge':
result += [Challenge(playerIndex)]
elif action == 'tax':
result += [Tax()]
elif action == 'assassinate':
result += [Assassinate(x) for x in otherPlayers]
elif action == 'exchange':
result += [Exchange()]
elif action == 'steal':
result += [Steal(x) for x in otherPlayers]
elif action == 'discard':
result += [Discard(playerIndex, x) for x in range(numInfluences)]
return result