Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Prolegemona To A Future Scripting Language: Game Of Life In Perl 6

by TheDamian (Priest)
on Apr 27, 2003 at 01:31 UTC ( #253438=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $life = new life: 20;
    
  2. or download this
    
    loop { $life.display() }
    
  3. or download this
    
    class life
    ...
      has Int          $.count;
      has Int          $.max;
      has Array of Bit @.grid;
    
  4. or download this
    
      method BUILD(Int $dim)
    
  5. or download this
      {
        $.count = 0;
        $.max = $dimension-1;
        my Array of Bit @grid is dim($dim,$dim) is default(0);
    
  6. or download this
        @grid[$dim / 2 - 1][$dim / 2    ] = 1;
        @grid[$dim / 2 - 1][$dim / 2 + 1] = 1;
    ...
        @grid[$dim / 2    ][$dim / 2 - 1] = 1;
        @grid[$dim / 2 + 1][$dim / 2    ] = 1;
        @.grid := @grid;
    
  7. or download this
      }
    
      sub iterate (&block) 
    
  8. or download this
      {
        for 0..$.max -> $x 
    
  9. or download this
       {
          for 0..$.max -> $y 
    ...
          @newgrid[$^x][$^y] =  $live==2 && @.grid[$^x][$^y] 
                             || $live==3;
        }
    
  10. or download this
        @.grid = @newgrid;
      }
    ...
        print "\n";
        print "Turn $(++$.count), press enter to continue or ctl-c to quit
    +;
        <$*IN>;
    
  11. or download this
        .calculate();
      }
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://253438]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (18)
As of 2015-07-30 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls