forked from onp/gmcr-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmdLineGuide.py
88 lines (48 loc) · 1.92 KB
/
cmdLineGuide.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
76
77
# To use gmcr-py from the command line:
# First navigate to the folder where the program lives.
# Then type:
import gmcr
# this makes the the conflict model classes available as gmcr.model
# and the conflict solvers under as gmcr.solvers
# To initialize a fresh conflict, next type:
myConflict = gmcr.model.ConflictModel()
# A decision maker is created by giving a reference to the parent conflict, and a name for the dm:
syria = gmcr.model.DecisionMaker(myConflict, "syria")
# the DM must then be added to the game:
myConflict.decisionMakers.append(syria)
#you can also a decision maker to the conflict more directly by typing:
myConflict.decisionMakers.append("iraq")
# grab a reference to this decisionMaker:
iraq = myConflict.decisionMakers[-1]
#The list of decision makers can be shown with
print(myConflict.decisionMakers)
#or:
[dm.name for dm in myConflict.decisionMakers]
#Now, lets give the decision makers some options:
syria.addOption("Release Water")
syria.addOption("Escalate")
iraq.addOption("Attack")
rw = syria.options[0]
esc = myConflict.options[1]
att = iraq.options[0]
#View the options:
[opt.name for opt in syria.options]
[opt.name for opt in iraq.options]
[opt.name for opt in myConflict.options]
# remove infeasible states
myConflict.infeasibles.append([[rw,"Y"],[esc,"Y"]])
myConflict.recalculateFeasibleStates()
#add preferences
syria.preferences.append([[rw,"N"],[esc,"N"],[att,"N"]])
syria.preferences.append([[esc,"Y"]])
syria.preferences.append([[att,"N"]])
syria.preferences.append([[rw,"N"]])
syria.calculatePreferences()
iraq.preferences.append([[rw,"Y"],[esc,"N"],[att,"N"]])
iraq.preferences.append([[rw,"N"],[esc,"N"],[att,"Y"]])
iraq.preferences.append([[rw,"N"],[esc,"Y"],[att,"Y"]])
iraq.preferences.append([[rw,"N"],[esc,"N"],[att,"N"]])
iraq.preferences.append([[rw,"Y"],[esc,"N"],[att,"Y"]])
iraq.calculatePreferences()
# Run the conflict!
lSolver = gmcr.solvers.LogicalSolver(myConflict)