Archived

This topic is now archived and is closed to further replies.

Starwind8748

I'm doing the game of life!

Recommended Posts

Not terribly efficient, but short enough:

  
int indexwrap( int x, int xdim )
{
x %= xdim;
return (x<0)?x+xdim:x;
}

int count( int x, int y, int xdim, int ydim )
{
int i,j;
count = 0;
for( i = x-1; i < x+2; ++i )
for( j = y-1; j < y+2; ++j )
count += !((i==x) && (j==y)) && cell[indexwrap(i,xdim)][indexwrap(j,ydim)];
return count;
}

Share this post


Link to post
Share on other sites
It''s been a while since I played, but I don''t remember any neighbors. I remember getting babies in the back of the stationwagon, and the occasional car crash would dump them all out onto the playing board (oh the humanity!).

Share this post


Link to post
Share on other sites
quote:
Original post by Stoffel
It''s been a while since I played, but I don''t remember any neighbors. I remember getting babies in the back of the stationwagon, and the occasional car crash would dump them all out onto the playing board (oh the humanity!).


ROFL

Share this post


Link to post
Share on other sites