Cellular Automata implementation
Does anybody know how to implement cellular automata in开发者_如何学运维 Java or C#?
I have write a Pseudo-Code implementation that you can use to write a .NET implementation:
function automate(cells,bornlist,survivelist,iterations)
{
loop(iterations)
{
loop(row < height)
{
loop(collumn < width)
{
if(is edge)
{
alive = true
}
else
{
num = add states of all cells around the outside (if in 3d include above and below and use less iterations)
state = cells[row,collumn]
alive = (state = 0 and bornlist.contains(num)) or (state = 1 and survivelist.contains(num))
}
cells[row,collumn] = alive ? 1 : 0
}
}
}
}
This relies on the fact that the cells have already been initialised with a random value by a noise generator such a Simplex or Perlin noise.
We need more info, like, what issues have you encountered, difficulties, etc. In the meantime, here are some links to help you:
http://www.primaryobjects.com/CMS/Article106.aspx
http://cplus.about.com/b/2008/08/17/programming-challenge-17-implement-the-cellular-automaton-known-as-life.htm
https://web.archive.org/web/20110503020104/http://www.kim-team.com/blog/2009/06/cellular-automaton-in-net/
Edit: thanks Halil, I've edited the answer to include web.archive.org link.
精彩评论