CS 121: Programming Artificial Life Homework # 2. Detecting Object Collisions.


Due on Thursday, March 30th, right before class. You can either email me the appropriate files, or place them in the Hand-Ins folder on urza. If your homework is divided into more that one file, as it should, all files should have your name on them, either as a comment inside or as part of the file names. If you deliver them via urza, you can also put all of your files into a folder, and then place that folder into the hand-in folder on urza.

This homework deals with detecting agent collisions. This homework will serve as the basis for the next homework.

In this homework you will have two classes. You can call them any name you want, but it helps me to think of them as Plants and Animals. Plants are stationary, Animals are mobile.

Animals move randomly. When they collide with a plant, they store the location where the collision occurred into one of their attributes (a new attribute). The class also has a method to write into this attribute, and a method to read it.