game-life - Interactive wrapper for Game::Life::Faster
game-life -help game-life -version game-life life> place_points 0 0 .x ..x xxx life> process life> grid .......... X.X....... .XX....... .X........ .......... .......... .......... .......... .......... .......... life> exit
If this Boolean option is asserted, the screen is cleared before the grid is printed.
The default is -noautoclear.
-noautoclear
If this Boolean option is asserted, the grid is printed after it is processed.
The default is -noautoprint.
-noautoprint
-dead +
This option specifies the character to be used for "dead" cells. If a letter is specified, uses of this letter on input will be case-blind.
The default is -dead ..
-dead .
If this Boolean option is asserted, Game::Life::Faster is used; if not, Game::Life is used.
The default is -faster, but it can be negated using -nofaster.
-faster
-nofaster
This option displays the documentation for this script. The script then exits.
-living *
This option specifies the character to be used for "living" cells. If a letter is specified, uses of this letter on input will be case-blind.
The default is -living X.
-living X
-profile game-life.ini
This option specifies a profile file to read before prompting the user. The default depends on the operating system:
VMS: 'sys$login:game_life.ini'
Windows: "$ENV{USERPROFILE}/game_life.ini"
anything else: "$ENV{HOME}/.game-life.ini"
Note that any explicitly-specified file must exist, but the defaut file need not exist.
This option displays the version of this script. The script then exits.
This Perl script provides an interactive interface to Game::Life::Faster, or optionally to Game::Life.
In addition to the above options this script accepts one to three arguments:
This is the size of the grid to produce. It is either a positive integer, or two positive integers separated by a comma. The former produces a square grid of the given size. The latter produces a rectangular grid of the given width and height.
The default is 20.
20
This is the breeding rule, specified as a comma-separated list of non-negative integers. "Dead" cells having one of the specified numbers of "living" neighbors will become "living" in the next generation.
The default is 3.
3
This is the living rule, specified as a comma-separated list of non-negative integers. "Living" cells having one of the specified numbers of "living" neighbors will remain "living" in the next generation; all other "living" cells will become "dead" in the next generation.
The default is 2,3.
2,3
The following commands are implemented:
life> active
This command displays the active portion of the grid as returned by the get_active_text_grid() method.
This command displays the -autoclear setting. If an argument is provided, the setting is changed to that value, which is interpreted as a Perl Boolean value, except for special-case values false, no, or off (case-insensitive), which are treated as false.
false
no
off
This command displays the -autoprint setting. If an argument is provided, the setting is changed to that value, which is interpreted as a Perl Boolean value, except for special-case values false, no, or off (case-insensitive), which are treated as false.
This command clears the grid.
life> clear_point 1 1
This command clears the point at the given row and column. It is a synonym for unset_point.
This command clears the screen. It does nothing if standard out is not a terminal.
This command displays the -dead setting. If an argument is provided, the setting is changed to the first character of that value.
This command is unsupported, in the sense that the author reserves the right to change or revoke it without notice.
If arguments are specified, the first argument is the name of a Game::Life::Faster method, and the value dumped is the result of calling that method with the subsequent arguments.
If no arguments are specified, the internal representation of the grid is dumped.
The output is serialized using Data::Dump::dump() if that can be loaded, otherwise with Data::Dumper::Dumper().
Data::Dump::dump()
Data::Dumper::Dumper()
This command is the equivalent of end-of-file. If issued in a source file it terminates processing of that file. If issued from standard input or in response to a command prompt, this script exits.
This command displays the grid. "Living" cells are represented by 'X', "dead" cells by '.'.
'X'
'.'
This command displays the same help provided by the -help option, but the script does not exit.
This command displays the -living setting. If an argument is provided, the setting is changed to the first character of that value.
life> new -faster 20 2 2,3
This command replaces the old game object with a new one. The arguments are the same as for the script itself, but the only supported option is -faster. All arguments and options default to their previous value.
life> place_points 0 0 .x ..x xxx
This command places points into the grid. The first two arguments are the row and column coordinates of the first point. Subsequent arguments are string representations of the points to be placed, with each argument representing consecutive cells in consecutive rows. "Living" cells are represented by 'X' or 'x'; any other character represents a "dead" cell.
'x'
The example places a glider in the top-left corner of the grid.
This command causes the game to be processed. An optional parameter specifies the number of iterations, the default being 1.
1
life> save life.txt
This command saves the current object in a text file which contains the game-life commands needed to recreate it. These commands can be re-executed by source-ing the file:
life> source life.txt
life> set_point 1 2
This command causes the cell in the specified row and columns to be set "living."
life> source life.source
This command opens the given file and reads commands from it.
life> unset_point 1 1
This command clears the point at the given row and column. It is a synonym for clear_point.
life> used
This command displays the used portion of the grid as returned by the get_used_text_grid() method.
Thomas R. Wyant, III wyant at cpan dot org
Copyright (C) 2019-2021 by Thomas R. Wyant, III
This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
To install Game::Life::Faster, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Game::Life::Faster
CPAN shell
perl -MCPAN -e shell install Game::Life::Faster
For more information on module installation, please visit the detailed CPAN module installation guide.