-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.als
178 lines (156 loc) · 3.92 KB
/
main.als
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
178
open board
enum ActionType { Noop, Transform, Build, BuildFirst, Upgrade }
one sig Game {
var currentPlayer: one Player,
var currentAction: one ActionType,
var currentRound: one Round
}
pred noTileIsOwned {
all t: GameTile | no t.ownedBy && no t.building
}
pred someTilesForEachTerrain {
some t: GameTile | t.terrainType = TypeA
some t: GameTile | t.terrainType = TypeB
some t: GameTile | t.terrainType = TypeC
some t: GameTile | t.terrainType = TypeD
}
pred noSameTypeNeighbor {
all t : GameTile |
t.terrainType != t.NE.terrainType
&& t.terrainType != t.E.terrainType
&& t.terrainType != t.SE.terrainType
&& t.terrainType != t.SW.terrainType
&& t.terrainType != t.W.terrainType
&& t.terrainType != t.SW.terrainType
}
pred noOwnershipChange [tiles: GameTile] {
all t : tiles | t.ownedBy' = t.ownedBy
}
pred noBuildingChange [tiles: GameTile] {
all t : tiles | t.building' = t.building
}
pred noTerrainChange [tiles: GameTile] {
all t : tiles | t.terrainType' = t.terrainType
}
pred transform [t: GameTile] {
// pre
Game.currentRound' != Finish
no t.ownedBy
no t.building
(t.terrainType != Game.currentPlayer'.desiredTerrain)
Game.currentPlayer' in t.Neighbors.ownedBy
// post
t.terrainType' != t.terrainType
t.terrainType' = Game.currentPlayer'.desiredTerrain
// frame
noOwnershipChange[GameTile]
noBuildingChange[GameTile]
noTerrainChange[GameTile - t]
Game.currentAction' = Transform
}
pred buildFirst [t: GameTile] {
// pre
Game.currentRound' != Finish
no t.ownedBy
no t.building
t.terrainType = Game.currentPlayer'.desiredTerrain
no ownedBy.(Game.currentPlayer')
// post
t.ownedBy' = Game.currentPlayer'
t.building' = TierI
// frame
noOwnershipChange[GameTile - t]
noBuildingChange[GameTile - t]
noTerrainChange[GameTile]
// track
Game.currentAction' = BuildFirst
}
pred build [t: GameTile] {
// pre
Game.currentRound' != Finish
no t.ownedBy
no t.building
Game.currentPlayer' in t.Neighbors.ownedBy
t.terrainType = Game.currentPlayer'.desiredTerrain
// post
t.ownedBy' = Game.currentPlayer'
t.building' = TierI
// frame
noOwnershipChange[GameTile - t]
noBuildingChange[GameTile - t]
noTerrainChange[GameTile]
// track
Game.currentAction' = Build
}
pred upgrade [t: GameTile] {
// pre
Game.currentRound' != Finish
some t.building
t.building != TierIV
t.terrainType = Game.currentPlayer'.desiredTerrain
// post
t.building' = t.building.next
// frame
noOwnershipChange[GameTile]
noBuildingChange[GameTile - t]
noTerrainChange[GameTile]
// track
Game.currentAction' = Upgrade
}
pred finish {
// pre
Game.currentRound' = Finish
// post
// frame
noOwnershipChange[GameTile]
noBuildingChange[GameTile]
noTerrainChange[GameTile]
// track
Game.currentAction' = Noop
}
pred init {
someTilesForEachTerrain
noSameTypeNeighbor
noTileIsOwned
Game.currentAction = Noop
Game.currentPlayer = Player4
Game.currentRound = Start
}
pred finished {
Game.currentRound = Finish
}
pred trans {
some t: GameTile | transform [t]
or
some t: GameTile | buildFirst [t]
or
some t: GameTile | build [t]
or
some t: GameTile | upgrade [t]
or finish
}
pred passTurn {
Game.currentPlayer' = Game.currentPlayer.next
Game.currentRound' = Game.currentRound.next
}
pred System {
init
always (trans and passTurn)
eventually finished
}
pred AllActions {
#GameTile = 12
eventually Game.currentAction = BuildFirst
eventually Game.currentAction = Build
eventually Game.currentAction = Transform
eventually Game.currentAction = Upgrade
}
pred TwoSquaresEach {
eventually all p: Player | #ownedBy.p = 2
}
pred FancyBuildings {
eventually some t: GameTile | t.building = TierIV
}
run execution {
System
} for 13 but 22..22 steps