-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw6.py
44 lines (34 loc) · 1.01 KB
/
hw6.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Solace Collestan
# Sam Lawrence
# October 19, 2009
# We worked on this assignment with Courtney Price, Farzon Lotfi and Joseph Rao IV.
from myro import *
init('com4')
def countYellows(pic):
countYellowPix=0
for pixel in getPixels(pic):
if getRed(pixel)>=190 and getGreen(pixel)>=140 and getBlue(pixel)<=135:
countYellowPix+=1
return countYellowPix
def celebrate():
speak("I win! We found it!")
for i in range(0,2):
beep(.5,680)
turnLeft(1,1)
def findYellow():
while True:
p=takePicture()
yellowPixels=countYellows(p)
print yellowPixels
show(p)
if yellowPixels>=2500 and getObstacle("center")>900:
celebrate()
stop()
return
elif yellowPixels>=2500:
forward(.5,1)
else:
turnRight(.5,.6)
findYellow()