IN101 project on Conway's Game of Life
Additional Features Documentation

Options parser

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:

-i: generate image output for each step
-p: print simulation steps to the console
-t: consider the universe as a torus
-?: print source textfile formatting help

For app-list-conway is also available:

-e: consider the universe as expandable (incompatible with a torus universe!)

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.

Possibility to consider the universe as a torus

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:

3 3 3 3 3 3 3 3
1 1 1 1
x.. x.. x.o x..
... ..o ... ...
..o ... ... o..

Possibility to consider the universe as expandable

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.

Usage of the PBM ASCII image standard

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):

P1 P1
width height 7 5
pixels 0000010
0000010
0000010
0100010
0011100

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.