Java
PROJECT – GAME OF LIFE

separator-blank.png

 

PROJECT DESCRIPTION

You will create your own version of the famous computer science program known as Conway’s Game of Life.  It is a simulation that is executed on a two dimensional grid that contains several elements that interact with each other following simple rules.  While the famous simulation deals with cellular level interactions, we will work with a different environment.

SPECIFICATIONS

Your simulation must include at least 4 different creatures or interactive elements.  Possible elements could include:

·       Grass

·       Forest

·       Sheep

·       Rabbit

·       Wolf

·       Fire

·       Water (Lake)

·       Water (Rain)

Your simulation must include at least 10 different simple rules that explain the interactivity between creatures.  The rules cover simple ideas such as surviving/dying, moving and expanding/having children.  Below are some examples but you are encouraged to create your own rules with whichever elements you want to use.

·       Grass (and Forest) expands to neighbouring tiles 5% of the time.

·       Sheep can live 10 days without being on grass.

·       Sheep that are not on grass move to a random neighbouring tile hoping to find grass.

·       If a sheep is on grass, it stays there for the turn and feeds.  When feeding, there is a 20% chance that all the grass will get consumed.

·       If a sheep lives 20 turns, it has a baby.  The baby sheep appears in a neighbouring tile.

·       Grass tiles that exist for 50 turns without being visited by a sheep become a forest.

·       A forest has a 1% chance of catching Fire.

·       Fires last for 3 turns.  The tile then becomes dirt.

·       A Fire spreads to neighbouring Forest tiles 20% of the time.  It spreads to neighbouring grass tiles 10% of the time.

·       And so on…

ALTERNATIVE THEME

Instead of working with an ecological theme, some students choose to use entirely different elements.  Here are a few themes that some students have created over the years:

Pandemic
Elements: Baby, Youth, Adult, Sick, Cured, Vaccinated, Masked, …

War
Elements: Village, Villager, Soldier, Captain, …

Focus on Animals
Elements: Lion, Tiger, Zebra, Giraffe, Elephant, Hippo, Crocodile, along with water, grass, …

ADDITIONS

Here are a few additions that some students have included:

·       SIMILAR COLOURS: Instead of making a tile type a specific colour, make it randomly choose between a few similar colours.  Instead of all grass tiles being one colour, make grass be a random green. 

·       SEASONS:  Add seasons to your simulation.  The first 100 ticks could be summer, the next 100 could be fall.  The next 100, winter and then 100 for spring.  And so on…  Rules can impact elements differently in different seasons.

·       RIVER GENERATION:  Start the simulation off with a randomly generated river that flows across the screen.  You can have a lot of fun with this alone.

·       WEATHER LAYER: You can have weather elements such as rain and snow that could be stored as a second grid above the main grid and draw overtop.  Another option is to include a weather status inside each tile.

·       CAPS: You can cap the number of a certain element.  This gives you more control over what is happening in the simulation.

·       MIGRATION: You can have animals be more likely to move to the south during some seasons and then to the north during other seasons.

·       ICE AGE: You can add an ice age effect that occurs every so often.  It could start at the top and work its way south (or vice versa).

·       TEMPERATURE:  You can give each tile a random temperature.  This temperature could change over time and could be impacted by its neighbours.  You can make the average random temperature be higher in the center and lower in the poles.  Then, you can make the temperature impact things like plant growth and water evaporation.

PRESENTATION EXPECTATIONS

You will create a 2-3 minute video of you simulation going over your rules and discussing what happens in your simulation.

AREAS OF EVALUATION

Rule count – You have at least 10 rules (level 4).  You need more to get full marks.

Rule complexity – Several of your rules involve movement or checking neighbouring tiles.

Overall look – The simulation is neat.  You have also expanded the interface to include information about the simulation.  This can include a legend of all the tile colours.  You can also include a count of all tiles.  You decide what to put here.

Presentation video – You will get a mark for the quality of your presentation video.  You speak clearly.  You speak at a good pace.  You have a well-organized presentation.  You demonstrate

DESIGN

Here are classes that might want to consider creating:

·       Tile class – Keeps track of what is on a single cell in the grid.  It can be a fairly simple class holding a String value for the type of tile it is (such as “grass”).  Or you can add some other data storing options to keep track of things like animals, weather, age, …

·       Grid class – Contains the 2D array of Tile objects.  It contains a draw and update method for the simulation.  It also contains a constructor to that will set the starting stage for the simulation.

·       Sim class – This class contains the main function.  You create the Grid class and then loop over the updating and drawing of the grid.

There are many different ways to create the Tile class.  On option is to have a colour for the ground and another colour for a possible animal that is over it.  You can even create draw method in the tile if you want to.

************************************

Below is an older start up option.  It doesn’t make use of the Tile class though and I now think that the Tile class approach offers many important benefits.  So I discourage the use of the solution below though it does give good hints at how to start.

************************************

PRELIMINARY PROBLEMS (OPTIONAL)

Below are some problems that will gradually guide you towards the application that you want to create.  Mr. Campeau will discuss solutions in class and share some parts.  There are also solution hints at the bottom.

PROBLEM #1A
Create a ColorGrid class that will contain a 2D array that will hold the information for the colours.  While you could get away with using an integer array, it is probably best to use an array that stores Color objects.

You also need to include a drawGrid method that uses NOOPDraw to display the array on the screen as such:

PROBLEM #1B
In the Tester class that creates and draws the ColorGrid, use a loop and continuously change the array (regenerate new random colours) and redisplay the array.  Include a pause so that the changes don’t occur too fast.

SOLUTION #1 HINTS

 

Click here for the file.