I've made a simple toy called Tacky Turtle. Basically, it's a virtual machine that runs randomly generated programs (any combination of symbols is a valid program), and the program controls a turtle which leaves a trail behind it.
The program's memory is a 'tape' which you can see on the right of the screen.
Getting started is easy, click 'Play' and then 'Randomize'.
You can share any interesting programs by clicking 'Share' and copying the link. Clicking that link will load the web player with that program pre-loaded. On desktop versions, you can load links by pasting it into the 'Share' dialog and clicking 'Load'.
There is a command list if you click "help" but if I recall correctly the commands are:
( rotate 5 degrees left
) rotate 5 degrees right
^ walk forward
r toggle red
g toggle green
b toggle blue
< previous tape position
> next tape position
- decrease tape value
+ increase tape value
= skip n instructions (n = tape value)
* repeat next instruction n times (n = tape value)
? skip next instruction if n is 0 (n = tape value)
Every other symbol is ignored (but still takes a cycle!)
MessiahAndrw wrote:Basically, it's a virtual machine that runs randomly generated programs
But why there is some regularity in every picture? It seems generated programs are not random. Or there is small random part which is repeated many times after some translation/rotation.
embryo wrote:But why there is some regularity in every picture? It seems generated programs are not random. Or there is small random part which is repeated many times after some translation/rotation.
If a program is randomly generated, that doesn't mean it can't create a regular output. It is able to repeat, as some commands trigger the tape position, and once the last tape was reached it jumps back to the first.
embryo wrote:And all translations follow a circle pattern.
No, the ones I took a screenshot of did, there are also some that don't. But that has a simple explanation: if the turtle moves always forward after each turn, and turns for example 10 times to the left, but 12 times to the right, it runs in a circle..
max wrote:It is able to repeat, as some commands trigger the tape position, and once the last tape was reached it jumps back to the first.
After random program ends the VM starts it again? Then why there are rotations and shifts every cycle? And all translations follow a circle pattern.
Randomness and regularity together are interesting area to explore, but understanding it is not a straight-forward process.
Yes it runs again. Just what Max said, if it runs the same thing over and over again (move forward, rotate right) there's a high chance it'll produce a circular pattern. Not all do and if you play with the tool you will get programs that generate straight patterns, things that look like scan lines, junk, etc.
Also, there is a tape device (I am simulating a turing machine) that acts as memory, and that can influence the looping and pattern behaviour of programs.
max wrote:if the turtle moves always forward after each turn, and turns for example 10 times to the left, but 12 times to the right, it runs in a circle..
MessiahAndrw wrote:Not all do and if you play with the tool you will get programs that generate straight patterns, things that look like scan lines, junk, etc.
Also, there is a tape device (I am simulating a turing machine) that acts as memory, and that can influence the looping and pattern behaviour of programs.
Nice toy to discover random regularities or regular randomness
I've been thinking about how a 3D version would work, and if the camera angle was static (you can't rotate the image) it would be simple because I merely have to draw the lines when the turtle moves. However if I implement the ability to rotate the display (which you'd want to), I'd have to redraw it from the new angle. I don't want to store a list of drawn lines, because this could be drawing hundreds of thousands of lines a second, and we'd quickly run out of memory.
So I'm thinking I could either do a voxel approach, where the turtle draws into a 512x512x512 voxel grid. This would look pixelated when zoomed up close though. An alternative approach would simply be to clear the display when you rotate, requiring the turtle to redraw.
Or, I could do a hybrid approach. Voxelize it into a low res (maybe 8x8x8) cloud that is only visible as a preview when you rotate, then you stop it fades out after a second (giving time for the turtle to start redrawing from the new angle).
That would work until you decide to add the "random number generator" function, although in that case you could store the seed so as to generate the same sequence of random numbers when redrawing and only change the seed when asked to re-generate the random numbers. Storing a seed wouldn't use much memory and there would be no increase in memory usage as more random numbers are generated as would have been the case with what was origianlly going to be my suggestion to store a list of the random numbers generated so that they can be repeated (I really should have known better than to even think of suggesting that LOL).
EDIT: I was actually meaning to post here anyway: this does look quite cool although I haven't tried it though... One more question/suggestion: does it generate random text or does it only use valid symbols which actually do something? If the former then it could get frustrating when a child decides to try changing something and can't understand why the pattern doesn't change!