"Life" is the name of a simulation exercise invented by a mathematician John Conway. The simulation represents the evolution of a population of creatures that exist in a rectangular grid. Each creature occupies one cell of the grid while it is alive. Creatures are born or die in cells based on conditions in neighboring cells. More precisely, there are “evolution parameters” BMIN, BMAX, SMIN and SMAX that govern the evolution of creatures according to the following evolution laws:

  • Birth law. If a cell is empty, a new creature will be born into that cell in the next generation if the number of occupied neighboring cells is greater than or equal to BMIN and less than or equal to BMAX.
  • Survival law. If a cell is occupied, the creature in that cell will survive to the next generation if the number of occupied neighboring cells is greater than or equal to SMIN and less than or equal to SMAX. (In Conway's terms, a creature dies of loneliness if the number of neighbors is less than SMIN and dies of overcrowding if the number of neighbors is greater than SMAX.)

The game as originally defined by Conway set BMIN = BMAX = 3, SMIN = 2 and SMAX = 3.

You are to write a program that implements these rules and displays successive generations in the client area of a form. The user should be allowed to set the parameters BMIN, BMAX, SMIN and SMAX. Every cell has 8 neighbors, including cells on the border of the client area. The neighboring cells of an interior cell are all the cells that are adjacent to the interior cell horizontally, vertically and diagonally. (Diagonally adjacent means the corners are adjacent). For border cells, consider the right border to be adjacent to the left border and the top border to be adjacent to the bottom border. That is, the client area represents the surface of a toroid. Creatures in all cells evolve according to the above rules.

GUI Specifications

The application should have a single form with a menu strip at the top of the form. The entire client area below the menu strip is the simulation grid. Represent each creature as a filled rectangle inside the boundaries of its cell.

Menu Commands

Menu commands should provide the user with the ability to do the following:

  • Specify the dimensions of the simulation grid (i.e., number of cells per row and cells per column). Allow grid sizes up to 1000 by 1000.
  • Specify the values of the constants BMIN, BMAX, SMIN and SMAX. When the application starts, these should be set to Conway’s original values.
  • Set the initial state of all cells randomly. That is, determine randomly whether each cell is occupied or not.
  • Clear the grid (i.e., remove all creatures). This will allow the user to set cells individually using the mouse or keyboard (see below).
  • Single-step the evolution (i.e., compute and display the next generation).
  • Start the evolution process (i.e., compute and display successive generations at the specified evolution rate).
  • Stop the evolution and display the current evolution state.
  • Specify/modify the evolution rate. Allow rates between 1 and 100 generations per second.
  • Specify the background color, creature color, and grid color.
  • Specify whether the grid is on or off. (The “grid” consists of 1-pixel wide horizontal and vertical lines that define the cells.)
  • Display user instructions.

Additional Features

In addition to the functionality provided by the menu, the application should:

  • Allow the user to resize the form. The simulation grid of the resized form should exactly fit the client area below the menu. Resizing the form should not change the number of cells (i.e., cells per row and cells per column). It should change the size of the cells, so that the grid exactly fits in the new client area and all cells are the same size. Resizing the form should not change the state of the simulation.
  • Allow the user to specify/modify the state of any cell of the grid using the mouse or keyboard.
  • Allow the user to use the keyboard to start, stop and single-step the evolution and change the evolution rate (either via menu command keyboard shortcuts or direct response to keyboard events).
  • The program should respond gracefully to errors (e.g., inappropriate values for grid dimensions; mouse errors). Do not allow the Runtime to handle any error.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.