IN101 project on Conway's Game of Life
|
The app-naive-conway
and app-list-conway
application features a standard options parser.
It is developped in naive_optionsparser.h / list_optionsparser.h and naive_optionsparser.c / list_optionsparser.c and used in app-naive-conway.c / app-list-conway.c.
The implemented options are:
For app-list-conway
is also available:
and are stored in a naive_options or list_options structure.
The options parser will analyse all command-line arguments until one without a preceding dash (-
) is found. It will then scan all characters following the dash and apply them to their corresponding options, or crash the program if they don't match a known option.
This means that the option sets -pt
and -t -p
are equivalent.
The first positional argument (the first argument withtout a leading dash) will be considered as the filename
argument.
The -t
option in app-naive-conway
and app-list-conway
makes the simulator consider the universe as a torus, meaning that the alive neighbor count for an edging cell will include alive cells on the opposite edge of the universe.
In the following examples, if the universe is considered as a torus, the cells at (0,0), marked x
, have one neighbor:
The -e
options in app-list-conway
makes the simulator consider the universe as expandable.
This option is incompatible with the aforementionned option to consider the universe as a torus.
Whilst the project guidelines call for creating output images for simulation steps using the PPM standard (magic number P3
), I decided to use the PBM standard (magic number P1
), featuring only black and white pixels.
A PGM image source code is as follows, with an example alongside (image of the letter J):
Since we only intend to print black and white pixels, the PBM standard is the minimum necessary and the produced images will be of smaller size.