Newsgroups: comp.ai.games
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!yale!gumby!newsxfer.itd.umich.edu!news.mathworks.com!news.kei.com!wang!news
From: bruck@actcom.co.il (Uri Bruck)
Subject: Re: LIFE in PASCAL
Organization: ACTCOM - Internet Services in Israel
Date: Sun, 17 Sep 1995 22:49:07 GMT
Message-ID: <DF2nDv.D22@actcom.co.il>
References: <42tbks$f3a@usenet.INS.CWRU.Edu> <DEwz1I.xy@cs.openu.ac.il>
Sender: news@wang.com
Lines: 24

Patreanu Eldad (patrel@cs.openu.ac.il) wrote:
: What are the best algorithms for calculating the next generation? 
: ( m*n board, does it matter if the ends wrap or are 'dead'?)

The trivial thing is to setup two matrices, one for current generation and one
for next generation.
The first thing most proggramers do is go the current generation matrix and
calculate the number of neighbors for each cell and plug the 'live' or
'dead' at the corresponding cell in the next generation matrix.
There are faster ways.
you could go through the current generation matrix and use the value in the 
current cell to increment the value in its neighbors.
If it's 0 (dead) you just skip it and do no futher additions with that cell,
this way small populations would get updated real fast.
Another way would be to go through both matrices sequentially, 8 times. 
Basically you would doing the same 'work' the same number of calculation.
Depending on which language you use, this could actually save time. In C,
going through a matrix sequentially is faster.  By updating a specific
member of the neighborhood each time you would be going through both
matrices sequentially, and not sequentially through one, and semi-randoammly
(as far as the compiler is concerned) through the other. I can't make
 aguess as to how significant such a saving would be.
Uri

