For your assignment you must build on two existing C programs as described below.

Super Text Printer

In your prior assignment, you developed a program to print text and allow control over line sequencing and timing. In this assignment, you start with a template program (below) with that functionality, and enhance it. It should be improved to allow variables to be defined and used, to support files and data streams of unlimited size, and to allow for file inclusion. Note you should note start with your own particular solution from the last assignment as the starting template.

Build on the solution provided below to create a program superprinter that reads the characters in a file (specified as an argument to the program) and prints the text to stdout. When it encounters a line whose first character is a period, it reads to following characters as a special command.

If the command is:

.quit                            -- the program exits,
.sleep N (where N is an integer) -- the program pauses for N seconds,
.rewind                          -- the program starts reading from the
                                    beginning of the file again
.rewind N                        -- rewind N lines forward from the 
                                    beginning,
.skip N                          -- skip the next N lines in the file
.set A = expr                    -- set a variable A to an expression
.include path                    -- include another file in the output
                                   (do not read commands in this file though)
.system A = s                    -- A takes the result of the UNIX command s
                                   (e.g. .system A date)
In each of the commands above (sleep, rewind, skip) a variable can be used in place of a numerical parameter.

Expressions take the form value1 operator value2 where the operator can be one of:

 +          -- addition
 -          -- subtraction
 *
 /
 |          -- string concatenation (e.g.  hell | o  -> hello)
 R          -- repetition (e.g. hi R 3  -> hihihi )

If the string $$name occurs anywhere in the text, the value of the variable called name should be interpolated. If no such variable exists, then the string should be unchanged.

Variables can take on string values, but if used in an arithmetic expression then they numeric equivalent should be used (i.e. the value 32 for the variable "32"). If a variable has a non-numeric interpretation, then the numeric value is zero (i.e. hello + 3 has the result 3).
Click here for a solution to the iprinter program from the last assignment that must be used as your starting point for this problem.

NOTE: There was a bug in the program which made it stop reading when it encountered empty lines in the input file. That problem has been fixed.

Part 2, superlife

The "game of life" is a standard example of a cellular automation. This was briefly discussed in class and in the . In this assignment you will start with a fully operational life program. You need to modify and improve it in serval ways. These are as follows:

Output of the multi-family variation should look like this file (which is the save file that resulted after 100 generations).

Start with the coding of the ability to use a world of arbitrary size (do this using dynamically allocated memory). The sample code for you to start with is as3lstart.c You can compile it using the command

   gcc -o as3lstart as3lstart.c -O2 -Wall -s -lcurses

Submit: 1) your source code (see course page), 2) testing, 3) timing data on how long it takes to run 10,000 generations on a 80x80 world with one family, with and without screen output (quiet mode), Give the time per generation. Evaluation criteria: performance, elegance, completeness, robustness, efficiency.


See the course home page hot links section for information related to this code assignment and/or sample. Be sure to read the policy of collaboration, independence and plagarism on the class home page.