CMSC 201

# Homework 7 - Due 4/08

This homework must be submitted by 8pm on the due date to get any credit.

## Conway's Game of Life

This week we will be coding a simple cellular automata game, called Conway's Game of Life. In this game, you have a grid where pixels can either be on or off, and simple rules that govern whether those pixels will be on or off (dead or alive) at the next timestep. The rules are as follows:

1. Any live cell with fewer than two live neighbours dies
2. Any live cell with two or three live neighbours lives on to the next generation.
3. Any live cell with more than three live neighbours dies.
4. Any dead cell with exactly three live neighbours becomes a live cell.

You will ask the user for the size of the game board, and any cells they'd like on to begin with. Then ask the user how many iterations they'd like to run, and display each one of those.

```Please enter number of rows: 5
Please enter number of columns: 5

Please enter enter the row of a cell to turn on (or q to exit): 3
Please enter a column for that cell: 3

Please enter enter the row of a cell to turn on (or q to exit): 2
Please enter a column for that cell: 3

Please enter enter the row of a cell to turn on (or q to exit): 4
Please enter a column for that cell: 3

Please enter enter the row of a cell to turn on (or q to exit): q

How many iterations should I run? 3

Starting Board:

00000
00000
000X0
000X0
000X0

Iteration 1:

00000
00000
00000
00XXX
00000

Iteration 2:

00000
00000
000X0
000X0
000X0

Iteration 3:

00000
00000
00000
00XXX
00000
```

I would recommend you store your board in a 2D list, and have a function called nextIteration(board) that returns a new board with the next iteration, and a function called printBoard(board) that prints out the board.

If you want to make sure you've done everything correctly, the wikipedia page shows some other examples of the game.

When you've finished your homework, use the submit command to submit the file. You must be logged into your account and you must be in the same directory as the file you're trying to submit. At the Linux prompt, type

submit cs201 HW7 hw7.py

After entering the submit command shown above, you should get a confirmation that submit worked correctly:

Submitting hw7.py...OK

If not, check your spelling and that you have included each of the required parts and try again.

You can check your submission by entering:

submitls cs201 HW7

You should see the name of the file that you just submitted, in this case hw6.py

 Adapted from UMBC CSHC's webpage design