Lovely! It reminds me of some methods of generating images with genetic programming, e.g. Karl Sims, http://dahart.com, and http://picbreeder.org. The main difference being a stack-based representation versus a tree-based one. Some people do use stack-based genetic programming, so it would be fun to hook this up to one of those systems and evolve textures.
One nice feature in the above strand of research is that the output value, instead of being mapped to a greyscale, is mapped via a colour map to produce colour images.
I am one of those people, because I see the examples and the text box but nothing appears to occur when I use it or try any of the examples.
Tried Chrome and FF (and disabling extensions), so I thought I was just doing it wrong.
However, I did a little more digging because of the discussions, and I think the button that I am supposed to click is hidden http://i.imgur.com/kI8TrfE.png
I dont know how this is happening across both browsers though, but I thought I would leave this here if anyone else is confused as I was.
Update:
After trying a few things, stretching the screen width made the button pop up.
This code run from console will generate and execute random codes, whenever it finds something new it stops (just reexecute it and it will continue searching)
var seen = seen || [];
while (true) {
c='';
m=30*Math.random();
var a='x0123456789dcp+*~!yPsqa-/^';
for (var i=0; i<m; i++) {
c+=a.charAt(Math.floor(Math.random()*a.length));
}
code.value = c;
buttonClick();
d=f.getImageData();
sum=0;
for (var i=0; i<5000; i++) {
sum+=d.data[i];
}
console.log('seen ', sum);
if (seen.indexOf(sum) < 0) {
seen.push(sum);
break;
}
}
The use of single digit constants is a bit strange. Why kot take the approach of dc and let constant tokens be any string of digits, separated either by a different token or whitespace? Or the rather simpler approach of forth where all tokens are separated by whitespace.
I also have to echo shat someone else mentioned: give Forth Haiku a try!
20 comments
[ 3.3 ms ] story [ 66.9 ms ] threadOne nice feature in the above strand of research is that the output value, instead of being mapped to a greyscale, is mapped via a colour map to produce colour images.
You can provide your own function that takes a number and returns an ARGB Int32, so for pretty flame you would just do.
L-systems could work as a stack system too perhaps ?
- the 'Try It' button disappears behind a text box if the browser window is too narrow, making you unable to use the tool. (edited after hobs' reply)
- 0 is black, 1 is white (and so is larger than 1).
- if a,b is on top of the stack, then - pops b and a and puts (a-b) on the stack
- the value on top of the stack (after the entire string was processed by the stack machine) will determine the final colour of the pixel
- the algorithm runs for every pixel, that's why it's kinda slow
Tried Chrome and FF (and disabling extensions), so I thought I was just doing it wrong.
However, I did a little more digging because of the discussions, and I think the button that I am supposed to click is hidden http://i.imgur.com/kI8TrfE.png
I dont know how this is happening across both browsers though, but I thought I would leave this here if anyone else is confused as I was.
Update: After trying a few things, stretching the screen width made the button pop up.
http://forthsalon.appspot.com/
It can get pretty crazy:
http://forthsalon.appspot.com/haiku-view/ahBzfmZvcnRoc2Fsb24...
http://www.ludumdare.com/compo/
The ImageData Constructor got support in Chrome 43 and FireFox 29.
so the palette program "x" generates a greyscale. "xy*" makes it orangy.
The original idea was compiling it to GLSL, but I got lazy. But it should be pretty easy to make it generate GLSL.
It doesn't do constant folding or any smart optimizations, but it should be pretty easy to code that in.
Example:
This:
Generates:"t" : push(time);
I also have to echo shat someone else mentioned: give Forth Haiku a try!