Project 5 (Draft)

Due Thursday 7/26/2001
Last Modified
One of the frequent uses for a computer is to model a system and one of the earlest, called "life", grew out of 1970 artical in Scientific American. In most such simulations all changes are assumed to all take place simultaniously and they usualy model one kind of organisms in isolation. For this project you will create a version of this simulation in a grid of at least 10x10 and not to exceed 100x100 with 3 types or creatures where changes do not need to take place simultaniusly.

What you will need to do

    Each of the 3 creatures is described bellow.
The world these creatures live in is a torus so there is no edge.
Rather than being turned bases each creature will wait between 1 and 60 sec before trying to make another move. Between moves it may be killed off by antoher creature.
The code to sleep 1 to 60 seconds would be: 1+( 59000*(int)(Math.random()) )
Starting conditions, you may hardcode the starting conditions of your simulation. There should be between [15 - 25] creatures with each creature having at least 4 representatives.
    You will need to use 2 aspects of multi-threading,
  1. each active creature will need to have its own thread or each square will need its own thread.
  2. You will need to impliment mutual exclusion so that only one thread may update the array that represents the world at a time.

The display for this is a grid layout of colour squares (1 for each in the world) that can be one of 4 colours (1 for each animal) and brown for the background.

What to submit

The code.