cs249 lecture notes, Fall 2001 Week 12, Monday Incremental development ----------------------- Develop updateIter gradually. We are given a matrix A and we want to compute the neighbor matrix B. Some steps: write a function that 1) prints A (and/or the size of A) 2) creates B and prints it 3) creates B and then loops through the elements, printing them 4) copies the values of A into B 5) fills in B with 0 or 1, depending on whether the corresponding cell in A has a neighbor to the east 6) fills in B with 0, 1, or 2, the total number of neighbors in the east and west directions At this point we might start thinking about a subfunction. 6a) Write a function that takes a matrix and two indices and that returns the indicated element if the indices are in bounds, and zero otherwise 6b) test the function in isolation 6c) plug the new function into set (6) 6d) gradually add in the other six neighbors 7) prints the new and completed B 8) allocates C (all zeros) and prints it 9) fills in C with the dead cell rule (empty cell with three neighbors) 10) fills in with the live cell rule (live cell with 2-3 neighbors) 11) combines 9 and 10 and prints the result 12) returns the result (without printing anything) Life on a donut --------------- In some versions of Life, the world is a torus! The matrix version ------------------- Write a development plan for the matrix version of update...