Game::Life

Game::Life - Plays Conway's Game of Life.
Download

Game::Life Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Michael K. Neylon
  • Publisher web site:
  • http://search.cpan.org/~dmuey/Hash-Merge-0.10/Merge.pm

Game::Life Tags


Game::Life Description

Game::Life - Plays Conway's Game of Life. Game::Life - Plays Conway's Game of Life.SYNOPSIS use Game::Life; my $game = new Game::Life( 20 ); my $starting = , , ]; $game->place_points( 10, 10, $starting ); for (1..20) { my $grid = $game->get_grid(); foreach ( @$grid ) { print map { $_ ? 'X' : '.' } @$_; print "n"; } print "nn"; $game->process(); }Conway's Game of Life is a basic example of finding 'living' patterns in rather basic rulesets (see NOTES). The Game of Life takes place on a 2-D rectangular grid, with each grid point being either alive or dead. If a living grid point has 2 or 3 neighbors within the surrounding 8 points, the point will remain alive in the next generation; any fewer or more will kill it. A dead grid point will become alive if there are exactly 3 living neighbors to it. With these simple rules, fascinating structures such as gliders that move across the grid, glider guns that generate these gliders, XOR gates, and others have been found.This module simply provides a way to simulate the Game of Life in Perl.In terms of coordinate systems as used in place_points, toggle_point and other functions, the first coodinate is the vertical direction, 0 being the top of the board, and the second is the horizontal direaction, 0 being the left side of the board. Thus, toggling the point of (3,2) will switch the state of the point in the 4th row and 3rd column.The edges of the board are currently set as "flat"; cells on the edge do not have any neighbors, and thus will 'fall' off the board. Future versions may allow for 'warp' edges (if a cell moves off the left side it reappears on the right side). Requirements: · Perl


Game::Life Related Software