

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


In this assignment you will write several functions that will be used to play a āgameā called Life that was invented by the mathematician John Horton Conway in 1970.^1 In reality, Life is not a game at all, but an entertaining example of cellular automata; that is, a collection of simple rules that determine how a binary pattern defined on a regular grid evolves with time. There are no winners, losers, payoffs, or even strategies in this game; but it is very captivating to sit back and watch what happens.
Conceptually, Life is played on an infinite regular grid (checkerboard), each square, called a cell, is either alive or dead. The collection of all ālivingā cells is called a colony. The colony of living cells changes in discrete time steps called generations, each generation being completely determined by the previous generation. The cells obey four simple rules, which determine the fate of the colony in the next generation. Each rule is based solely on the number of living neighbors that a cell has among the eight adjacent cells (including diagonally adjacent cells), and whether the cell is currently alive or dead. Here are the rules:
All four rules are applied simultaneously, and (conceptually) to each cell of the entire infinite grid to determine the colony of the next generation. See Figure for an example of four successive generations of a simple colony.
You might wonder where these rules came from. The answer is experimentation. Computer scientists had been exploring the behavior of rules such as these for a long time, with an eye toward exploiting massive computational parallelism. Conway discovered that the rules above had a very appealing balance: cells were born and died off in such a way that the resulting colonies exhibited very complex and unpredictable behavior. While these rules may not be the most intrinsically valuable in terms of computation, they are nonetheless the best known, for their entertainment value.
Figure 1: A simple illustration of the rules of Life. Reading left-to-right, the four configurations represent four successive generations. You should be able to try this pattern on paper, applying the rules yourself. Notice that one cell dies and one is born in the in moving from the first to the second generation. In the fourth generation a stable pattern called a āhiveā is reached. There will be no further births or deaths.
(^1) This is a two-part assignment; in part two you will complete the progtram that plays the game of Life.
Figure 2: Shown here is the simplest repeating pattern, called a āblinker.ā This configuration con- stantly changes, but repeats with a period of two generations (as shown).
Figure 3: Here are three patterns that you should try out once you think your complete program is working in the next assignment. From left to right these are called (or turn into) a āpulsar,ā a āglider,ā and an ār-pentomino.ā The configuration on the left ultimately leads to a pulsar, a pattern that looks like a blinking star as it cycles through three different shapes. The glider is the simplest shape that moves. The r-pentomino grows into a massively complex colony, shooting off several gliders in the process. The configuration in Figure is only one cell away from being an r-pentomino (aside from rotation).
This is a two-part assignment; you will only implement three of the necessary components of a working Life program in this assignment, and you will complete the program in the following as- signment. You are to create and submit a Python module named āhw6.pyā containing definitions for the following functions (with precisely these spellings, including case):
Be sure to submit only working Python code and comments. If your Python module cannot be loaded as-is, points will be deducted. Also, be sure to text these functions thorougly so that you are confident that they behave as they should. (Test functions will be supplied for you.) Here is what the functions should do:
[( 9 , ā 6 ), ( 9 , ā 5 ), ( 9 , ā 4 ), ( 10 , ā 6 ), ( 10 , ā 4 ), ( 11 , ā 6 ), ( 11 , ā 5 ), ( 11 , ā 4 )],
although the ordering is unimportant. Notice that the coordinate passed in to the function is not in the list; just the coordinates of the surrounding cells.