zaphnat
zaphnat

Reputation: 287

What algorithm can I implement to speed up some Cellular Automata simulations?

I am writing a ncurses based C.A. simulator for (nearly) any kind of C.A. which uses the Moore or Neumann neighborhoods.

With the current (hardcoded and most obvious [running state funcs]) the simulation runs pretty well; until the screen is filled with 'on' (or whatever active) cells.

So my question is: Are there any efficient algorithms for handling at least life-like rules? or Generations, Weighted life/generations...

Thanks.

Upvotes: 3

Views: 567

Answers (3)

Marc Müller
Marc Müller

Reputation: 717

You could look into the HashLife algorithm and try to adapt its concept to whatever automata you are working on.

Upvotes: 1

Autoplectic
Autoplectic

Reputation: 7676

it's generally nice to only run update passes in areas of the grid that had activity in the previous time step. if you keep a boolean lattice of "did i change this time?" for each pass, you only need to update cells within one radius of those with an "on" in the change lattice.

Upvotes: 3

Luka Rahne
Luka Rahne

Reputation: 10517

I think writing state machines is not as much algorhitms designing problem as is just problem how to write clean and "bug free" code. What are you probably looking for is implementation of cellular automata / state chart.

http://www.state-machine.com/ //<- no this is not coincidence http://www.boost.org/doc/libs/1_40_0/libs/statechart/doc/index.html

You might also try whit stackless python http://stackless.com/. It can be used for state machines or CA. Here http://members.verizon.net/olsongt/stackless/why_stackless.html#the-factory it is tutorial for stackless implementing factory process simulation

Upvotes: 1

Related Questions