ding
[mc1516the.git] / uppaal / 2.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE nta PUBLIC '-//Uppaal Team//DTD Flat System 1.1//EN' 'http://www.it.uu.se/research/group/darts/uppaal/flat-1_2.dtd'>
3 <nta>
4 <declaration>// Place global declarations here.
5 // Intermediate
6 const int N = 13;
7 // Advanced
8 //const int N = 7
9
10 typedef int[0,N-1] id_c;
11
12 broadcast chan up[N], down[N], left[N], right[N], start, leftRed, rightRed;
13
14 chan reg, finish;
15
16 bool grid[6][6];</declaration>
17 <template>
18 <name x="5" y="5">HorzCar</name>
19 <parameter>int[2,3] length, const id_c id, int[0,4] x, const int[0,5] y</parameter>
20 <declaration>// Place local declarations here.
21
22 void register() {
23 int i;
24 for (i=0; i&lt;length; i++) {
25 grid[x+i][y] = true;
26 }
27 }</declaration>
28 <location id="id0" x="-425" y="-51">
29 </location>
30 <location id="id1" x="-535" y="-136">
31 <urgent/>
32 </location>
33 <location id="id2" x="-212" y="-76">
34 </location>
35 <init ref="id1"/>
36 <transition>
37 <source ref="id0"/>
38 <target ref="id2"/>
39 <label kind="synchronisation" x="-407" y="-80">start?</label>
40 </transition>
41 <transition>
42 <source ref="id1"/>
43 <target ref="id0"/>
44 <label kind="synchronisation" x="-517" y="-110">reg!</label>
45 <label kind="assignment" x="-517" y="-93">register()</label>
46 </transition>
47 <transition>
48 <source ref="id2"/>
49 <target ref="id2"/>
50 <label kind="guard" x="-280" y="8">x&gt;0 &amp;&amp; !grid[x-1][y]</label>
51 <label kind="synchronisation" x="-246" y="102">down[id]!</label>
52 <label kind="assignment" x="-340" y="34">grid[x+length-1][y]:=false,
53 grid[x-1][y]:=true,
54 x:=x-1</label>
55 <nail x="-306" y="8"/>
56 <nail x="-136" y="0"/>
57 </transition>
58 <transition>
59 <source ref="id2"/>
60 <target ref="id2"/>
61 <label kind="guard" x="-306" y="-263">x+length &lt; 6 &amp;&amp; !grid[x+length][y]</label>
62 <label kind="synchronisation" x="-221" y="-204">up[id]!</label>
63 <label kind="assignment" x="-331" y="-229">grid[x][y]:=false,
64 grid[x+length][y]:=true,
65 x:=x+1</label>
66 <nail x="-323" y="-102"/>
67 <nail x="-195" y="-178"/>
68 <nail x="-110" y="-102"/>
69 </transition>
70 </template>
71 <template>
72 <name>VertCar</name>
73 <parameter>int[2,3] length, const id_c id, const int[0,5] x, int[0,4] y</parameter>
74 <declaration>void register() {
75 int i;
76 for(i=0; i&lt;length; i++){
77 grid[x][y+i] = true;
78 }
79 }
80 </declaration>
81 <location id="id3" x="-314" y="-34">
82 </location>
83 <location id="id4" x="-416" y="-76">
84 <urgent/>
85 </location>
86 <location id="id5" x="-102" y="-34">
87 </location>
88 <init ref="id4"/>
89 <transition>
90 <source ref="id3"/>
91 <target ref="id5"/>
92 <label kind="synchronisation" x="-228" y="-72">start?</label>
93 </transition>
94 <transition>
95 <source ref="id4"/>
96 <target ref="id3"/>
97 <label kind="synchronisation" x="-374" y="-110">reg!</label>
98 <label kind="assignment" x="-374" y="-76">register()</label>
99 <nail x="-255" y="-85"/>
100 </transition>
101 <transition>
102 <source ref="id5"/>
103 <target ref="id5"/>
104 <label kind="guard" x="-170" y="153">y&gt;0 &amp;&amp; !grid[x][y-1]</label>
105 <label kind="synchronisation" x="-119" y="119">left[id]!</label>
106 <label kind="assignment" x="-221" y="51">grid[x][y-1]:=true,
107 grid[x][y+length-1]:=true,
108 y:=y-1</label>
109 <nail x="-153" y="42"/>
110 <nail x="-34" y="42"/>
111 </transition>
112 <transition>
113 <source ref="id5"/>
114 <target ref="id5"/>
115 <label kind="guard" x="-204" y="-221">y+length &lt; 6 &amp;&amp; !grid[x][y+length]</label>
116 <label kind="synchronisation" x="-127" y="-195">right[id]!</label>
117 <label kind="assignment" x="-263" y="-161">grid[x][y+length]:=true,
118 grid[x][y]:=false,
119 y:=y+1</label>
120 <nail x="-178" y="-102"/>
121 <nail x="-34" y="-102"/>
122 </transition>
123 </template>
124 <template>
125 <name>Player</name>
126 <declaration>int[0,N] registered;
127 bool done = 0;</declaration>
128 <location id="id6" x="-493" y="-255">
129 </location>
130 <location id="id7" x="-680" y="-246">
131 </location>
132 <location id="id8" x="-799" y="-246">
133 </location>
134 <init ref="id8"/>
135 <transition>
136 <source ref="id7"/>
137 <target ref="id6"/>
138 <label kind="synchronisation" x="-629" y="-272">finish?</label>
139 <label kind="assignment" x="-662" y="-250">done := 1</label>
140 </transition>
141 <transition>
142 <source ref="id8"/>
143 <target ref="id7"/>
144 <label kind="guard" x="-781" y="-280">registered == N</label>
145 <label kind="synchronisation" x="-781" y="-263">start!</label>
146 </transition>
147 <transition>
148 <source ref="id8"/>
149 <target ref="id8"/>
150 <label kind="synchronisation" x="-875" y="-365">reg?</label>
151 <label kind="assignment" x="-926" y="-382">registered := registered+1</label>
152 <nail x="-892" y="-263"/>
153 <nail x="-833" y="-331"/>
154 <nail x="-765" y="-314"/>
155 </transition>
156 </template>
157 <template>
158 <name>RedCar</name>
159 <parameter>const id_c id, int[0,5] x</parameter>
160 <declaration>void register() {
161 grid[x][3] = true;
162 grid[x+1][3] = true;
163 }</declaration>
164 <location id="id9" x="493" y="-51">
165 </location>
166 <location id="id10" x="51" y="-59">
167 </location>
168 <location id="id11" x="-93" y="-68">
169 </location>
170 <location id="id12" x="-204" y="-68">
171 <urgent/>
172 </location>
173 <init ref="id12"/>
174 <transition>
175 <source ref="id10"/>
176 <target ref="id9"/>
177 <label kind="guard" x="416" y="-93">x == 4</label>
178 <label kind="synchronisation" x="416" y="-76">finish!</label>
179 </transition>
180 <transition>
181 <source ref="id10"/>
182 <target ref="id10"/>
183 <label kind="guard" x="0" y="161">x &gt; 0 &amp;&amp; grid[x-1][3]</label>
184 <label kind="synchronisation" x="25" y="119">leftRed!</label>
185 <label kind="assignment" x="-85" y="85">grid[x+1][3]:=false,
186 grid[x-1][3]:=true,
187 x:=x-1</label>
188 <nail x="-25" y="42"/>
189 <nail x="178" y="51"/>
190 </transition>
191 <transition>
192 <source ref="id10"/>
193 <target ref="id10"/>
194 <label kind="guard" x="-17" y="-255">x+2 &lt; 6 &amp;&amp; grid[x+2][3]</label>
195 <label kind="synchronisation" x="25" y="-221">rightRed!</label>
196 <label kind="assignment" x="-85" y="-187">grid[x-1][3]:=false,
197 grid[x+2][3]:=true,
198 x:=x+1</label>
199 <nail x="-17" y="-144"/>
200 <nail x="144" y="-136"/>
201 </transition>
202 <transition>
203 <source ref="id11"/>
204 <target ref="id10"/>
205 <label kind="synchronisation" x="-75" y="-80">start?</label>
206 </transition>
207 <transition>
208 <source ref="id12"/>
209 <target ref="id11"/>
210 <label kind="synchronisation" x="-186" y="-85">reg!</label>
211 <label kind="assignment" x="-186" y="-68">register()</label>
212 </transition>
213 </template>
214 <system>// Place template instantiations here.
215
216 // Intermediate puzzle
217 H1 = HorzCar(2, 0, 0, 5);
218 H2 = HorzCar(2, 1, 2, 5);
219 V3 = VertCar(2, 2, 4, 4);
220 V4 = VertCar(2, 3, 2, 3);
221 V5 = VertCar(3, 4, 5, 2);
222 V6 = VertCar(2, 5, 1, 3);
223 H7 = HorzCar(2, 6, 3, 4);
224 H8 = RedCar(7, 2); //RED
225 V9 = VertCar(3, 8, 0, 0);
226 HA = HorzCar(2, 9, 1, 0);
227 VB = VertCar(2, 10, 3, 0);
228 HC = HorzCar(2, 11, 4, 1);
229 HD = HorzCar(2, 12, 4, 0);
230 system H1, H2, V3, V4, V5, V6, H7, H8, V9, HA, VB, HC, HD, Player;
231
232 // Advanced puzzle
233 /*
234 H1 = HorzCar(2, 0, 0, 5);
235 V2 = VertCar(2, 1, 2, 4);
236 V3 = VertCar(3, 2, 3, 3);
237 V4 = VertCar(3, 3, 0, 2);
238 H5 = HorzCar(2, 4, 1, 3);
239 H6 = HorzCar(3, 5, 1, 2);
240 H7 = HorzCar(3, 6, 3, 0);
241 system H1, V2, V3, V4, H5, H6, H7
242 */
243
244 // List one or more processes to be composed into a system.
245
246 </system>
247 <queries>
248 <query>
249 <formula>E&lt;&gt; Player.done == 1
250 </formula>
251 <comment>
252 </comment>
253 </query>
254 </queries>
255 </nta>