Re: [livecode] [OT] cellular automata

From: Kassen <signal.automatique_at_gmail.com>
Date: Mon, 15 Sep 2008 13:57:46 +0200

2008/9/15 AlgoMantra <algomantra_at_gmail.com>

> Hey Guys, I am sure some of you have played around with them
> rulesets. I had a question, which if answered here, would prevent
> me the pain of finding yet another mailing list.
>
> The question is this: You can't possibly update all the cells
> simultaneously can you? The code runs, but it is still sequential
> over the array.
>

I'd take a somewhat simpler approach then Marcel (who's take I can't quite
comment on since I don't completely understand it).

I'd make a array of "cell" objects that hold both their state (say as a
integer) and a variable containing their next state where it has been
computed.

I'd loop over the array, for each cell calculating the "next state" based
on it's neighbour's "state". Then I'd loop over it again and copy all "next
state's" to the "states" and out comes a updated cellular automaton.

If you'd like to get clever you could call the two variables "state A" and
"state B" and instead of the second loop simply swap which one of the two
refers to the current state and which one is the temporary holder for
already calculated results, that would save some CPU.

There may be better methods but at least this will work; if you do run into
issues you could always go peek into the source of open implementations
later.

Yours,
Kas.
Received on Mon Sep 15 2008 - 12:00:15 BST

This archive was generated by hypermail 2.4.0 : Sun Aug 20 2023 - 16:02:23 BST