Hints for Lights Out
These hints are based on questions that arose in class.
Model
Some students found it easier to think about a model where each circle
is represented by a tuple containing a Point
for the center of the
circle and also a Bool
which is true if the circle is solid.
type OneCirc = (Point, Bool)
How do you feel about a list of OneCirc
instead of a list of
Point
? Can you think of any advantages and disadvantages to this approach?
Draw Handler Exercises
The main challenge with the draw handler is that you need to develop a plan. Do not rush in to coding.
-
“By hand” draw a row of five outline circles. Adjust the spacing so they look good.
ex1 = pictures [ circle 3, translated (-5) 0 $ circle 3, coordinatePlane ] main = drawingOf ex1
-
Draw two circles, an outline one with point
(1,0)
and a solid one with point (0,0). Adjust until they look good. -
Write a drawing function that you can produce any version of solid or outline for the two circles in the previous exercise.
Logic Exercises
The simpleUpdate function takes in a “original Point” and a Maybe Point. In the situation that the “Maybe Point” is an “actual Point”, that is the answer. When the Maybe Point is Nothing, the original Point is the result. Write tests showing how this function is supposed to work before you write the function!
simpleUpdate :: Point -> Maybe Point -> Point