Permalink
Browse files

Gestion du déclenchement/arrêt de l'IA

  • Loading branch information...
1 parent 6121d36 commit 6b72ca8f71dca5c0552ec7ae441ea39661e6cd5c @erdnaxeli erdnaxeli committed May 18, 2012
Showing with 91 additions and 90 deletions.
  1. +91 −90 main.u
View
181 main.u
@@ -27,12 +27,11 @@ var robot = Robot.new(0,0,0,"R")|
*/
var Tag.done = false|;
-var group_t = Tag.new("group")|
-var alones_t = Tag.new("alones")|
+var main_t = Tag.new("main")|
+
var poussoirs_t = Tag.new("poussoirs")|
-var u_t = Tag.new ("U")|
-var goBackInv_t = Tag.new ("goBackInv")|
-var goBack_t = Tag.new ("goBack")|
+var u_t = Tag.new("U")|
+var goBack_t = Tag.new("goBack")|
var cross_t = Tag.new("cross")|
// cette variable sera égal au tag en cours
@@ -50,6 +49,7 @@ function launch {
+
// les différentes actions du robot
@@ -80,24 +80,6 @@ function goBack {
at (goBack_t.enter?) goBack_t.done = false;
-at (goBack_t.leave?) {
- if (!goBack_t.done) {
- current_t = Tag.new();
- for (4) {
- sleep(0.5s);
- if (!goBack_t.done) {
- current_t:
- goBack;
- }
- else break;
- };
-
- launch(u, u_t);
- goBack_t.done = true;
- }
-};
-
-
/* U
*
@@ -128,24 +110,6 @@ function u {
at (u_t.enter?) u_t.done = false;
-at (u_t.leave?) {
- if (!u_t.done) {
- current_t = Tag.new();
-
- for (4) {
- sleep(0.5s);
- if (!u_t.done) {
- current_t:
- u;
- }
- else break;
- };
-
- launch(goBack, goBack_t);
- u_t.done = true;
- };
-};
-
/* Poussoirs
*
@@ -184,22 +148,6 @@ function poussoirs {
at (poussoirs_t.enter?) poussoirs_t.done = false;
-at (poussoirs_t.leave?) {
- if (!poussoirs_t.done) {
- current_t = Tag.new();
- for (6) {
- sleep(0.5s);
- if (!poussoirs_t.done) {
- current_t:
- poussoirs;
- }
- else break;
- };
-
- poussoirs_t.done = true;
- };
-};
-
function cross {
do (robot) {
@@ -227,36 +175,89 @@ function cross {
at (cross_t.enter?) cross_t.done = false;
-at (cross_t.leave?) {
- if (!cross_t.done)
- cross_t.done = true;
-};
-
-// les 4 CDs du bas plus le premier poussoir
-/*function group {
- current_t = group_t |
- group_t:
- do (robot) {
- forward(25);
- rotate(90);
- forward(50);
- rotate(90);
- forward(25);
- };
-}|;*/
-
-
-{sleep(3); {robot.stop (current_t)}},
-launch(u, u_t);
-launch(poussoirs, poussoirs_t);
-echo("x = " + robot._x)|
-echo("y = " + robot._y)|
-launch(cross, cross_t);
-echo("x = " + robot._x)|
-echo("y = " + robot._y)|
-{sleep(6); {robot.stop (current_t)}},
-launch(poussoirs, poussoirs_t);
-echo("x = " + robot._x)|
-echo("y = " + robot._y)|
-
-System.shutdown;
+
+function main {
+ at (goBack_t.leave?) {
+ if (!goBack_t.done) {
+ current_t = Tag.new();
+
+ for (4) {
+ sleep(0.5s);
+ if (!goBack_t.done)
+ current_t:
+ goBack
+ else break;
+ };
+
+ if (!goBack_t.done)
+ launch(u, u_t);
+
+ goBack_t.done = true;
+ }
+ };
+
+
+ at (u_t.leave?) {
+ if (!u_t.done) {
+ current_t = Tag.new();
+
+ for (4) {
+ sleep(0.5s);
+ if (!u_t.done) {
+ current_t:
+ u;
+ }
+ else break;
+ };
+
+ launch(goBack, goBack_t);
+ u_t.done = true;
+ };
+ };
+
+
+ at (poussoirs_t.leave?) {
+ if (!poussoirs_t.done) {
+ current_t = Tag.new();
+ for (6) {
+ sleep(0.5s);
+ if (!poussoirs_t.done) {
+ current_t:
+ poussoirs;
+ }
+ else break;
+ };
+
+ poussoirs_t.done = true;
+ };
+ };
+
+
+ at (cross_t.leave?)
+ if (!cross_t.done)
+ cross_t.done = true;
+
+ {sleep(3); {robot.stop (current_t)}},
+ launch(u, u_t);
+ launch(poussoirs, poussoirs_t);
+ echo("x = " + robot._x)|
+ echo("y = " + robot._y)|
+ launch(cross, cross_t);
+ echo("x = " + robot._x)|
+ echo("y = " + robot._y)|
+ {sleep(6); {robot.stop (current_t)}},
+ launch(poussoirs, poussoirs_t);
+ echo("x = " + robot._x)|
+ echo("y = " + robot._y)|
+}|;
+
+
+var start = true;
+
+at (start) main_t: main;
+at (!start) { echo ("bite"); main_t.stop };
+
+sleep(3);
+start = false;
+sleep(3);
+start = true;

0 comments on commit 6b72ca8

Please sign in to comment.