Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: cirCA-Sim - A Cellular Automata Simulator  (Read 5365 times)

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
cirCA-Sim - A Cellular Automata Simulator
« on: April 16, 2010, 02:23:27 pm »

    I was working on various projects that are interesting just to watch, for use as a sort of display, and one of the most recent ones was a version of
WireWorldWireWorld is a cellular automaton that simulates basic electronics (wires and electrons), particularly fun to mess around with basic logic gates and such in.  Cellular automata are a fairly simple sort of simulation, in which the "world" is a grid of cells, each in one of a finite number of states.  Then, depending on a set number of rules/conditions, each cell can change states. 

One example of a fairly simple cellular automaton is Conway's Game of Life.  Cells in "Life" are either "alive" or "dead".  A "dead" cell turns into an "alive" cell if there are exactly 3 "alive" cells next to it, and an "alive" cell turns into a dead cell if more than 3 or fewer than 2 "alive" cells are next to it.  The resulting patterns can be very interesting to watch.

But I digress, the point of this topic wasn't to explain cellular automata, but to "advertise" a program I wrote to simulate them.  After finishing the WireWorld program, I realized how simple it would be to turn it into a "Life" program, or any other cellular automaton.  But, rather than hard-coding a bunch of different rule sets, I decided to design a program that would load a set of rules from an external file, so multiple rule sets could be made up fairly quickly, and without the need for programming experience, or re-compiling a program.

The result of my efforts, cirCA-Sim.  cirCA-Sim is a Cellular Automata SIMulator, that uses CustomIzed Rules (lame, I know, but it's the best I could come up with).  Rules are loaded from an XML file containing a list of cells and the rules for changing them.  Then, a grid of cells is loaded either from a .txt or .bmp file, and the simulater runs one step at a time, once for each key-press.  It's a very simple program, the interface is very simple.  In fact, aside from the 3 keys used to load files and exit, and the use of any other key to step through the simulation, there isn't one.  See the README.txt in the .zip file for further directions, and the XMLFORMAT.txt for details on the tags used in the rule files.  Two rule files, one .txt format grid file, and two .bmp format grid files are included in the download, along with the windows binary, and the source-code.


Screenshots:




DOWNLOAD(531KB)




[/list]
« Last Edit: April 20, 2010, 09:40:42 pm by timmeh »
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: cirCA-Sim - A Cellular Automata Simulator
« Reply #1 on: April 16, 2010, 03:09:45 pm »

Sweet!

I've grown bored of these sort of things,
 but I always wanted to fiddle around with the rule sets.

I might give this a try.

Do you know if anyone's done this before?
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: cirCA-Sim - A Cellular Automata Simulator
« Reply #2 on: April 16, 2010, 05:11:27 pm »

Thanks.

I don't know, there's a good chance there's one out there, but a quick Google turned up mostly simulators designed for specific automata.  There were a fair number that allowed a lot of customization, but I didn't see one that allowed the creation of completely new cell states/types and such.  Then again, I didn't look very hard or long :P
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

Bricks

  • Bay Watcher
  • Because you never need one brick.
    • View Profile
Re: cirCA-Sim - A Cellular Automata Simulator
« Reply #3 on: April 16, 2010, 06:24:04 pm »

Mirek's Cellebration (or similar, can't quite remember) featured a number of different types of cellular automata and allowed for custom rule sets.
Logged
EMPATHY - being able to feel other peoples' stuff.

florian

  • Bay Watcher
    • View Profile
Re: cirCA-Sim - A Cellular Automata Simulator
« Reply #4 on: April 16, 2010, 07:19:41 pm »

There is Golly, which lets one define new rules.

As a challenge: Implement HashLife.
Logged

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: cirCA-Sim - A Cellular Automata Simulator
« Reply #5 on: April 19, 2010, 04:42:28 pm »

@Bricks & florian - Thanks for those, look very interesting!  I'll still be working on mine, although I'll definitely have to download those later for inspiration.

