ICS H21 • UC IRVINE • DAVID G. KAY • FALL 2009
Lab Assignment 3
This assignment is due at the end of lab on Friday, October 16.
Choose a partner for this assignment, someone you haven't worked with already.
(a) Do exercises 9.1.3, 9.3.2 (Hint: What kind of operators work on two boolean values?), and 9.3.3. Then do exercises 9.5.3, 9.5.4, 9.5.6, and 9.5.7. As you do them, follow the design recipe in Figure 26.
Do exercises 10.1.2, 10.1.4, 10.1.5, and 10.1.6. Then do exercises 10.2.2, 10.2.7, and 10.2.9 (you don't have to write name-robot, but it might help you get to substitute).
Instead of doing exercises 10.3.1 through 10.3.6, create a new version of the world-drawing code you wrote last week based on section 7.4. This time, your world will contain a list of shapes (based on the definitions in exercise 7.4.1); each time you draw the world, you'll overlay all the shapes on the list. Each shape will contain a posn (a two-number structure) that indicates how far (in the x and y directions) to move on each tick; each time you create the next world, you'll translate each shape by the amounts specified. You'll want to be sure to choose names for all these functions that are different from the ones you used earlier, since they'll all be submitted as part of one big Scheme file.
Collect your definitions for all these exercises into one Scheme file, make sure both partners' names are in a comment at the top, and submit it via Checkmate.
(b) Set your language level to Beginning Student with List Abbreviations and include the image.ss teachpack (if you've included universe.ss, that's fine). Click Run.
Now, a color is a structure, (make-color red green blue), where red, green, and blue are numbers from 0 to 255. You can represent any color by some amount of red, green, and blue; try out some combinations and see. These colors can represent pixels in an image—that is, each of the dots that makes the image up.
(rectangle 3 4 "solid" "blue")).
You get a list of the 12 blue pixels that make up the 3x4 rectangle. Likewise,
(list (make-color 0 0 0) (make-color 0 0 0) (make-color 0 0 0)
(make-color 0 0 0) (make-color 0 0 0) (make-color 0 0 0))
3 2 0 0)
makes a 3x2 rectangle of black pixels. (The last two arguments have to do with aligning images; we'll leave them at zero for now.)
Remember that you can consult the documentation for the image.ss teachpack in the DrScheme Help Desk.
There's nothing to turn in for this part.
(c) You can insert images (any image from a JPEG or GIF file) into DrScheme using the Insert Image item on the Special menu. To give the image a name to use in your program, you could say (define my-pic X), where instead of the X you just insert the image.
Write the function remove-green that takes a color and returns a color with the same red and blue values but the green value replaced by zero.
Write the function remove-color that takes a color and a string ("red", "green", or "blue") and returns that pixel with the specified field set to zero.
Write the function remove-color-from-image that takes an image and a string ("red", "green", or "blue") and returns that image with all its pixels altered as in remove-color. Try this out on some pictures you find on the web.
Submit your definitions via Checkmate. If you have images in the file you submit, make sure they're small.
(d) Do exercises 11.2.1 and 11.2.4; then do exercise 11.3.1 and exercises 11.5.1 and 11.5.4.
(e) (extra credit) Do exercises 11.3.5 and 11.4.7.
(f) Remember that each partner must complete a partner evaluation form and submit it individually via Checkmate.
Based in part on ICS H21assignments by David G. Kay from Fall 2001; modified by David G. Kay, Fall 2004–Fall 2009. The image exercises were adapted from Matthias Felleisen's TeachScheme 2 Workshop.