Week 3, Problem 1: Evolving Lists and Lights On!
[35 points; individual or pair]

 

Submission: This lab has four parts. Because each builds on the last, please create only one file, named hw3pr1.py and add to it throughout the lab. Please submit your hw3pr1.py file to Canvas.

The bird's-eye view

The end goal of this lab is to build a game called "Lights On" (alternatively, "Lights Out", but that seemed so gloomy to us). "Lights On" is played with a grid of lights which are either on or off.

The goal in Lights On is to turn all of the lights in the initial grid on. Each time the user selects a light, that light toggles from 0 to 1 or from 1 to 0. The challenge is that the neighboring light(s) ALSO toggle. That is, the one, two, three or four lights directly to the N, S, E and W of the selected light also change state (either on to off, or off to on). The lights do not "wrap-around": e.g., the leftmost light is not a neighbor to the rightmost light.

You can play a version of Lights Out here: http://www.logicgamesonline.com/lightsout/

This lab will guide you in developing several Python functions that will allow you to implement this game. In doing so, we will introduce and reinforce the concepts of

Lab 3, Part 0: Set up

Lab 3, Part 1: Counting generations

Lab 3, Part 2: Graphics and user input

Lab 3, Part 3: The game of "Lights On"

 


 

Submission

You should submit your hw3pr1.py file at Canvas .

Next

hw3pr2

Lab 3

Homework 3