[SCM] applications.git branch, master, updated. 843f5113fb9a142b6a1fd06db3feae0944c59406

ontologiae ontologiae at ordinateur-de-ontologiae-3.local
Wed Mar 31 14:02:51 UTC 2010


The following commit has been merged in the master branch:
commit 843f5113fb9a142b6a1fd06db3feae0944c59406
Author: ontologiae <ontologiae at ordinateur-de-ontologiae-3.local>
Date:   Wed Mar 31 16:02:33 2010 +0200

    generalisation of agent lib

diff --git a/examples/standard/agent/agent.li b/examples/standard/agent/agent.li
index 77c4ebe..ddbf4b0 100644
--- a/examples/standard/agent/agent.li
+++ b/examples/standard/agent/agent.li
@@ -20,7 +20,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 Section Header
   
-  + name      := AGENT;
+  + name      := AGENT(V);
 
   - copyright := "2003-2010 Sonntag Benoit";
 
@@ -35,22 +35,22 @@ Section Public
   
   + birthtime:UINTEGER_64;
     
-  + current_state:STATE;
+  + current_state:STATE(V);
   
   + state_time:UINTEGER_64;
   
-  + behavior:STATE;
+  + behavior:STATE(V);
   
-  - make s:STATE <-
+  - make s:STATE(V) <-
   ( 
     behavior := s;
     set_state s;
     birthtime := TIMER.timer_count;    
   );
   
-  - set_state s:STATE <-
+  - set_state s:STATE(V) <-
   [ -? {s != NULL}; ]
