Problem Set 2 - Due Tue, Sept 17 at 23:59

Reading

  1. Goldwasser & Letscher, Chapter 3, sections 3.3-3.6, pages 103-110.
  2. Slides and notebooks from Lec 3.
  3. Problems and solutions from Lab 2.

About this Problem Set

Need a partner? Do NOT use the Google Group!

Read the instructions above on how to find a partner.

Other notes:


Task 0: Scrambled Solutions

This is an individual problem which you must complete on your own, although you can ask for help from the CS111 staff.

To help you study for the problem set 1 quiz, we have prepared some simple puzzles based on the solutions to problem set 1. You should complete them online, but also download your solutions and submit them with the rest of the problem set.

The puzzles for the problem set 1 solutions, which you must complete as part of problem set 2, can be found on the puzzles page here:

CS 111 Puzzles

Make sure you click the link at the top to log in to that page so that you can access the puzzles.

Give the page a few seconds to load, and then select "Problem Set 1" from the drop-down menu. There should be two options in the sub-menu: timeProfiler.py and graphicsScene.py. You should complete both of those puzzles, and once you have a solution (use the 'Check Solution' button and rearrange the code in the right-hand column until the puzzle turns blue), use the 'Download Solution' button to download your solutions. The solutions should download as files called ps01-time_profiler-solution.json and ps01-graphics_scene-solution.json; submit these files along with the rest of your problem set.

Because this is our first time using this puzzle interface, please be on the lookout for any bugs or strange behavior, and email Peter (pmawhort@wellesley.edu) directly if you spot anything.

Task 1: Debugging Graphics

This is an individual problem which you must complete on your own, though you may ask for help from the CS111 staff.

Using layers and transformations in cs1graphics, we want to create the following picture, which contains 4 transformed versions of a face:


Relative to the upper left face:

We have supplied you with a program that attempts to create the above picture. Click here to see the program, a copy of which can be found in the ps02 folder as debugGraphicsBuggy.py. Although it is structured well and in many ways is close to correct, the program generates the following incorrect picture due to numerous bugs:


Your goal in this subtask is to fix this program so that it generates the correct picture. In the ps02 folder is a file debugGraphicsFixed.py that is initially a copy of the buggy debugGraphicsBuggy.py program with some extra header information at the top that you should fill out and an extra triple-quoted comment section at the bottom (more on this below). You should modify debugGraphicsFixed.py by finding and fixing all the bugs it contains, so that it ultimately generates the correct picture.

Notes:


Task 2: Bunny Money Pattern

This task is required and you have the option to work with a partner on it if you wish. We strongly encourage you to work in pairs on this problem. Use this shared Google Doc to find a pair programming partner and record pair programming partnership.

Need a partner? Do NOT use the Google Group!

Read the instructions above on how to find a partner.

Your goal in this task is to generate the following picture by fleshing out the file bunnyMoneyMosaic.py in the ps02 folder:


There is a lot of stuff going on in this picture. You can see that one pattern is repeated, at different sizes and rotations. Let's call this pattern bunnyMoney, as shown below (enlarged):

The bunnyMoneyMosaic.py file begins by importing the following shapes to get you started; the rest you will create using cs1graphics.

Two graphics objects that are provided for you:

Description Graphic
bunny
This is a layer that is returned by calling the
makeBunny function imported from bunny.py.
Its reference point is marked by an orange circle.
wedge
This is an orange polygon that is returned by calling the
makeWedge function imported from from wedge.py
Its reference point is in its upper left corner.

In general, we recommend that you start with pencil and paper (as opposed to jumping into Canopy). You want to build your code incrementally, making sure that smaller parts work before attempting the entire picture.

Useful bunnyMoney information:

  1. The large green (lightgreen) rectangle has a width of 600 and height of 300
  2. The blue (navy) circle in the center of the bunnyMoney has a radius of 75
  3. Each of the small wedges + bunny on the navy circle are one-quarter the size of the original wedge + bunny
  4. The grey (darkgrey) rectangle has a width of 330 and height of 70
  5. The top-left bunny's head is located at (75, 120).
  6. This set of slides give a high-level overview of how to make bunny money.
  7. Here is bunnyMoney shown with a gridlines spaced 50 apart and also with gridlines spaced 25 apart (use the grids to figure out where to place things):

Bunny Money Mosaic information that will be useful for you:

  1. The pink canvas has dimensions 900x600
  2. The 900x600 bunny money mosaic with grid is shown here:
  3. Note that the ears of the bunny are always outlined in white; sometimes the bunny is scaled smaller and the ears may appear to be non-white, but rest assured they retain their original color.

Notes



Task 3: Fancy Bunny Money [THIS IS AN OPTIONAL TASK]

If you had fun making bunny money and have time to spare, then you can complete this OPTIONAL task. In this OPTIONAL task, the goal is to create this picture in the file fancyBunnyMoneyMosaic.py:

The image is very similar to the one in Task 2 above, but has a line of bunnies in the grey rectangle.

Useful fancy bunny money tips:

  1. Here is an enlarged view of fancy bunny money with a grid (each grid line is 50 units apart):
  2. The smaller bunnies are 30% the size of the original bunny; the larger bunnies are 42% the original size.
  3. Here is an enlarged closeup of the line of bunnies with a grid (each grid line is 10 units apart):
    .
    This gives information about where to place each bunny.

Task 4: Honor Code Form

The ps02 folder contains a file honorcode.py with several variable assignments for your name, the time you spent on the tasks, etc. Change the values in these variable assignments to appropriate values.

How to turn in this Problem Set