Conway's game of life
bearophile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Feb 3 06:01:50 PST 2015
Paul:
> enum WORLDSIZE = 20;
> enum INITIALPOP = 70; //experimental
> enum DEAD = 0;
> enum ALIVE = 1;
D enums don't need to be ALL UPPERCASE :-)
> int world[WORLDSIZE][WORLDSIZE];
Don't forget to compile with warnings active (it's a design error
of the D compiler to have them disabled by default).
> foreach(i; 0..INITIALPOP){
It's less bug-prone to make that index immutable:
foreach(immutable i; 0 .. initialPop) {
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list