Lab 11: Week of Oct 24-28
 


0. Explore how to generate random numbers in Java. This is required for the lab problems.

1. You've probably heard that in a group of about two dozen people there is a high chance that at least two of the people have the same birthday. Write a method trial() that selects 23 random integers between 1 and 365 (both inclusive). The method should return true iff a pair of selected integers are the same. Then, write a program that performs 10000 calls to trial() and prints the percentage of trials that are true.

Look at http://www.people.virginia.edu/~rjh9u/birthday.html or
search on google for "two people with the same birthday"

2. Game of Life (population simulation program): The simulation follows the progress of a colony of individuals that reside within a square array. An individual may continue to live or die based on its neighbours. Each cell has 8 neighbours (except the ones on the boundaries and corners). Following three rules govern life and death in the array:

A. Birth: An empty cell surrounded by (exactly) three neighbours produces a new individual.
B. Life: Any individual surrounded by 2 or 3 neighbours lives on.
C. Death: Any individual surrounded by fewer than 2 or greater than 3 neighbours dies from loneliness or overcrowding respectively.

Create a colony of 50 by 50 cells. Randomly fill it with individuals (some cells may be filled and some may be empty). Show the population distribution for first 100 cycles. However, if the population stabilizes earlier then stop further simulation. Try it with some of the patterns given in the links.

Look at http://www.math.com/students/wonders/life/life.html or
search on google for "game of life" for more insight in the game.