Just updated the link, here's what's new in this version:
  • Added settings.ini file, which currently only loads resolution.  However, there was a bug with resolution size before, so if you have any problems with the program starting up, try lowering the resolution.
  • Added 5 new search patterns/neighborhoods, and fixed a bug regarding the original two, when the radius was higher than 2.
  • Added mouse controls, both the menus and main screen can now be interacted with, see the README file for more information.
  • Grids can now be saved from within the simulator by pressing the 's' key.  See the README file for more information.
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: cirCA-Sim - A Cellular Automata Simulator
« Reply #6 on: April 19, 2010, 06:39:10 pm »

... :(

I was going to suggest Mirek's.

I would like to warn you, however, from a key missing feature of it: When flood-filling, it does *not* check to see if the new colour is the same as the old one. Thus, it infinite-loop crashes if you do.

If it weren't for that, it would be far better, simply becaue it works, and works very well(though not unbelievably fast, it has practically any ruleset that doesn't need to know about distant neighbours to compute the next state. And maybe even supports that with some userdll trickery that builds a map of the game with each update.
Logged
Eh?
Eh!

chaoticag

  • Bay Watcher
  • All Natural Pengbean
    • View Profile
Re: cirCA-Sim - A Cellular Automata Simulator
« Reply #7 on: April 19, 2010, 07:23:12 pm »

Looks like it needs an alleg42.dll file.

edit: got the file, but the program closes as soon as I open it.
« Last Edit: April 19, 2010, 07:29:53 pm by chaoticag »
Logged

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: cirCA-Sim - A Cellular Automata Simulator
« Reply #8 on: April 20, 2010, 09:43:21 pm »

@qwertyuiopas - Thanks for the heads up.  I'm assuming the flood-fill bug is in Mirek's, since mine doesn't have flood-fill :P  I think I may later work on some sort of masking for adjacent checks, so literally anything could be done with them, although I'm not quite sure how yet...

@chaoticag - Thanks for the heads up, the file is included in the download now!  You may want to try it again as a fresh download, it may be that the version of the DLL you downloaded was different from the version I compiled with...

Thanks for the input everyone!
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: cirCA-Sim - A Cellular Automata Simulator
« Reply #9 on: April 20, 2010, 10:33:26 pm »

Ironically, ever since I noticed that Mirek's had that bug, I have tried to avoid making it myself(the one time that I actually made a flood-fill, though, but if I ever did again, I would almost certainly remember that, like the return value of malloc, or the !=NULL of pointer arguments that must not be null, a flood-fill must never fill over itself, or Bad Things may happen.)
Logged
Eh?
Eh!

Alexhans

  • Bay Watcher
  • This is toodamn shortto write something meaningful
    • View Profile
    • Osteopatia y Neurotonia
Re: cirCA-Sim - A Cellular Automata Simulator
« Reply #10 on: April 21, 2010, 05:07:02 pm »

meh... there's so many interesting things going on and I still have so much to do...

Posting to check it out.

The worst thing is... Internet at work is sucking so I can't even browse the forum from there...
Logged
“Eight years was awesome and I was famous and I was powerful" - George W. Bush.

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: cirCA-Sim - A Cellular Automata Simulator
« Reply #11 on: April 21, 2010, 11:39:04 pm »

Well, unfortunately, you have a bit of time to catch up with me.

My computer crashed this morning... completely.  Hard-drive was horribly corrupted.  The good news is, I made a backup of all my important source code yesterday, and managed to salvage all my college files via my "Ultimate Boot CD 4 Windows".  The great news, is that the screen doesn't seem to flicker any more, which leads me to believe it was either a problem with the computer trying to access a part of the hard-drive that was corrupted, or some kind of virus.  The bad news, is that I still have to reorganize myself, and get an IDE set up, and all that crap again....

That being said, I'm considering switching IDEs... off to make a topic about that actually....
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.