From: pimjager <pim@pimjager.nl>
Date: Tue, 14 Jun 2016 10:05:05 +0000 (+0200)
Subject: Gaat de goede kant op
X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=10df1a675da1776f737a1f374c32ecca3ed3b2c2;p=mc1516the.git

Gaat de goede kant op
---

diff --git a/uppaal/2.xml b/uppaal/2.xml
index 7091457..153e6b9 100644
--- a/uppaal/2.xml
+++ b/uppaal/2.xml
@@ -9,27 +9,54 @@ const int N = 13;
 
 typedef int[0,N-1] id_c;
 
-chan up[N], down[N], left[N], right[N];</declaration>
+broadcast chan up[N], down[N], left[N], right[N], start;
+
+chan reg;
+
+bool grid[6][6];</declaration>
 	<template>
 		<name x="5" y="5">VertCar</name>
 		<parameter>int[2,3] length, const id_c id, int[0,5] x, const int[0,4] y</parameter>
-		<declaration>// Place local declarations here.</declaration>
-		<location id="id0" x="-212" y="-76">
+		<declaration>// Place local declarations here.
+
+void register() {
+    int i;
+    for (i=0; i&lt;length; i++) {
+        grid[x][y+1] = true;
+    } 
+}</declaration>
+		<location id="id0" x="-425" y="-51">
+		</location>
+		<location id="id1" x="-535" y="-136">
+			<urgent/>
 		</location>
-		<init ref="id0"/>
+		<location id="id2" x="-212" y="-76">
+		</location>
+		<init ref="id1"/>
 		<transition>
 			<source ref="id0"/>
+			<target ref="id2"/>
+			<label kind="synchronisation" x="-407" y="-80">start?</label>
+		</transition>
+		<transition>
+			<source ref="id1"/>
 			<target ref="id0"/>
-			<label kind="guard" x="-288" y="-68">x&gt;0</label>
+			<label kind="synchronisation" x="-517" y="-110">reg!</label>
+			<label kind="assignment" x="-517" y="-93">register()</label>
+		</transition>
+		<transition>
+			<source ref="id2"/>
+			<target ref="id2"/>
+			<label kind="guard" x="-288" y="-68">x&gt;0 &amp;&amp; !grid[x-1][y]</label>
 			<label kind="synchronisation" x="-288" y="-51">down[id]!</label>
 			<label kind="assignment" x="-288" y="-34">x:=x-1</label>
 			<nail x="-306" y="8"/>
 			<nail x="-136" y="0"/>
 		</transition>
 		<transition>
-			<source ref="id0"/>
-			<target ref="id0"/>
-			<label kind="guard" x="-306" y="-204">x+length &lt; 6</label>
+			<source ref="id2"/>
+			<target ref="id2"/>
+			<label kind="guard" x="-306" y="-204">x+length &lt; 6 &amp;&amp; !grid[x+length][y]</label>
 			<label kind="synchronisation" x="-314" y="-153">up[id]!</label>
 			<label kind="assignment" x="-306" y="-178">x:=x+1</label>
 			<nail x="-323" y="-102"/>
@@ -40,22 +67,46 @@ chan up[N], down[N], left[N], right[N];</declaration>
 	<template>
 		<name>HorzCar</name>
 		<parameter>int[2,3] length, const id_c id, const int[0,4] x, int[0,5] y</parameter>
-		<location id="id1" x="-102" y="-34">
+		<declaration>void register() {
+    int i;
+    for(i=0; i&lt;length; i++){
+        grid[x+i][y] = true;
+    }
+}
+</declaration>
+		<location id="id3" x="-314" y="-34">
 		</location>
-		<init ref="id1"/>
+		<location id="id4" x="-416" y="-76">
+			<urgent/>
+		</location>
+		<location id="id5" x="-102" y="-34">
+		</location>
+		<init ref="id4"/>
 		<transition>
-			<source ref="id1"/>
-			<target ref="id1"/>
-			<label kind="guard" x="-135" y="8">y&gt;0</label>
+			<source ref="id3"/>
+			<target ref="id5"/>
+			<label kind="synchronisation" x="-228" y="-72">start?</label>
+		</transition>
+		<transition>
+			<source ref="id4"/>
+			<target ref="id3"/>
+			<label kind="synchronisation" x="-374" y="-110">reg!</label>
+			<label kind="assignment" x="-374" y="-76">register()</label>
+			<nail x="-255" y="-85"/>
+		</transition>
+		<transition>
+			<source ref="id5"/>
+			<target ref="id5"/>
+			<label kind="guard" x="-135" y="8">y&gt;0 &amp;&amp; !grid[x][y-1]</label>
 			<label kind="synchronisation" x="-135" y="25">left[id]!</label>
 			<label kind="assignment" x="-135" y="42">y:=y-1</label>
 			<nail x="-153" y="42"/>
 			<nail x="-34" y="42"/>
 		</transition>
 		<transition>
-			<source ref="id1"/>
-			<target ref="id1"/>
-			<label kind="guard" x="-160" y="-102">y+length &lt; 6</label>
+			<source ref="id5"/>
+			<target ref="id5"/>
+			<label kind="guard" x="-160" y="-102">y+length &lt; 6 &amp;&amp; !grid[x][y+length]</label>
 			<label kind="synchronisation" x="-160" y="-85">right[id]!</label>
 			<label kind="assignment" x="-160" y="-68">y:=y+1</label>
 			<nail x="-178" y="-102"/>
@@ -64,9 +115,28 @@ chan up[N], down[N], left[N], right[N];</declaration>
 	</template>
 	<template>
 		<name>Player</name>
-		<location id="id2" x="-476" y="-178">
+		<parameter>Template red</parameter>
+		<declaration>int[0,N] registered;</declaration>
+		<location id="id6" x="-680" y="-246">
+		</location>
+		<location id="id7" x="-799" y="-246">
 		</location>
-		<init ref="id2"/>
+		<init ref="id7"/>
+		<transition>
+			<source ref="id7"/>
+			<target ref="id6"/>
+			<label kind="guard" x="-781" y="-280">registered == N</label>
+			<label kind="synchronisation" x="-781" y="-263">start!</label>
+		</transition>
+		<transition>
+			<source ref="id7"/>
+			<target ref="id7"/>
+			<label kind="synchronisation" x="-875" y="-365">reg?</label>
+			<label kind="assignment" x="-926" y="-382">registered := registered+1</label>
+			<nail x="-892" y="-263"/>
+			<nail x="-833" y="-331"/>
+			<nail x="-765" y="-314"/>
+		</transition>
 	</template>
 	<system>// Place template instantiations here.
 
@@ -84,7 +154,7 @@ HA = HorzCar(2, 9, 1, 0);
 VB = VertCar(2, 10, 3, 0);
 HC = HorzCar(2, 11, 4, 1);
 HD = HorzCar(2, 12, 4, 0);
-system H1, H2, V3, V4, V5, V6, H7, H8, V9, HA, VB, HC, HD;
+system H1, H2, V3, V4, V5, V6, H7, H8, V9, HA, VB, HC, HD, Player;
 
 // Advanced puzzle
 /*