Omnimaga

Calculator Community => Other Calculators => Topic started by: Nick on January 15, 2013, 08:48:02 pm

Title: [Lua] Cellular Automata
Post by: Nick on January 15, 2013, 08:48:02 pm
Cellular Automata

http://www.omnimaga.org/index.php?action=downloads;sa=view;down=843

This is an Nspire Lua version of Cellular Automata.

Features:
 - choose the fieldsize yourself
 - choose the number of generations that pass automatically (when it stops, you can go to the next gen with [enter]
 - choose the framerate at which the generations pass
 - toggle wraparound. When enabled, one row below the field's bottom row is the top row. That way with all the borders (The field never stops). When disabled, the field stops at the screenborders.
 - add standard states from a menu (glider, cross, Diagonal egg, Exploder, Dieing exploder r-Pentamino and Glidergun).
 - toggle tiles on the field using [tab] in edit mode

If you stop the animation with [esc] you go back to the starting positions.
Press [esc] again and you're back in the main menu. As long as you don't change the field size, all data is contained.
No saving option is implemented yet. When you quit the program, you lose the data.

11 sets of rules supported, select them, and many more options, with [menu].

Title: Re: Conway's Game of Life
Post by: DJ Omnimaga on January 15, 2013, 09:04:55 pm
Hmm nice, I gotta give this a try at some point. Does it support 320x240 grid? :P
Title: Re: Conway's Game of Life
Post by: epic7 on January 15, 2013, 09:08:47 pm
We both made the game of life at the same time :P
Here's mine btw (https://dl.dropbox.com/u/93019118/life.tns)

Only difference is that mine is in C and I don't attach the top-bottom/left-right edges like nick does.
Title: Re: Conway's Game of Life
Post by: Nick on January 15, 2013, 09:10:44 pm
Hmm nice, I gotta give this a try at some point. Does it support 320x240 grid? :P
No, for two reasons:
1. It is written in apilevel 1.0, so it does not support fullscreen (max of 318x212px)
2. It took way too long to calculate it for a big screen, that's why I put a restriction on it. This restriction might be stupid, but when I ran it w/o it on my pc, it started ventilating like hell, and I didn't dare to try it on calc.
Title: Re: Conway's Game of Life
Post by: epic7 on January 15, 2013, 09:16:59 pm
I could do that actually :P
'twould be easier to do that with ndless

Edit: Here ya go :P
https://dl.dropbox.com/u/93019118/life_full.tns
Title: Re: Conway's Game of Life
Post by: Sorunome on January 15, 2013, 10:49:53 pm
Looks interesting, but what is this game of life?
Title: Re: Conway's Game of Life
Post by: Juju on January 15, 2013, 11:42:21 pm
http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
Title: Re: Conway's Game of Life
Post by: Sorunome on January 15, 2013, 11:44:20 pm
Ah, that is a very interesting consept! :D
Title: Re: Conway's Game of Life
Post by: tr1p1ea on January 16, 2013, 01:29:16 am
Looks awesome, there are some 83+ variations as well. I believe Iambian has one on these forums somewhere.
Title: Re: Conway's Game of Life
Post by: Lionel Debroux on January 16, 2013, 01:48:12 am
Indeed, Conway's Game of Life is a classic learning exercise which can produce nifty patterns, there are many implementations for pretty much any platform :)
The ticalc.org archives contain several dozens of implementations, among which are:
http://www.ticalc.org/archives/files/fileinfo/338/33898.html (best TI-68k implementation, fast and multiple rules supported, documentation - if you want a source of inspiration for expanding the feature set of your program, this one is fantastic)
http://www.ticalc.org/archives/files/fileinfo/144/14483.html (TICT's simple implementation, hard-coded 23/3 rule, for the TI-68k series) / http://www.ticalc.org/archives/files/fileinfo/434/43471.html (my Nspire Clickpad/Touchpad Ndless 1.7/2.0 port)
Title: Re: Conway's Game of Life
Post by: tr1p1ea on January 16, 2013, 01:56:27 am
There are also some z80 implementations:

Iambians which supports multiple rules etc: http://www.ticalc.org/archives/files/fileinfo/445/44578.html

And i have one also that i made in a hurry (http://www.ticalc.org/archives/files/fileinfo/397/39705.html)
Title: Re: Conway's Game of Life
Post by: Xeda112358 on January 16, 2013, 02:02:39 am
Looks awesome, there are some 83+ variations as well. I believe Iambian has one on these forums somewhere.
That would be here (http://ourl.ca/15141/283545) and features a bazillion alternative rulesets he also explains his method somwhat to acheive such performance.
If we are sharing examples, Patrick Pendergast (tr1p1ea) wrote a Conway's Game of Life program. (http://www.ticalc.org/archives/files/fileinfo/397/39705.html) :P


EDIT: Dang, I was ninja'd >.> My computer died mid-post, but Chrome saved the majority of it XD
Title: Re: Conway's Game of Life
Post by: Nick on January 16, 2013, 05:25:56 am
I decided to implement all those from wikipedia, since those are the ones in that 68k game too i think.
there are 11 rules in total: Conway, replicator, replicator2, seeds, flakes, 34 Life, Diamoeba, 2x2, highlife, day&night and morley.
You can set them with the [menu] key.

Of course I changed the name to Cellular Automata :)

I only have some problems with those menu's. It seems that when I change it, the contents and th functions behind the menu change, but not the text and layout of the menu. That way you can't see what you're doing, you always see the same menu, and I have no clue what's going on...
I'll update it as soon as I get this fixed
Title: Re: [Lua] Cellular Automata
Post by: Nick on January 16, 2013, 07:38:51 am
Updated!

Now 11 different rules are supported, select with [menu].
Download is also updated, toghether wih the youtube vid.
Title: Re: [Lua] Cellular Automata
Post by: Lionel Debroux on January 16, 2013, 08:18:12 am
Relayed to the community at TI-Planet, like I did with your Uno game several weeks ago: http://tiplanet.org/forum/viewtopic.php?t=11117 .

How about adding a Cellular Automata item to the image in your signature ? :)
Title: Re: [Lua] Cellular Automata
Post by: Nick on January 16, 2013, 09:19:26 am
Relayed to the community at TI-Planet, like I did with your Uno game several weeks ago: http://tiplanet.org/forum/viewtopic.php?t=11117 .
How about adding a Cellular Automata item to the image in your signature ? :)
Thanks :)
And that uno game will be updated, just some more time..

