EE221 Assignment 3

Program 1 Alternative 1 (30pts.)

Complete the provided partially developed program that calculates the steady state temperature distribution for the printed circuit board (PCB) with up to ten heat sources. The calculations are performed based on the following assumptions and simplifications:

Run your program for a grid of 20x20, 2 heat sources: (5,5,10) and (10,15,5), ambient temperature of 70F, and MSE error of 1E-6. After the program completes (approximately 350 iterations) import file tempplate.csv into Excel spreadsheet and print the result table using surface plot. Change the z-axis from autorange to the range of values observed in the output numbers. Attach that to the program source code and output printout. The surface plot should look like this.

The idea of the program is loosely based on the problem 10 from Chapter 3, page 140 and on past course assignments. However, solving the original textbook problem instead of this one will not receive any credit. Please refer to the instructor's comments that were (will be) made during lectures if the rough description included on this page combined with comments provided in the source code and the textbook problem description are not detailed enough.

Program 1 Alternative 2 (30pts.)

Complete the provided outline of the Game of Life simulation program. The program has been written except that contents of most functions has been removed and left for you to do as an exercise. The functionality of functions is briefly described in the form of comments. The functionality of the whole program is also somewhat commented.

From wikipedia: The original universe of the Game of Life is an infinite two- dimensional orthogonal grid of square cells, each of which is in one of two possible states, live or dead. Every cell interacts with its eight neighbours, which are the cells that are directly horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
  1. Any live cell with fewer than two live neighbours dies, as if by loneliness
  2. Any live cell with more than three live neighbours dies, as if by overcrowding
  3. Any live cell with two or three live neighbours lives, unchanged, to the next generation
  4. Any dead cell with exactly three live neighbours comes to life
The initial pattern constitutes the 'seed' of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed—births and deaths happen simultaneously, and the discrete moment at which this happens is sometimes called a tick. (In other words, each generation is a pure function of the one before.) The rules continue to be applied repeatedly to create further generations.

Your job is to analyze the provided program in order to find out how it implements the algorithm described above. Complete the missing implementation for functions. Also note the commented swapping of array pointer that is actually a preferred alternative to copying contents of the arrays.

Run your program a few times and capture a few most recent screens prior to program termination for a run that produced some interesting results such as persistent constant or oscillating patterns. This program will stop automatically when it detects a constant or two phase oscilating pattern but will fail to notice three or more phase patterns. Use the world of 10 by 20 for your experiments.

This homework is based on the textbook problem Chapter 3, Problem 11, Page 140. You may also want to look at Conway's Game of Life and its GUI implementation.

Game of Life Extra Credit (10pts.)

Improve the game of life program so that it can detect also three- and four-phase patters as stop condition, and also make it more efficient by utilizing pointer swapping instead of array copying that is now commented for one- and two-phase patter detection. You may turn in the improved version instead of the original assignment but to expedite grading please write "includes extra credit" at the top of the program. Please note that it may be too difficult to fully test if your improvement works as there is very little chance that you would encounter higher phase patterns from random initial condition.

Boring Extra Credit 2 (10pts.)

Redo the array-based city zone population assignment from Homework 2 using pointer-based dynamic arrays created according to the user specified number of zones at the time of executing the program. Also create and use a function that prints the populations for current year instead of printing directly from the main program. You may also develop and use more functions if you have time to exercise. (Pass all necessary data to the function, no global variables allowed.) Remember to prevent memory leaks. Mostly only the modified portions of code will be graded but the program must be functional to qualify for the extra credit.

web site front local main page local list page print this page   general bookmarks software bookmarks go back close this page copyright info   visitor counter