Commits

catseye  committed 235f461

Change appearance of Slime to ":". Use latest yoob.Controller.

  • Participants
  • Parent commits b8c9ef2

Comments (0)

Files changed (14)

File README.markdown

 
 -   ` ` - empty space
 -   `#` - wall (purely decorative)
--   `%` - slime mold
+-   `:` - slime mold
 -   `F` - food
 -   `S` - "start" food (needed in Jacciata, optional in Jaccia)
 -   `-` - exploratory head (Jacciata only)
 neighbourhoods different from the assumed von Neumann neighbourhood, and
 their use in the count operator.  The Jaccia and Jacciata descriptions were
 rewritten in ALPACA 1.0, and do now take advantage of these features in order
-to be written more succinctly.
+to be written more succinctly.  (The ASCII appearance of slime mold cells was
+also changed, from the ridiculous `%` to the more aesthetically pleasing `:`.
+This actually happened a month after 1.1 was released, so should technically
+be 1.2, but this change is *so* difficult to account for and will *surely*
+break your toolchain, so I ain't gonna bother with another version bump.)
 
 Happy intelligence! Such as it is.  
 Chris Pressey  

File demo/jaccia.html

 
 <h1>Jaccia Demo</h1>
 
+<button id="load">Load</button>
+<button id="edit">Edit</button>
+<button id="start">Start</button>
+<button id="stop">Stop</button>
+<button id="step">Step</button>
+Speed: <input id="speed" type="range" min="0" max="200" value="0" />
+
 <textarea id="input" rows="10">
 ########S##
-#%%%%%%%%%#
-#%###%###%#
-#%#%#%%%#%#
-#%#%#%#%###
-#%%%#%#%#%#
-#####%#%#%#
-#%#%%%#%%%#
-#%#%###%###
-#%%%#%%%%%#
+#:::::::::#
+#:###:###:#
+#:#:#:::#:#
+#:#:#:#:###
+#:::#:#:#:#
+#####:#:#:#
+#:#:::#:::#
+#:#:###:###
+#:::#:::::#
 #########F#
 </textarea>
 
 <pre id="output" style="border: 1px solid blue">
 </pre>
 
-<button id="start">Start</button>
-<button id="stop">Stop</button>
-<button id="step">Step</button>
-<button id="load">Load</button>
-Speed: <input id="speed" type="range" min="0" max="200" value="0" />
-
 </body>
 <script src="yoob/controller.js"></script>
 <script src="yoob/playfield.js"></script>
     'stop': 'stop',
     'step': 'step',
     'load': 'load',
+    'edit': 'edit',
+    'speed': 'speed',
     'source': 'input',
-    'speed': 'speed'
+    'display': 'output'
   });
+  c.click_load();
 </script>

File demo/jacciata.html

 
 <h1>Jacciata Demo</h1>
 
+<button id="load">Load</button>
+<button id="edit">Edit</button>
+<button id="start">Start</button>
+<button id="stop">Stop</button>
+<button id="step">Step</button>
+Speed: <input id="speed" type="range" min="0" max="200" value="0" />
+
 <textarea id="input" rows="10">
 ####S####
-#%%%%%%%#
-#%#####%#
-#%#%%%#%#
-#%#%#%#%#
-#%%%#%%%#
+#:::::::#
+#:#####:#
+#:#:::#:#
+#:#:#:#:#
+#:::#:::#
 ##F######
 </textarea>
 
 <pre id="output" style="border: 1px solid blue">
 </pre>
 
-<button id="start">Start</button>
-<button id="stop">Stop</button>
-<button id="step">Step</button>
-<button id="load">Load</button>
-Speed: <input id="speed" type="range" min="0" max="200" value="0" />
-
 </body>
 <script src="yoob/controller.js"></script>
 <script src="yoob/playfield.js"></script>
     'stop': 'stop',
     'step': 'step',
     'load': 'load',
+    'edit': 'edit',
+    'speed': 'speed',
     'source': 'input',
-    'speed': 'speed'
+    'display': 'output'
   });
+  c.click_load();
 </script>

