Bryn Mawr College
Computer Science Department
CS 110: Introduction to Computing
Fall 2007
Course Materials
Associate Professor Douglas S. Blank
Information | Texts | Links | Important Dates | Grading | Schedule |
Instructor: Douglas S. Blank, 248 Park Hall, 526-6501
E-Mail: dblank (AT) cs (DOT) brynmawr (DOT) edu
WWW: http://cs.brynmawr.edu/~dblank
Lecture Hours: Tuesdays & Thursdays, 2:30 p.m. to 4:00.m.
Room: Park 338
Lab: TBA
Laboratories:
Lab Assistants: The following Lab assitants will be available during the week (names and schedules will be posted by the end of this week) for assistance on lab assignments.
Please see http://wiki.roboteducation.org/Introduction_to_Computer_Science_via_Robots for up-to-date TA hours.
These are the hours when the Lab will not be available:
|
All graded work will receive a percentage score (0 to 100). At the end of the semester, a final grade will be assigned that will be one of the following: 4.0, 3.7, 3.3, 3.0, 2.7, 2.3, 2.0, 1.7, 1.3, 1.0, or 0.0. This value will be calculated as a weighted average of all grades according to the following weights:
BONUS: Attend Wednesday's Talk on the "Philosophy of Computer Science" and write a brief summary at blog.roboteducation.org.
BONUS: Do #6 Chapter #4, Proprioception: Try writing a program to draw other shapes: the outline of a house, a stadium, or create art by inserting pens of different colors (you can write the program so that the robot stops and asks you for a new color, too).
So, this assignment will require you to do two things:
The first part is written like:
pic = takePicture() # initilize some variables here for pixel in getPixels(pic): if getColor(pixel) == 255: # bright red # do something because they match
Now, what would help you decide what to do? If you knew where the matching orange pixels were, that would help. You can find out where a pixel is with:
x = getX(pixel) y = getY(pixel)
But that is only one pixel. What you really want to know is where all of the matching orange pixels are. But that is too much information. You could take the average, and that would tell you the general direction of the Pyramid. To compute the average, you need to sum up all of the x's and the y's of the matching pixels, and then divide by the total matching pixels. Here is a little program that sums up the x's and y's for an entire picture::
# initialize the variables: x = 0 y = 0 for pixel in getPixels(pic): x = x + getX(pixel) y = y + getY(pixel)and then you could compute the average by dividing by the total count of matching pixels:
# initialize the variables: x = 0 y = 0 total = 0 for pixel in getPixels(pic): x = x + getX(pixel) y = y + getY(pixel) total = total + 1 print "Average x:", x / total print "Average y:", y / total
But that will just give you the average position of ALL of the pixels. You'll need to only add the x's and y's of the matching pixels, and only divide by the number that match.
Finally, you should use those values to decide to go left, right, or straight:
if x/total > getWidth(pic)/2: # on right half of screen else: # on left half of screen
But when do you go straight? Divide by two, get two halves, divide by three and ...
Hopefully this will give you some useful hints as to how to solve the "Find the Pyramid" puzzle.
Read Chapter 5, Python Programming.
Draw a representation of yourself in Python using Myro that includes your name. I'd like a copy of the picture. One easy way to get a picture is to save it as in Postscript format. If you want to save the picture in a file called "test.ps" you can do the following:from myro import * win = GraphWin() p1 = Point(25, 50) p1.draw(win) p2 = Point(75, 50) p2.draw(win) t = Text(Point(100, 50), "Doug") win.postscript(file="test.ps")Then, please send me the file "test.ps", and print out your program to hand in. You should center the name at the bottom of the picture. Feel free to use colors. Have fun; be creative!
You should form teams of two or three. Design a game using your knowledge of Python and Myro. Feel free to use the Gamepad and graphics from your book. Goal: make it fun! Due December 6, 2007, in class.
To complete this assignment:
Robot Conflict October 20, 2007, at the Franklin Institute.
Engineering Politics, Good Magazine.
Created by dblank, September 3, 2007.