TITLE
game-life-faster - Interactive wrapper for Game::Life::Faster
SYNOPSIS
game-life-faster -help
game-life-faster -version
game-life-faster
life> place_points 0 0 .x ..x xxx
life> process
life> grid
..........
X.X.......
.XX.......
.X........
..........
..........
..........
..........
..........
..........
life> exit
OPTIONS
-autoclear
If this Boolean option is asserted, the screen is cleared before the grid is printed.
The default is -noautoclear
.
-autoprint
If this Boolean option is asserted, the grid is printed after it is processed.
The default is -noautoprint
.
-dead
-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 .
.
-faster
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
.
-help
This option displays the documentation for this script. The script then exits.
-living
-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
.
-pause
-pause 0.25
This option specifies the pause after each iteration, in seconds. It takes fractional values, but these are only useful if Time::HiRes can be loaded.
The default is -pause 0
.
-profile
-profile game-life-faster.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_faster.ini'
Windows: "$ENV{USERPROFILE}/game_life_faster.ini"
anything else: "$ENV{HOME}/.game-life-faster.ini"
Note that any explicitly-specified file must exist, but the default file need not exist.
-version
This option displays the version of this script. The script then exits.
DETAILS
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:
- size
-
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
. - breed
-
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
. - live
-
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
.
COMMANDS
The following commands are implemented:
active
life> active
This command displays the active portion of the grid as returned by the get_active_text_grid() method.
autoclear
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.
autoprint
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.
clear_grid
This command clears the grid.
clear_point
life> clear_point 1 1
This command clears the point at the given row and column. It is a synonym for unset_point.
clear_screen
This command clears the screen. It does nothing if standard out is not a terminal.
dead
This command displays the -dead setting. If an argument is provided, the setting is changed to the first character of that value.
dump
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()
.
exit
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.
grid
This command displays the grid. "Living" cells are represented by 'X'
, "dead" cells by '.'
.
help
This command displays the same help provided by the -help option, but the script does not exit.
living
This command displays the -living setting. If an argument is provided, the setting is changed to the first character of that value.
load
life> load -living * grid.txt 2 2
This command loads the grid with the contents of the file specified as the first argument. This file is a picture of the desired grid as "ASCII art".
The second and third arguments specify the row and column coordinates of the top left corner of the grid. Both default to 0
.
This command also takes the option -living
, which specifies the character which represents a living cell. The default is the value of -living
which was specified when the script was launched. Any cell represented by a character other than this is considered dead.
new
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.
pause
This command displays the -pause setting. If an argument is provided, the setting is changed to that value.
place_points
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.
The example places a glider in the top-left corner of the grid.
process
This command causes the game to be processed. An optional parameter specifies the number of iterations, the default being 1
.
save
life> save life.txt
This command saves the current object in a text file which contains the game-life-faster commands needed to recreate it. These commands can be re-executed by:
life> source life.txt
set_point
life> set_point 1 2
This command causes the cell in the specified row and columns to be set "living."
source
life> source life.source
This command opens the given file and reads commands from it.
step
This is just a synonym for process.
unset_point
life> unset_point 1 1
This command clears the point at the given row and column. It is a synonym for clear_point.
used
life> used
This command displays the used portion of the grid as returned by the get_used_text_grid() method.
AUTHOR
Thomas R. Wyant, III wyant at cpan dot org
COPYRIGHT AND LICENSE
Copyright (C) 2019-2022 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.