Jump to content




One-Dimensional Cellular Automaton


10 replies to this topic

#1 TangentDelta

    Math Wizard

  • Members
  • 24 posts
  • LocationMathland

Posted 08 October 2012 - 05:06 PM

Greetings. I'm TangentDelta, one of the most active users on the IRC channel, and one of the original users of Computercraft!

Many of you might know me for my "TangentLock" program, one of the first public lock programs for ComputerCraft.

Today I have a very special program for you, a one-dimensional cellular automaton. What is a cellular automaton? It is basically a simple turing machine that manipulates bits according to a set of rules. To read more, visit the Wikipedia page here.

One-dimensional CA are used in the modern world for things like advanced programming algorithms, data encryption, artificial creativity, probability, sudo-random number generation, and abstract artwork.

This project was more of a fun relaxing thing for me to do in-between college classes. While working on it, I also put alot of effort into making it an educational script to help people better understand Lua. Nearly every line has a comment explaining what it does.

This program was completely coded within SciTE. The only actual computercraft testing that went on, was by Cruor on the IRC.




To use my program, install it like any other computercraft program. When you start it, it will ask you for a width. The width will define how large the environment for the CA will be. I recommend entering a number within the 2^n string, but anything will work. Make sure that your width isn't too small, or you won't see anything. Too large, and you'll run out of space on the computer screen. The bigger the width, the longer it will also take for the automaton to complete.

The next prompt will ask you for a rule. The rule is an 8-bit (numbers 0-255) decimal number, and corrosponds to Wolfram's code. To learn how these rules work, I highly recommend visiting the wikipedia link above. If you're lazy, you can look at a large list of interesting rules here.

After that's set up, you'll be asked if you want to enter a custom seed. In programming, a seed is a set of predetermined data that a program acts upon. If you choose to enter a seed by typing "y", enter the starting pattern in 1's and 0's (I'm unsure of what happens if you use anything else).

If you choose not to use a custom seed, you'll be asked if you want to use a random seed. If you choose yes to this, a random beginning seed will be generated and used.

If you don't choose to use a custom or random seed, the default seed will be chosen. The default seed is a single "on" cell in the middle of the starting seed. This seed usually generates triangular structures with very little chaos (with the exception of rule 110).

Once you've done all of that, the automaton will begin generating patterns based on your input. If the width is too wide, it might wrap around and distort, which is why smaller numbers are recommended for the width. If you're having a hard time with choosing a width, go with a width of 64.

My script can be found here: http://pastebin.com/Ru3nfViz

Change-log:
Spoiler

Screenshots:
Spoiler


#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 08 October 2012 - 05:26 PM

Sounds....neat, but what practical application does this have? I'm not up to speed in advanced computations such as this...

#3 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 08 October 2012 - 05:26 PM

So you did the first lock, huh?

#4 TangentDelta

    Math Wizard

  • Members
  • 24 posts
  • LocationMathland

Posted 08 October 2012 - 06:01 PM

View PostCranium, on 08 October 2012 - 05:26 PM, said:

Sounds....neat, but what practical application does this have? I'm not up to speed in advanced computations such as this...
1-dimensional CA are used in things like data encryption, plus they look really cool!

View Postjag_e_nummer_ett, on 08 October 2012 - 05:26 PM, said:

So you did the first lock, huh?
I didn't make the first lock for CC, but my lock was one of the first to be publicly availible.

#5 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 08 October 2012 - 06:03 PM

View PostTangentDelta, on 08 October 2012 - 06:01 PM, said:

My lock was one of the first to be publicly availible.
Hmm, ok...

#6 TangentDelta

    Math Wizard

  • Members
  • 24 posts
  • LocationMathland

Posted 08 October 2012 - 06:59 PM

Found a bug. If you input a width over 64, it overflows. I'll have to see why that is. Expect a patched version soon.

#7 TangentDelta

    Math Wizard

  • Members
  • 24 posts
  • LocationMathland

Posted 08 October 2012 - 07:13 PM

Darn, why do I keep calling variables before I define them? Updated.

#8 TangentDelta

    Math Wizard

  • Members
  • 24 posts
  • LocationMathland

Posted 09 October 2012 - 06:02 PM

I fixed/tweaked quite a few things, making 1.4 hundreds of times better than 1.3.1. Generating massive automatons should also be alot faster now, and cause no lag at all.

The turing function is now 100% my code, and should run two times as fast as before.

#9 Cruor

  • Members
  • 413 posts
  • LocationNorway

Posted 10 October 2012 - 03:16 PM

Nice work TD :P/>

For people who wants picturez, here is one from the test runs @ irc

https://dl.dropbox.c...05_15.48.20.png

#10 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 10 October 2012 - 03:55 PM

So you have to use a binary 1/0 input for the seed? I think you should add a binary generator based on the input the user adds. It would automatically convert any string into binary data, and convert numbers as well.

#11 TangentDelta

    Math Wizard

  • Members
  • 24 posts
  • LocationMathland

Posted 10 October 2012 - 08:15 PM

View PostCranium, on 10 October 2012 - 03:55 PM, said:

So you have to use a binary 1/0 input for the seed? I think you should add a binary generator based on the input the user adds. It would automatically convert any string into binary data, and convert numbers as well.
In my program, look at "dectobin", it does just that. How else do I decode the decimal rules? :P/>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users