git @ Cat's Eye Technologies Jaccia / d09040d
Change appearance of Slime to ":". Use latest yoob.Controller. catseye 7 years ago
14 changed file(s) with 139 addition(s) and 80 deletion(s). Raw diff Collapse all Expand all
5151
5252 - ` ` - empty space
5353 - `#` - wall (purely decorative)
54 - `%` - slime mold
54 - `:` - slime mold
5555 - `F` - food
5656 - `S` - "start" food (needed in Jacciata, optional in Jaccia)
5757 - `-` - exploratory head (Jacciata only)
7272 neighbourhoods different from the assumed von Neumann neighbourhood, and
7373 their use in the count operator. The Jaccia and Jacciata descriptions were
7474 rewritten in ALPACA 1.0, and do now take advantage of these features in order
75 to be written more succinctly.
75 to be written more succinctly. (The ASCII appearance of slime mold cells was
76 also changed, from the ridiculous `%` to the more aesthetically pleasing `:`.
77 This actually happened a month after 1.1 was released, so should technically
78 be 1.2, but this change is *so* difficult to account for and will *surely*
79 break your toolchain, so I ain't gonna bother with another version bump.)
7680
7781 Happy intelligence! Such as it is.
7882 Chris Pressey
66
77 <h1>Jaccia Demo</h1>
88
9 <button id="load">Load</button>
10 <button id="edit">Edit</button>
11 <button id="start">Start</button>
12 <button id="stop">Stop</button>
13 <button id="step">Step</button>
14 Speed: <input id="speed" type="range" min="0" max="200" value="0" />
15
916 <textarea id="input" rows="10">
1017 ########S##
11 #%%%%%%%%%#
12 #%###%###%#
13 #%#%#%%%#%#
14 #%#%#%#%###
15 #%%%#%#%#%#
16 #####%#%#%#
17 #%#%%%#%%%#
18 #%#%###%###
19 #%%%#%%%%%#
18 #:::::::::#
19 #:###:###:#
20 #:#:#:::#:#
21 #:#:#:#:###
22 #:::#:#:#:#
23 #####:#:#:#
24 #:#:::#:::#
25 #:#:###:###
26 #:::#:::::#
2027 #########F#
2128 </textarea>
2229
2330 <pre id="output" style="border: 1px solid blue">
2431 </pre>
25
26 <button id="start">Start</button>
27 <button id="stop">Stop</button>
28 <button id="step">Step</button>
29 <button id="load">Load</button>
30 Speed: <input id="speed" type="range" min="0" max="200" value="0" />
3132
3233 </body>
3334 <script src="yoob/controller.js"></script>
5859 'stop': 'stop',
5960 'step': 'step',
6061 'load': 'load',
62 'edit': 'edit',
63 'speed': 'speed',
6164 'source': 'input',
62 'speed': 'speed'
65 'display': 'output'
6366 });
67 c.click_load();
6468 </script>
66
77 <h1>Jacciata Demo</h1>
88
9 <button id="load">Load</button>
10 <button id="edit">Edit</button>
11 <button id="start">Start</button>
12 <button id="stop">Stop</button>
13 <button id="step">Step</button>
14 Speed: <input id="speed" type="range" min="0" max="200" value="0" />
15
916 <textarea id="input" rows="10">
1017 ####S####
11 #%%%%%%%#
12 #%#####%#
13 #%#%%%#%#
14 #%#%#%#%#
15 #%%%#%%%#
18 #:::::::#
19 #:#####:#
20 #:#:::#:#
21 #:#:#:#:#
22 #:::#:::#
1623 ##F######
1724 </textarea>
1825
1926 <pre id="output" style="border: 1px solid blue">
2027 </pre>
21
22 <button id="start">Start</button>
23 <button id="stop">Stop</button>
24 <button id="step">Step</button>
25 <button id="load">Load</button>
26 Speed: <input id="speed" type="range" min="0" max="200" value="0" />
2728
2829 </body>
2930 <script src="yoob/controller.js"></script>
5455 'stop': 'stop',
5556 'step': 'step',
5657 'load': 'load',
58 'edit': 'edit',
59 'speed': 'speed',
5760 'source': 'input',
58 'speed': 'speed'
61 'display': 'output'
5962 });
63 c.click_load();
6064 </script>
00 /*
1 * This file is part of yoob.js version 0.2-PRE
1 * This file is part of yoob.js version 0.3-PRE
22 * This file is in the public domain. See http://unlicense.org/ for details.
33 */
44 if (window.yoob === undefined) yoob = {};
1919 this.delay = 100;
2020 this.source = undefined;
2121 this.speed = undefined;
22 this.controls = {};
2223
23 var makeOnClick = function(controller, key) {
24 if (controller['click_' + key] !== undefined)
24 this.makeEventHandler = function(control, key) {
25 if (this['click_' + key] !== undefined) {
2526 key = 'click_' + key;
26 return function(e) { controller[key](); }
27 }
28 var self = this;
29 return function(e) {
30 self[key](control);
31 };
2732 };
2833
2934 /*
3439 */
3540 this.connect = function(dict) {
3641 var self = this;
37 var keys = ["start", "stop", "step", "load"];
42 var keys = ["start", "stop", "step", "load", "edit", "select"];
3843 for (var i in keys) {
3944 var key = keys[i];
4045 var value = dict[key];
4247 value = document.getElementById(value);
4348 }
4449 if (value !== undefined) {
45 value.onclick = makeOnClick(this, key);
50 if (key === 'select') {
51 value.onchange = this.makeEventHandler(value, key);
52 } else {
53 value.onclick = this.makeEventHandler(value, key);
54 }
55 this.controls[key] = value;
4656 }
4757 }
4858
49 var source = dict.source;
50 if (typeof source === 'string') {
51 source = document.getElementById(source);
52 }
53 if (source !== undefined) {
54 this.source = source;
59 var keys = ["source", "display"];
60 for (var i in keys) {
61 var key = keys[i];
62 var value = dict[key];
63 if (typeof value === 'string') {
64 value = document.getElementById(value);
65 }
66 if (value !== undefined) {
67 this[key] = value;
68 }
5569 }
5670
5771 var speed = dict.speed;
8397 this.click_load = function(e) {
8498 this.stop();
8599 this.load(this.source.value);
100 if (this.controls.edit) this.controls.edit.style.display = "inline";
101 if (this.controls.load) this.controls.load.style.display = "none";
102 if (this.controls.start) this.controls.start.disabled = false;
103 if (this.controls.step) this.controls.step.disabled = false;
104 if (this.controls.stop) this.controls.stop.disabled = false;
105 if (this.display) this.display.style.display = "block";
106 if (this.source) this.source.style.display = "none";
86107 };
87108
88109 this.load = function(text) {
89110 alert("load() NotImplementedError");
111 };
112
113 this.click_edit = function(e) {
114 this.stop();
115 if (this.controls.edit) this.controls.edit.style.display = "none";
116 if (this.controls.load) this.controls.load.style.display = "inline";
117 if (this.controls.start) this.controls.start.disabled = true;
118 if (this.controls.step) this.controls.step.disabled = true;
119 if (this.controls.stop) this.controls.stop.disabled = true;
120 if (this.display) this.display.style.display = "none";
121 if (this.source) this.source.style.display = "block";
122 };
123
124 this.click_select = function(control) {
125 this.stop();
126 var source = document.getElementById(
127 control.options[control.selectedIndex].value
128 );
129 var text = source.innerHTML;
130 text = text.replace(/\&lt;/g, '<');
131 text = text.replace(/\&gt;/g, '>');
132 text = text.replace(/\&amp;/g, '&');
133 if (this.source) this.source.value = text;
134 this.load(text);
90135 };
91136
92137 this.start = function() {
00 ####S####
1 #%%%%%%%#
2 #%#####%#
3 #%#%#%#%#
4 #%#%#%#%#
5 #%%%%%%%#
1 #:::::::#
2 #:#####:#
3 #:#:#:#:#
4 #:#:#:#:#
5 #:::::::#
66 ####F####
00 F
1 %%%%%%%%%
2 % % %
3 % % %%% %
4 % % % %
5 %%% % % %
6 % % %
7 % %%% %%%
8 % % %
9 %%% %%%%%
1 :::::::::
2 : : :
3 : : ::: :
4 : : : :
5 ::: : : :
6 : : :
7 : ::: :::
8 : : :
9 ::: :::::
1010 F
00 ########S##
1 #%%%%%%%%%#
2 #%###%###%#
3 #%#%#%%%#%#
4 #%#%#%#%###
5 #%%%#%#%#%#
6 #####%#%#%#
7 #%#%%%#%%%#
8 #%#%###%###
9 #%%%#%%%%%#
1 #:::::::::#
2 #:###:###:#
3 #:#:#:::#:#
4 #:#:#:#:###
5 #:::#:#:#:#
6 #####:#:#:#
7 #:#:::#:::#
8 #:#:###:###
9 #:::#:::::#
1010 #########F#
00 ####S####
1 #%%%%%%%#
2 #%#####%#
3 #%#%%%#%#
4 #%#%#%#%#
5 #%%%#%%%#
1 #:::::::#
2 #:#####:#
3 #:#:::#:#
4 #:#:#:#:#
5 #:::#:::#
66 ##F######
2323 function loadMapper(c) {
2424 if (c === ' ') return 'Space';
2525 if (c === '#') return 'Wall';
26 if (c === '%') return 'Slime';
26 if (c === ':') return 'Slime';
2727 if (c === 'S') return 'Food2';
2828 if (c === 'F') return 'Food';
2929 };
3030 function dumpMapper(s) {
3131 if (s === 'Space') return ' ';
3232 if (s === 'Wall') return '#';
33 if (s === 'Slime') return '%';
33 if (s === 'Slime') return ':';
3434 if (s === 'Food2') return 'S';
3535 if (s === 'Food') return 'F';
3636 };
4242 $Appearance = {
4343 'Food' => 'F',
4444 'Food2' => 'S',
45 'Slime' => '%',
45 'Slime' => ':',
4646 'Space' => ' ',
4747 'Wall' => '#',
4848
5151 $InputCodec = {
5252 'F' => 'Food',
5353 'S' => 'Food2',
54 '%' => 'Slime',
54 ':' => 'Slime',
5555 ' ' => 'Space',
5656 '#' => 'Wall',
5757
2323 function loadMapper(c) {
2424 if (c === ' ') return 'Space';
2525 if (c === '#') return 'Wall';
26 if (c === '%') return 'Slime';
26 if (c === ':') return 'Slime';
2727 if (c === '@') return 'Solved';
2828 if (c === 'F') return 'Finish';
2929 if (c === '-') return 'Head';
3333 function dumpMapper(s) {
3434 if (s === 'Space') return ' ';
3535 if (s === 'Wall') return '#';
36 if (s === 'Slime') return '%';
36 if (s === 'Slime') return ':';
3737 if (s === 'Solved') return '@';
3838 if (s === 'Finish') return 'F';
3939 if (s === 'Head') return '-';
9595 'Body' => '?',
9696 'Finish' => 'F',
9797 'Head' => '-',
98 'Slime' => '%',
98 'Slime' => ':',
9999 'Solved' => '@',
100100 'Space' => ' ',
101101 'Start' => 'S',
107107 '?' => 'Body',
108108 'F' => 'Finish',
109109 '-' => 'Head',
110 '%' => 'Slime',
110 ':' => 'Slime',
111111 '@' => 'Solved',
112112 ' ' => 'Space',
113113 'S' => 'Start',
33 * Slime Molds are Intelligent Maze-Solvers.
44 * April 11 2009, Chris Pressey, Cat's Eye Technologies.
55 * Updated to ALPACA 1.0 on March 20, 2013.
6 * Changed appearance of Slime from "%" to ":" April 6, 2013.
67 */
78
89 neighbourhood VonNeumann
1617 is Sustainer;
1718 state Food2 "S"
1819 is Sustainer;
19 state Slime "%"
20 state Slime ":"
2021 is Sustainer
2122 to Space when not 2 in VonNeumann is Sustainer.
22 * Inspired by Jaccia.
33 * April 11 2009, Chris Pressey, Cat's Eye Technologies.
44 * Updated to ALPACA 1.0 on March 20, 2013.
5 * Changed appearance of Slime from "%" to ":" April 6, 2013.
56 */
67
78 neighbourhood VonNeumann
2021 * head of an exploratory shoot) on at least two sides. Slime turns into an
2122 * exploratory head if there is adjacent starter material.
2223 */
23 state Slime "%"
24 state Slime ":"
2425 is Sustainer
2526 to Space when (not 2 in VonNeumann is Sustainer)
2627 /* this part lets conflicts be resolved */