I didn't know that other forms of cellular automata were possible, i only heard of conway's game of life.
It's nice to have done this, as you say in you french post, it really is a good exercise, but I learned the most about the different types and their function, I never realised there's such a wide range of useful applications...

edit: check this out :)
(http://img.removedfromgame.com/imgs/IMG_20130116_171447.jpg)

A stormtrooper!!!! (with some imagination)
Title: Re: [Lua] Cellular Automata
Post by: ElementCoder on January 16, 2013, 10:22:11 am
Interesting, now we only have to wait until the nspires themselves start reproducing :o Good job :)
Title: Re: [Lua] Cellular Automata
Post by: Xeda112358 on January 16, 2013, 12:44:45 pm
Very cool, that looks nice, Nick!
Title: Re: [Lua] Cellular Automata
Post by: tr1p1ea on January 16, 2013, 03:42:26 pm
Lol it does look like a Storm Trooper, nice! :).
Title: Re: [Lua] Cellular Automata
Post by: DJ Omnimaga on January 16, 2013, 11:38:56 pm
Nice update Nick :)
Title: Re: [Lua] Cellular Automata
Post by: Nick on January 17, 2013, 12:50:07 pm
Thanks :)

I plan on adding these features in the future:
 - More standard/known rules
 - 'Build' your own rules by setting Born and Survive numbers (1)
 - Add save and recall feature for patterns, right now it kinda sucks that you lose it when you quit...
 - Do not reset generation when going back to edit as long as you don't change anything.
 - be able to set a generation directly without being drawn. E.g. you want to know the 1500th generation of a pattern, but you don't want to wait until everything is calculated and drawn, then I'd make it just calculate, and only draw it when generation 1500 is reached, that should save a lot of time.

(1) a rule is basically just a set of numbers that equal the amount of living tiles from the Moore neighborhood (A cell has 8 neighbors)
+++
+O+ ==> + is neighbor, O is self
+++
So when you design your own rules, you say for example: B3S23 or B3/S23. This means:
When 2 or 3 neighbors are alive, Survive (if dead it stays dead).
When exactly 3 neighbors are alive, a dead cell is 'Born' (which means it gets lit)
So if you look closely you can see that B3/S23 is Conway's game of life rules set of a cellular automata.
Title: Re: [Lua] Cellular Automata
Post by: Ranman on January 17, 2013, 01:04:36 pm
edit: check this out :)
(http://img.removedfromgame.com/imgs/IMG_20130116_171447.jpg)

A stormtrooper!!!! (with some imagination)

I see a dragon looking directly at me... a hungry dragon!

I remember doing a Conway's Game of Life project in one of my undergrad courses. I really enjoyed that exercise.

Nice job Nick!  :)
Title: Re: [Lua] Cellular Automata
Post by: Xeda112358 on January 17, 2013, 05:42:32 pm
- 'Build' your own rules by setting Born and Survive numbers (1)
 - be able to set a generation directly without being drawn. E.g. you want to know the 1500th generation of a pattern, but you don't want to wait until everything is calculated and drawn, then I'd make it just calculate, and only draw it when generation 1500 is reached, that should save a lot of time.
I have always liked being able to play with my own rules (that was an awesome advantage in Iambian's program). And that second idea should be much faster O.O
Title: Re: [Lua] Cellular Automata
Post by: Nick on January 18, 2013, 02:28:52 pm
I've implemented the startgeneration, so you don't have to wait to get to generation 2000 for example. "Don't have to wait" is not exaclty true, it takes time of course, and the optimization is less than i expected.

example 3 sliderguns (smallest version) in a 50x75 field, generation 100
01:09 seconds with [enter]
00:53 seconds from startgeneration

as you can see it's not that big a deal, but it's something...