CSCI 1120 (Low-Level Computing), Spring 2020:
Homework 8

Credit:
20 points.

Reading

Be sure you have read, or at least skimmed, the assigned readings for classes through 10/30.

Programming Problems

Do the following programming problems. You will end up with at least one code file per problem. Submit your program source (and any other needed files) by sending mail to my TMail address with each file as an attachment. Please use a subject line that mentions the course and the assignment (e.g., “csci 1120 hw 8” or “LL hw 8”). You can develop your programs on any system that provides the needed functionality, but I will test them on one of the department's Linux machines, so you should probably make sure they work in that environment before turning them in.

  1. Your mission for this assignment is to first complete and then modify a starter program that plays mathematician John Conway's Game of Life, described below. (You can also find more information on the Web. The Wikipedia article seems good.)

    The Game of Life is not so much a game in the usual sense as a set of rules for something called a cellular automaton: There are no players, and once the initial configuration is established, everything that happens is determined by the game's rules. The game is “played” on a board consisting of a rectangular grid of cells. Some cells are “live” (contain a simulated organism); others are “dead” (empty). At each step, a new configuration is computed from the old configuration according to the following rules:

    To visualize how this works ... I found some Web sites that let you “play” online, but none I found immediately appealing. I have a version that uses text-based graphics that you should be able to use on our classroom/lab machines. Download file game, tell Linux it's an executable file with the command chmod u+x game, and run it with the command ./game. (If you're curious, the program is written in C++ using a library called ncurses to do text-based graphics.) (NOTE that this program has sometimes crashed when I try to demo it in class. I can't make this happen consistently and am at a loss to know what might be wrong. If it doesn't work for you please let me know where and when you tried it. NOTE ALSO that since it's an executable file it won't work on non-Linux systems, and I don't guarantee that it even works on all Linux systems.)

    To implement the basic algorithm in a program, you pretty much need to use 2D arrays. Writing a complete program is straightforward but more than I want to ask you to do; instead I am providing starter code that does everything but the actual update of the grid. To give you some practice with make and to reduce code duplication, I've split the code into multiple files and included a Makefile. (NOTE: If you really want to do this homework on a system that doesn't support make, talk to me about options.) The files:

    To make it easier to download all these files, I've made a ZIP file containing all of these files, so it will probably be simplest just to download that and unzip it (command unzip on our machines).

    NOTE that if you prefer to download individual files, you should use your browser's “download” or “save” function to obtain the makefile rather than copying and pasting text. This is because copy-and-paste will likely replace the tab characters in the file with spaces, with bad consequences (since tabs are semantically significant in makefiles.)

    NOTE that downloading files if you're using department computers remotely in text mode is problematical. You can do this from the commmand line if you have the full URL, however, using command wget. For example, to get the ZIP file:

    wget http://www.cs.trinity.edu/~bmassing/Classes/CS1120_2020spring/Homeworks/HW08/Problems/hw8.zip

    NOTE also that you might want to put the files for this homework in a separate directory, so its makefile doesn't conflict with the one you use for compiling other programs.

    You might want to start by just downloading everything and trying compiling the two programs. They won't do anything useful yet, but this will let you check that you know how to build them when you do start writing code.

    For this assignment you will develop two programs:

Pledge

Include the Honor Code pledge or just the word “pledged”, plus at least one of the following about collaboration and help (as many as apply).2Text in italics is explanatory or something for you to fill in. For programming assignments, this should go in the body of the e-mail or in a plain-text file pledge.txt (no word-processor files please).

Essay

Include a brief essay (a sentence or two is fine, though you can write as much as you like) telling me what if anything you think you learned from the assignment, and what if anything you found found interesting, difficult, or otherwise noteworthy. For programming assignments, it should go in the body of the e-mail or in a plain-text file essay.txt (no word-processor files please).



Footnotes

...long)1
The long data type is a “long integer”. In C int only has to be big enough for 16-bit values; long has to be big enough for 32-bit values. If you're curious about support for 64-bit values, long long (C99 only) does that.
... apply).2
Credit where credit is due: I based the wording of this list on a posting to a SIGCSE mailing list. SIGCSE is the ACM's Special Interest Group on CS Education.



2020-10-30