Alrighty, I've built a simple ascii model of a cellular autonoma:
as you can see, each element checks to see if either the one above it or the one below is has a value of 1. if either one does, it is assigned the value of 1.Code:int cells[50][50]; int main() { cells[0][24]=1; for(int a=1;a<50;a++) { for(int b=0;b<50;b++) { if( ((cells[a-1][b-1])==1) || ((cells[a-1][b+1])==1) ) cells[a][b]=1; } } for(a=0;a<50;a++) { for(int b=0;b<50;b++) { if(cells[a][b]) cout << (char)31; else cout << (char)0; } cout << endl; } cin.get(); }
when it gets to the edge, for some reason the edge elements are assigned values of 1, even though no element above them is true.
the edge ones check for elements that technically don't exist, but those nonexistant elements should still be false...
any ideas?
if i change it to this it works:
thanks a lot for the helpCode:int cells[50][51];