-  ( + cur:STATE;
+  ( + cur:STATE(V);
     (current_state != NULL).if {
       cur := current_state;
       {cur != NULL}.while_do {
@@ -99,4 +99,4 @@ Section Public
       current_state.run Self;        
     };    
   );
-  
\ No newline at end of file
+  
diff --git a/examples/standard/agent/example.li b/examples/standard/agent/example.li
index 013eb65..e861b0f 100644
--- a/examples/standard/agent/example.li
+++ b/examples/standard/agent/example.li
@@ -56,14 +56,14 @@ Section Public
   //
 
   - init:G_EXPR <-
-  ( + x,y:INTEGER;
+  ( //+ x,y:INTEGER;
     // Initialization.
     screen:=FAST_ARRAY2(UINTEGER_8).create (256,256);
-    9000.times {
+    /*9000.times {
       x := screen.upper1.random_upper;
       y := screen.upper2.random_upper;
       screen.put 1 to (x,y);
-    };      
+    };      */
     G_RAW.create (Self.fix_height.fix_width)
   );
 
@@ -101,7 +101,8 @@ Section Public
   - draw (x0,y0:INTEGER) to (x1,y1:INTEGER) <-
   ( + n:UINTEGER_8;
     + xx,yy:INTEGER;
-    + ant:ANT;
+    //+ ant:ANT;
+    + ant:PENCIL;
 
     clipping (x0,y0) to (x1,y1);
     //rectangle_fill (x0,y0) to (x1,y1) color black;
@@ -121,7 +122,7 @@ Section Public
       };
     };        
     
-    WORLD.agents.foreach { a:AGENT;
+    WORLD(PENCIL).agents.foreach { a:AGENT(PENCIL);
       ant ?= a;
       xx := ant.x * 2;
       yy := ant.y * 2;
@@ -130,9 +131,9 @@ Section Public
     };
     
     // BSBS: BUG URGENT !!!!!!
-    (WORLD.agents.lower).to (WORLD.agents.upper) do { i:INTEGER;
+    (WORLD(PENCIL).agents.lower).to (WORLD(PENCIL).agents.upper) do { i:INTEGER;
       `//ICI`;
-      ant ?= WORLD.agents.item i;
+      ant ?= WORLD(PENCIL).agents.item i;
       xx := ant.x * 2;
       yy := ant.y * 2;
       //i.print; " ! \n".print;
@@ -196,12 +197,17 @@ Section Public
 Section Public
 
   - create_world <-
-  ( + free,busy,life:STATE;
-    + ant:ANT;
+  ( + state1,state2,state3,state4,life : STATE(PENCIL);
+    + pencil:PENCIL;
+    
+    //+ free,busy,life:STATE;
+    //+ ant:ANT;
     
     //
     // Comportement.
     //
+
+   /* 
     
     free := STATE.create "Free" begin_action { x:ANT;
       "I am free!\n".print;
@@ -218,20 +224,34 @@ Section Public
     } end_action { x:ANT;
       //x.put_food screen;
     };
-    free.to busy if { x:ANT; /*"free à busy".printline; x.found_food screen*/ (1.random_to 9) = 3 };
-    busy.to free if { x:ANT; /*"busy à free".printline; */x.found_heap screen/* (1.random_to 5) = 3*/ };
+    free.to busy if { x:ANT; "free à busy".printline; x.found_food screen };
+    busy.to free if { x:ANT; "busy à free".printline; x.found_heap screen };
     
     life := STATE.create "Life" action { x:ANT;
       x.move;
     };
     life.has free;
-    
-    100.times {
-      ant := ANT.create life;      
+
+*/
+
+    state1 := STATE(PENCIL).create "State 1" action { x:PENCIL; x.move; x.trace screen; }; 
+    state2 := STATE(PENCIL).create "State 2" action { x:PENCIL;  x.setdir  (1,-1); }; 
+    state3 := STATE(PENCIL).create "State 3" action { x:PENCIL;  x.move; x.trace screen; }; 
+    state4 := STATE(PENCIL).create "State 4" action { x:PENCIL;  x.setdir  (-1,0); }; 
+
+
+    state1.to state2 if { x:PENCIL; x.step = 10};
+    state2.to state3 if { x:PENCIL; TRUE};
+    state3.to state4 if { x:PENCIL; x.step = 16};
+    state4.to state1 if { x:PENCIL; TRUE };
+
+
+    5.times {
+      pencil := PENCIL.create life;      
       "create ".print;
-      ant.x.print; '\n'.print;
-      WORLD.add ant; 
+      pencil.x.print; '\n'.print;
+      WORLD(PENCIL).add pencil; 
     };
     
-    WORLD.run;
+    WORLD(PENCIL).run;
   );
diff --git a/examples/standard/agent/state.li b/examples/standard/agent/state.li
index 0aaea69..8db89cb 100644
--- a/examples/standard/agent/state.li
+++ b/examples/standard/agent/state.li
@@ -9,8 +9,8 @@
 //   (at your option) any later version.                                     //
 //                                                                           //
 //   This program is distributed in the hope that it will be useful,         //
-//   but WITHOUT ANY WARRANTY; without even the implied warranty of          //
-//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
+//   but WITHOUT ANY WARRVY; without even the implied warranty of          //
+//   MERCHVABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
 //   GNU General Public License for more details.                            //
 //                                                                           //
 //   You should have received a copy of the GNU General Public License       //
@@ -20,12 +20,12 @@
 ///////////////////////////////////////////////////////////////////////////////
 Section Header
 
-  + name      := STATE;
+  + name      := STATE(V);
 
   - copyright := "2003-2010 Sonntag Benoit";
 
   - author    := "Sonntag Benoit (sonntag at icps.u-strasbg.fr)";
-  - comment   := "The main prototype";
+  - comment   := "State in hierarchical FSM";
 
 Section Inherit
 
@@ -33,25 +33,25 @@ Section Inherit
 
 Section Public
 
-  + begin_action:{ ANT; }; // BSBS: Mettre E
+  + begin_action:{ V; }; // BSBS: Mettre E
 
-  + action:{ ANT; };
+  + action:{ V; };
 
-  + end_action:{ ANT; };
+  + end_action:{ V; };
 
-  + transitions:FAST_ARRAY(TRANSITION);
+  + transitions:FAST_ARRAY(TRANSITION(V));
 
-  + sub_state:STATE;
+  + sub_state:STATE(V);
   
-  + parent_state:STATE;
+  + parent_state:STATE(V);
   
 Section STATE
   
-  - update_parent other:STATE <-
+  - update_parent other:STATE(V) <-
   (
     (parent_state != NULL).if {
       parent_state := other;
-      transitions.foreach { t:TRANSITION;
+      transitions.foreach { t:TRANSITION(V);
         t.state.update_parent other;
       };
     };
@@ -68,66 +68,66 @@ Section Public
   - create n:ABSTRACT_STRING :SELF <-
   create n begin_action NULL action NULL end_action NULL;
 
-  - create n:ABSTRACT_STRING begin_action b_a:{ ANT; } :SELF <-
+  - create n:ABSTRACT_STRING begin_action b_a:{ V; } :SELF <-
   create n begin_action b_a action NULL end_action NULL;
 
-  - create n:ABSTRACT_STRING action a:{ ANT; } :SELF <-
+  - create n:ABSTRACT_STRING action a:{ V; } :SELF <-
   create n begin_action NULL action a end_action NULL;
 
-  - create n:ABSTRACT_STRING end_action e_a:{ ANT; } :SELF <-
+  - create n:ABSTRACT_STRING end_action e_a:{ V; } :SELF <-
   create n begin_action NULL action NULL end_action e_a;
 
-  - create n:ABSTRACT_STRING begin_action b_a:{ ANT; }
-  action a:{ ANT; } :SELF <-
+  - create n:ABSTRACT_STRING begin_action b_a:{ V; }
+  action a:{ V; } :SELF <-
   create n begin_action b_a action a end_action NULL;
 
-  - create n:ABSTRACT_STRING begin_action b_a:{ ANT; }
-  end_action e_a:{ ANT; } :SELF <-
+  - create n:ABSTRACT_STRING begin_action b_a:{ V; }
+  end_action e_a:{ V; } :SELF <-
   create n begin_action b_a action NULL end_action e_a;
 
-  - create n:ABSTRACT_STRING action a:{ ANT; }
-  end_action e_a:{ ANT; } :SELF <-
+  - create n:ABSTRACT_STRING action a:{ V; }
+  end_action e_a:{ V; } :SELF <-
   create n begin_action NULL action a end_action e_a;
 
-  - create n:ABSTRACT_STRING begin_action b_a:{ ANT; }
-  action a:{ ANT; } end_action e_a:{ ANT; } :SELF <-
+  - create n:ABSTRACT_STRING begin_action b_a:{ V; }
+  action a:{ V; } end_action e_a:{ V; } :SELF <-
   ( + result:SELF;
     result := clone;
     result.make n begin_action b_a action a end_action e_a;
     result
   );
 
-  - make n:ABSTRACT_STRING begin_action b_a:{ ANT; }
-  action a:{ ANT; } end_action e_a:{ ANT; } <-
+  - make n:ABSTRACT_STRING begin_action b_a:{ V; }
+  action a:{ V; } end_action e_a:{ V; } <-
   (
     name := n;
     begin_action := b_a;
     action := a;
     end_action := e_a;
-    transitions := FAST_ARRAY(TRANSITION).create_with_capacity 2;
+    transitions := FAST_ARRAY(TRANSITION(V)).create_with_capacity 2;
   );
 
   //
   // Transition.
   //
 
-  - to other:STATE if cmp:{ ANT; BOOLEAN} <-
+  - to other:STATE(V) if cmp:{ V; BOOLEAN} <-
   (
-    transitions.add_last (TRANSITION.create other if cmp);
+    transitions.add_last (TRANSITION(V).create other if cmp);
   );
 
   //
   // Sub-state engin.
   //
 
-  - has other:STATE <-
+  - has other:STATE(V) <-
   (
     sub_state := other;
     other.update_parent Self;
   );
   
-  - run a:AGENT <- // BSBS E!!!
-  ( + ant:ANT;
+  - run a:AGENT(V) <- // BSBS E!!!
+  ( + ant:V;
     ant ?= a;
     (action != NULL).if {
       action.value ant;      
@@ -135,9 +135,9 @@ Section Public
     (parent_state != NULL).if {
       parent_state.run a;
     };
-    transitions.foreach { t:TRANSITION;
+    transitions.foreach { t:TRANSITION(V);
       (t.condition.value ant).if {
         a.set_state (t.state);
       };
     };
-  );
\ No newline at end of file
+  );
diff --git a/examples/standard/agent/transition.li b/examples/standard/agent/transition.li
index 2f71e81..fe4ab58 100644
--- a/examples/standard/agent/transition.li
+++ b/examples/standard/agent/transition.li
@@ -20,7 +20,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 Section Header
 
-  + name      := TRANSITION;
+  + name      := TRANSITION(V);
 
   - copyright := "2003-2010 Sonntag Benoit";
 
@@ -33,22 +33,22 @@ Section Inherit
 
 Section Public
 
-  + state:STATE;
+  + state:STATE(V);
 
-  + condition:{ ANT; BOOLEAN};
+  + condition:{ V; BOOLEAN};
 
   //
   // Creation.
   //
 
-  - create s:STATE if cmp:{ ANT; BOOLEAN} :SELF <-
+  - create s:STATE(V) if cmp:{ V; BOOLEAN} :SELF <-
   ( + result:SELF;
     result := clone;
     result.make s if cmp;
     result
   );
 
-  - make s:STATE if cmp:{ ANT; BOOLEAN} <-
+  - make s:STATE(V) if cmp:{ V; BOOLEAN} <-
   (
     state := s;
     condition := cmp;
diff --git a/examples/standard/agent/world.li b/examples/standard/agent/world.li
index a75159d..7a585d1 100644
--- a/examples/standard/agent/world.li
+++ b/examples/standard/agent/world.li
@@ -20,7 +20,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 Section Header
 
-  + name      := WORLD;
+  + name      := WORLD(V);
 
   - copyright := "2003-2010 Sonntag Benoit";
 
@@ -41,7 +41,7 @@ Section Public
     Self
   );
   
-  - add a:AGENT <-
+  - add a:AGENT(V) <-
   (
     agents.add_last a;
     "OK\n".print;
@@ -57,7 +57,7 @@ Section Public
     // Nothing.
     t ?= msg;
     (t != NULL).if {      
-      agents.foreach { a:AGENT;        
+      agents.foreach { a:AGENT(V);        
         a.run;
       };
     };

-- 
applications.git



More information about the Lisaac-commits mailing list