# CMPT 102 Assignment #5

This assignment is worth twice as much as the other assignments. Accordingly, you will probably have to spend more time on it.

In addition to solving one of the problems outlined below, there will be marks available for the quality of your solution. This will include style and efficiency.

## The Choices

You have two choices of problems for this assignment. The two problems have roughly equal difficulty, so your choice of problems should be based on subject of interest, not which one is easier.

The real details of the assignment are in the Acrobat or Postscript files linked below.

### Simulating Billiards

The first option is to simulate the movement of balls on a pool table. The problem has been simplified somewhat to make it easier to work with.

Details of this option: [ Pool PDF | Pool PS ]
Sample output animation: [ Pool GIF (250K) ]

### Simulating Populations

The second option is to use a common mathematical model of population change to simulate populations of two species in an area. The species are a predator and prey, so their populations depend on each other.

Details of this option: [ Pop. PDF | Pop. PS ]
Sample output animation: [ Pop. GIF (110K) ]

## Warm-up

For this assignment, you will have to use both structures and arrays. If you're not comfortable with these yet, you might want to try some smaller problems first, before you dive into assignment 5.

You can try the warmup problems. These are worth no marks and you shouldn't hand them in. But, if you're struggling with arrays or structures, the first piece of advice you will get from the instructor or TAs will be "do the warmup problems".

## This is hard. Will I finish?

Yes, it is and maybe not. If you don't finish this assignment, that's okay. Not everybody will.

First, here are some tips to help you actually get this program working:

• Write in small pieces. This can't be stressed enough. If you try to write this program by hand and then type it in, you'll never get it to work. There are too many places for errors to hide and there won't be anything that the TA or instructor can do short of rewriting your program for you.
• Start with a plan. Write pseudocode first and use it as a guide for your program. Even if you don't write down detailed pseudocode, at least make a list of the things you have to do.
• Read the problem statements carefully. There is a lot of information in there that can help, particularly in the "Hints" section.

If you don't think you can finish, you can still get most of the marks without a complete solution. Here are some things in particular that will get you a lot of marks:

• Make your data structures to hold the simulation data.
• Show that you know how to work with these--even initializing them shows something here.
• Get some small part of the simulation working.
• Get enough working to draw an image.
• Put in some comments to indicate what you would add and where to finish.

If you want, you can also include a file called `about.txt` in your submission that contains a paragraph or two explaining what you have done and what you haven't. Remember, the more you can convince us you understand what's going on, the more marks you'll get. In fact, it's entirely possible that a unfinished program will get more marks than a finished one, if the person demonstrates that they understood what was going on, but just couldn't finish.

## Optional stuff

There are some optional extensions to the image drawing functions that you can use.