Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by TheDamian (Vicar)
on Apr 27, 2003 at 01:31 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://253438]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-03-28 12:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found