CS253: Software Development with C++

Fall 2020

HW 2

CS253 HW2: ¡Livin’ La Vida Conway!

Gosper Glider Gun

Changes

Updates to the assignment will be noted here. None yet!                 

Description

For this assignment, you will write a program that computes the next generation in Conway’s Game of Life.                 

Arguments

If no arguments are given, read the initial state from standard input. Otherwise, the first argument must be a filename—read the initial state from that file.                 

Input format

The input is a number of lines containing only period (.) and capital letter O (O) characters. For example:                 

..O..
.....
O..OO
...OO

There must be at least two lines, each at least two cells wide. Each line must have the same length.                 

Operation

Conway’s Game of Life is a cellular automaton. It a rectangular wraparound universe of cells. The rightmost cell in each row is considered to be adjacent to the leftmost cell in the same row. Similarly, the topmost cell is adjacent to the bottommost cell in a column.                 

    .........                 F......DE
    ...ABC...                 I......GH
    ...DEF...                 .........
    ...GHI...                 .........
    .........                 C......AB

The population for generation N +1 is computed entirely on the state of generation N. For example, when computing the next state for cells in row 5, make sure to use the cells for row 4 from the previous generation, and not the new cells computed for the next generation.                 

Sample Runs

Here are sample runs, where % is my prompt.

% cmake .
… cmake output appears here …
% make
… make output appears here …
% cat block3
....
.OO.
.O..
....
% ./hw2 <block3
....
.OO.
.OO.
....
% cat block
....
.OO.
.OO.
....
% ./hw2 block
....
.OO.
.OO.
....
% cat blinker
....
.O..
.O..
.O..
....
% cat blinker | ./hw2
....
....
OOO.
....
....
% ./hw2 <blinker | ./hw2
....
.O..
.O..
.O..
....
% cat jack
...O..............O..
...O...OO.O...OO..O.O
...O..O..O...O....OO.
O..O..O..O...O....OO.
.OO....OO.O...OO..O.O
% ./hw2 jack
O..O.............OO..
..OOO..OOO....O..OO..
..OOO.O..OO..O...O...
OO.O..O..OO..O...O...
OOOO...OOO....O..OO.O
% ./hw2 jack | ./hw2
O...............O...O
.O...O.OOOO.....O....
......O......OO.OO...
.....OO......OO.OO..O
...OO..OOOO.....O..OO
% ./hw2 jack | ./hw2 | ./hw2
O...O.O........OOO.OO
O.....OOOO......O....
........OO...OO......
....OOO.OO...OO...OOO
....OOOOOO......O..O.
% ./hw2 jack | ./hw2 | ./hw2 | ./hw2
O...O..........O.OOO.
O....OO..O....O.OO...
..........O..OOO...OO
....O.....O..OOO..OOO
O..O.....O....O.O....
% ./hw2 jack | ./hw2 | ./hw2 | ./hw2 | ./hw2
OO..OO........O...O..
O....O.......O...O...
O....O...OO......O...
O........OO.....O.O..
O..OO........O..O....

Debugging

If you encounter “STACK FRAME LINK OVERFLOW”, then try this:

    export STACK_FRAME_LINK_OVERRIDE=ffff-ad921d60486366258809553a3db49a4a

Requirements

If you have any questions about the requirements, ask. In the real world, your programming tasks will almost always be vague and incompletely specified. Same here.                 

Tar file

    cmake . && make

How to submit your work:

In Canvas, check in the file hw2.tar to the assignment “HW2”.                 

How to receive negative points:

Turn in someone else’s work.