[SCM] applications.git branch, master, updated. bec53a95c528e1115bf34736ea47c2a6092fa6e5

ontologiae ontologiae at ordinateur-de-ontologiae-3.local
Tue Mar 30 17:16:19 UTC 2010


The following commit has been merged in the master branch:
commit 4584406654b185eee9ed35f290570fb28dbdb529
Author: ontologiae <ontologiae at ordinateur-de-ontologiae-3.local>
Date:   Tue Mar 30 19:15:13 2010 +0200

    Update agent example

diff --git a/examples/standard/agent/ant.li b/examples/standard/agent/ant.li
index 56f203d..01ac5d2 100644
--- a/examples/standard/agent/ant.li
+++ b/examples/standard/agent/ant.li
@@ -59,24 +59,49 @@ Section Public
   
   - move <-
   (
-    "Move!!\n".print;
+    //"Move!!\n".print;
     x := (x + INTEGER.random_between (-1) and 1).min 254.max 1;
     y := (y + INTEGER.random_between (-1) and 1).min 254.max 1;
   );
   
+
+
+  - how_many_food  scr:FAST_ARRAY2(UINTEGER_8) : INTEGER <-
+  ( + px,py,stop : INTEGER;
+     py := -1;
+    px := -1;
+    { (px <= 1) && {py <= 1} }.while_do {
+      {px <= 1 }.while_do {
+        //"\npx=".print;px.print;"py=".print;py.print;
+        ({(px != 0) && {px != py}} && {scr.item (x+px,y+py) = 1}).if {         
+          stop := stop + 1;
+        };
+        px := px + 1;
+      };
+      py := py + 1; 
+    };
+    stop
+  );
+
+  // Y a t-il de la nouriture autour ? Si oui, la prend
   - get_food scr:FAST_ARRAY2(UINTEGER_8) <-
   ( + px,py:INTEGER;
     + stop:BOOLEAN;
     is_busy := TRUE;
+    //Compte combien il y a de nouriture autour
+
     py := -1;
+    px := -1;
     {(py <= 1) && {! stop}}.while_do {
-      px := -1;
-      {(px <= 1) && {! stop}}.while_do {        
-        ((px != py) && {scr.item (x+px,y+py) = 1}).if {
+      {(px <= 1) && {! stop}}.while_do {    
+        "GET FOOD !!!".printline;
+        ( {(px != 0) && {px != py}} && {scr.item (x+px,y+py) = 1} ).if {
           scr.put 0 to (x+px,y+py);
           stop := TRUE;
         };
+        px := px + 1;
       };
+      py := py + 1;
     };
   );
   
@@ -86,17 +111,12 @@ Section Public
     scr.put 1 to (x,y);
   );
 
-  - found_food scr:FAST_ARRAY2(UINTEGER_8) :BOOLEAN <-
-  ( + px,py:INTEGER;
-    + stop:BOOLEAN;
-    py := -1;
-    {(py <= 1) && {! stop}}.while_do {
-      px := -1;
-      {(px <= 1) && {! stop}}.while_do {        
-        ((px != py) && {scr.item (x+px,y+py) = 1}).if {         
-          stop := TRUE;
-        };
-      };
-    };
-    stop
+  - found_heap scr:FAST_ARRAY2(UINTEGER_8) :BOOLEAN <-
+  ( 
+    (how_many_food scr) > 3
+  );
+
+   - found_food scr:FAST_ARRAY2(UINTEGER_8) :BOOLEAN <-
+  (
+    (how_many_food scr) < 3
   );

-- 
applications.git



More information about the Lisaac-commits mailing list