-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpandemic.cep
177 lines (146 loc) · 4.24 KB
/
pandemic.cep
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
city : type.
la : city.
atlanta : city.
bogota : city.
milan : city.
delhi : city.
tokyo : city.
neq city city : bwd.
neq la atlanta. neq la bogota. neq la milan. neq la delhi. neq la tokyo.
neq atlanta la. neq atlanta bogota. neq atlanta milan. neq atlanta delhi. neq atlanta tokyo.
neq bogota la. neq bogota atlanta. neq bogota milan. neq bogota delhi. neq bogota tokyo.
neq milan la. neq milan atlanta. neq milan bogota. neq milan delhi. neq milan tokyo.
neq delhi la. neq delhi atlanta. neq delhi bogota. neq delhi milan. neq delhi tokyo.
neq tokyo la. neq tokyo atlanta. neq tokyo bogota. neq tokyo milan. neq tokyo delhi.
city_list : type.
nil : city_list.
cons city city_list : city_list.
neighbors city city_list : bwd.
neighbors atlanta (cons la (cons milan nil)).
neighbors la (cons atlanta (cons bogota (cons delhi nil))).
neighbors milan (cons atlanta (cons delhi (cons bogota (cons tokyo nil)))).
neighbors delhi (cons la (cons milan (cons tokyo nil))).
neighbors tokyo (cons delhi (cons milan nil)).
member city city_list : bwd.
member/hit : member C (cons C L).
member/miss : member C (cons C' L)
<- neq C C'
<- member C L.
adj city city : bwd.
adj C C'
<- neighbors C N
<- member C' N.
% adj atlanta la. adj la atlanta.
% adj atlanta milan. adj milan atlanta.
% adj la bogota. adj bogota la.
% adj la delhi. adj delhi la.
% adj milan delhi. adj delhi milan.
% adj milan bogota. adj bogota milan.
% adj milan tokyo. adj tokyo milan.
% adj delhi tokyo. adj tokyo delhi.
card : type.
city_card city : card.
epidemic : card.
player : type.
ana : player.
bill : player.
claudette : player.
danny : player.
turn_next player player : bwd.
last_player player : bwd.
first_player player : bwd.
first_player ana.
turn_next ana bill.
turn_next bill claudette.
turn_next claudette danny.
last_player danny.
clr : type.
blue : clr.
red : clr.
yellow : clr.
black : clr.
color city clr : bwd.
color atlanta blue.
color milan blue.
color la yellow.
color bogota yellow.
color delhi red.
color tokyo red.
research_ctr city : pred.
disease city : pred.
spread city_list : pred. % spread disease to list of cities
virus : pred.
% XXX - change turns to count a quantity - track which player went last
at player city : pred.
turn player : pred.
hand player card : pred.
deck card : pred.
discard card : pred.
draw player : pred.
context init =
{
research_ctr atlanta,
at ana atlanta,
at bill atlanta,
at claudette atlanta,
at danny atlanta,
deck (city_card atlanta),
deck (city_card bogota),
deck (city_card delhi),
deck (city_card la),
deck (city_card milan),
deck (city_card tokyo),
deck epidemic,
deck epidemic,
turn ana
}
stage start {
}
do/setup : qui * stage start * $turn P -o draw P * stage draw.
do/draw2 : qui * stage draw * turn P * turn_next P P'
-o turn P' * draw P' * stage draw.
stage draw {
draw : draw P * deck C -o hand P C.
}
do/initial_infect :
qui * stage draw * turn P * last_player P
-o
stage infect * virus * virus * virus.
stage infect {
infect2 : deck (city_card C) * virus
-o disease C * disease C * discard (city_card C).
}
end_setup : qui * stage infect * first_player P
-o turn P * turn P * turn P * turn P * stage turn.
stage outbreak {
spread/init :
$disease C * $disease C * $disease C * disease C
* neighbors C N
-o
spread N. % should also increase outbreak level
spread/nil : spread nil -o ().
spread/cons :
spread (cons C L) -o disease C * spread L.
}
stage turn {
drive/ferry : turn P * at P C * adj C C' -o at P C'.
fly : turn P * at P C * hand P (city_card C') -o at P C'.
charter : turn P * at P C * $research_ctr C * $research_ctr C'
-o at P C'.
treat : turn P * $at P C * disease C -o ().
build : turn P * $at P C * hand P (city_card C) -o research_ctr C.
end_turn : turn P -o ().
}
#interactive turn.
do/infect_after_turn :
qui * stage turn * turn P * turn_next P P'
-o
stage infect * virus * turn P'.
% virus count should be # equal to outbreak level
% special case for last player
do/infect_after_turn_last :
qui * stage turn * turn P * last_player P * first_player P'
-o
stage infect * virus * turn P'.
% virus count should be # equal to outbreak level
#trace _ start init.