Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Cellular automata constrained inside boundaries' topicStudent Support Forum > General > "Cellular automata constrained inside boundaries"

Next Comment >Help | Reply To Topic
Author Comment/Response
Philip Riggs
12/13/05 11:29am

Hi. I have been learning about CA from several books. However, all the examples I have seen uses the cell value on the opposite side of the grid for boundary cells. I would like for the boundary case not to use those cell values. In other words, given the grid:

1 2 3
4 5 6
7 8 9

The usual way of calculating cell 1's value using the Moore neighborhood, as I understand, would be 1 + 2 + 4 + 5 + 3 + 6 + 7 + 8 + 9. I would like cell 1 to be 1 + 2 + 4 + 5.

I am guessing that this is the usual approach because RotateRight[] makes the programming simple. How would I change to program to accomplish what I want?

Here is the critical code from the Game of Life program from "An Introduction to Programming in Mathematica" by Wellin, Gaylord, and Kannin:

liveNeighbors[mat_]:=Apply [Plus, Map[RotateRight[mat, #] &, {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}}]];

Thanks for any help.

URL: ,

Subject (listing for 'Cellular automata constrained inside boundaries')
Author Date Posted
Cellular automata constrained inside boundaries Philip Riggs 12/13/05 11:29am
Re: Cellular automata constrained inside bounda... yehuda ben-s... 12/15/05 02:54am
Next Comment >Help | Reply To Topic