File demo/yoob/controller.js

 /*
- * This file is part of yoob.js version 0.2-PRE
+ * This file is part of yoob.js version 0.3-PRE
  * This file is in the public domain.  See http://unlicense.org/ for details.
  */
 if (window.yoob === undefined) yoob = {};
     this.delay = 100;
     this.source = undefined;
     this.speed = undefined;
+    this.controls = {};
 
-    var makeOnClick = function(controller, key) {
-        if (controller['click_' + key] !== undefined)
+    this.makeEventHandler = function(control, key) {
+        if (this['click_' + key] !== undefined) {
             key = 'click_' + key;
-        return function(e) { controller[key](); }
+        }
+        var self = this;
+        return function(e) {
+          self[key](control); 
+        };
     };
 
     /*
      */
     this.connect = function(dict) {
         var self = this;
-        var keys = ["start", "stop", "step", "load"];
+        var keys = ["start", "stop", "step", "load", "edit", "select"];
         for (var i in keys) {
             var key = keys[i];
             var value = dict[key];
                 value = document.getElementById(value);
             }
             if (value !== undefined) {
-                value.onclick = makeOnClick(this, key);
+                if (key === 'select') {
+                    value.onchange = this.makeEventHandler(value, key);
+                } else {
+                    value.onclick = this.makeEventHandler(value, key);
+                }
+                this.controls[key] = value;
             }
         }
 
-        var source = dict.source;
-        if (typeof source === 'string') {
-            source = document.getElementById(source);
-        }
-        if (source !== undefined) {
-            this.source = source;
+        var keys = ["source", "display"];
+        for (var i in keys) {
+            var key = keys[i];
+            var value = dict[key];
+            if (typeof value === 'string') {
+                value = document.getElementById(value);
+            }
+            if (value !== undefined) {
+                this[key] = value;
+            }
         }
 
         var speed = dict.speed;
     this.click_load = function(e) {
         this.stop();
         this.load(this.source.value);
+        if (this.controls.edit) this.controls.edit.style.display = "inline";
+        if (this.controls.load) this.controls.load.style.display = "none";
+        if (this.controls.start) this.controls.start.disabled = false;
+        if (this.controls.step) this.controls.step.disabled = false;
+        if (this.controls.stop) this.controls.stop.disabled = false;
+        if (this.display) this.display.style.display = "block";
+        if (this.source) this.source.style.display = "none";
     };
 
     this.load = function(text) {
         alert("load() NotImplementedError");
     };
 
+    this.click_edit = function(e) {
+        this.stop();
+        if (this.controls.edit) this.controls.edit.style.display = "none";
+        if (this.controls.load) this.controls.load.style.display = "inline";
+        if (this.controls.start) this.controls.start.disabled = true;
+        if (this.controls.step) this.controls.step.disabled = true;
+        if (this.controls.stop) this.controls.stop.disabled = true;
+        if (this.display) this.display.style.display = "none";
+        if (this.source) this.source.style.display = "block";
+    };
+
+    this.click_select = function(control) {
+        this.stop();
+        var source = document.getElementById(
+          control.options[control.selectedIndex].value
+        );
+        var text = source.innerHTML;
+        text = text.replace(/\&lt;/g, '<');
+        text = text.replace(/\&gt;/g, '>');
+        text = text.replace(/\&amp;/g, '&');
+        if (this.source) this.source.value = text;
+        this.load(text);
+    };
+
     this.start = function() {
         if (this.intervalId !== undefined)
             return;

File eg/nonunique.jac

 ####S####
-#%%%%%%%#
-#%#####%#
-#%#%#%#%#
-#%#%#%#%#
-#%%%%%%%#
+#:::::::#
+#:#####:#
+#:#:#:#:#
+#:#:#:#:#
+#:::::::#
 ####F####

File eg/nowalls.jac

         F  
- %%%%%%%%% 
- %   %   % 
- % % %%% % 
- % % % %   
- %%% % % % 
-     % % % 
- % %%% %%% 
- % %   %   
- %%% %%%%% 
+ ::::::::: 
+ :   :   : 
+ : : ::: : 
+ : : : :   
+ ::: : : : 
+     : : : 
+ : ::: ::: 
+ : :   :   
+ ::: ::::: 
          F 

File eg/solveit.jac

 ########S##
-#%%%%%%%%%#
-#%###%###%#
-#%#%#%%%#%#
-#%#%#%#%###
-#%%%#%#%#%#
-#####%#%#%#
-#%#%%%#%%%#
-#%#%###%###
-#%%%#%%%%%#
+#:::::::::#
+#:###:###:#
+#:#:#:::#:#
+#:#:#:#:###
+#:::#:#:#:#
+#####:#:#:#
+#:#:::#:::#
+#:#:###:###
+#:::#:::::#
 #########F#

File eg/unique.jac

 ####S####
-#%%%%%%%#
-#%#####%#
-#%#%%%#%#
-#%#%#%#%#
-#%%%#%%%#
+#:::::::#
+#:#####:#
+#:#:::#:#
+#:#:#:#:#
+#:::#:::#
 ##F######

File script/jaccia.js

 function loadMapper(c) {
   if (c === ' ') return 'Space';
   if (c === '#') return 'Wall';
-  if (c === '%') return 'Slime';
+  if (c === ':') return 'Slime';
   if (c === 'S') return 'Food2';
   if (c === 'F') return 'Food';
 };
 function dumpMapper(s) {
   if (s === 'Space') return ' ';
   if (s === 'Wall') return '#';
-  if (s === 'Slime') return '%';
+  if (s === 'Slime') return ':';
   if (s === 'Food2') return 'S';
   if (s === 'Food') return 'F';
 };

File script/jaccia.pl

 $Appearance = {
   'Food' => 'F',
   'Food2' => 'S',
-  'Slime' => '%',
+  'Slime' => ':',
   'Space' => ' ',
   'Wall' => '#',
 
 $InputCodec = {
   'F' => 'Food',
   'S' => 'Food2',
-  '%' => 'Slime',
+  ':' => 'Slime',
   ' ' => 'Space',
   '#' => 'Wall',
 

File script/jacciata.js

 function loadMapper(c) {
   if (c === ' ') return 'Space';
   if (c === '#') return 'Wall';
-  if (c === '%') return 'Slime';
+  if (c === ':') return 'Slime';
   if (c === '@') return 'Solved';
   if (c === 'F') return 'Finish';
   if (c === '-') return 'Head';
 function dumpMapper(s) {
   if (s === 'Space') return ' ';
   if (s === 'Wall') return '#';
-  if (s === 'Slime') return '%';
+  if (s === 'Slime') return ':';
   if (s === 'Solved') return '@';
   if (s === 'Finish') return 'F';
   if (s === 'Head') return '-';

File script/jacciata.pl

   'Body' => '?',
   'Finish' => 'F',
   'Head' => '-',
-  'Slime' => '%',
+  'Slime' => ':',
   'Solved' => '@',
   'Space' => ' ',
   'Start' => 'S',
   '?' => 'Body',
   'F' => 'Finish',
   '-' => 'Head',
-  '%' => 'Slime',
+  ':' => 'Slime',
   '@' => 'Solved',
   ' ' => 'Space',
   'S' => 'Start',

File src/jaccia.alp

  *   Slime Molds are Intelligent Maze-Solvers.
  * April 11 2009, Chris Pressey, Cat's Eye Technologies.
  * Updated to ALPACA 1.0 on March 20, 2013.
+ * Changed appearance of Slime from "%" to ":" April 6, 2013.
  */
 
 neighbourhood VonNeumann
    is Sustainer;
 state Food2 "S"
    is Sustainer;
-state Slime "%"
+state Slime ":"
    is Sustainer
    to Space when not 2 in VonNeumann is Sustainer.

File src/jacciata.alp

  * Inspired by Jaccia.
  * April 11 2009, Chris Pressey, Cat's Eye Technologies.
  * Updated to ALPACA 1.0 on March 20, 2013.
+ * Changed appearance of Slime from "%" to ":" April 6, 2013.
  */
 
 neighbourhood VonNeumann
  * head of an exploratory shoot) on at least two sides.  Slime turns into an
  * exploratory head if there is adjacent starter material.
  */
-state Slime "%"
+state Slime ":"
    is Sustainer
    to Space when (not 2 in VonNeumann is Sustainer)
                  /* this part lets conflicts be resolved */