Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ed.ObstacleDetectionBeam(Ed.ON)
- Ed.Drive(Ed.FORWARD,Ed.SPEED_1,Ed.DISTANCE_UNLIMITED)
- def stop():
- while True:
- Ed.Drive(Ed.STOP, 0, 1000)
- for i in range(100):
- temp_score = 0
- total_score = 0
- if i % 4 == 1:
- temp_score = 0
- obstacle = Ed.ReadObstacleDetection()
- if obstacle > Ed.OBSTACLE_NONE:
- Ed.LeftLed(Ed.ON)
- Ed.RightLed(Ed.ON)
- Ed.PlayBeep()
- Ed.SendIRData(10)
- stop()
- else:
- temp_score = 0
- Ed.Drive(Ed.BACKWARD,Ed.SPEED_1,10)
- temp_score = victory()
- total_score += temp_score
- pass
- elif i % 4 == 2:
- temp_score = 0
- obstacle = Ed.ReadObstacleDetection()
- if obstacle > Ed.OBSTACLE_NONE:
- Ed.LeftLed(Ed.ON)
- Ed.RightLed(Ed.ON)
- Ed.PlayBeep()
- Ed.SendIRData(10)
- stop()
- else:
- temp_score = 0
- Ed.Drive(Ed.SPIN_RIGHT, Ed.SPEED_1, 90)
- Ed.Drive(Ed.FORWARD,Ed.SPEED_1,10)
- temp_score = victory()
- total_score += temp_score
- pass
- elif i % 4 == 3:
- temp_score = 0
- obstacle = Ed.ReadObstacleDetection()
- if obstacle > Ed.OBSTACLE_NONE:
- Ed.LeftLed(Ed.ON)
- Ed.RightLed(Ed.ON)
- Ed.PlayBeep()
- Ed.SendIRData(10)
- stop()
- else:
- temp_score = 0
- Ed.Drive(Ed.SPIN_LEFT, Ed.SPEED_1, 90)
- Ed.Drive(Ed.FORWARD,Ed.SPEED_1,10)
- temp_score = victory()
- total_score += temp_score
- pass
- elif i % 4 ==0:
- temp_score = 0
- obstacle = Ed.ReadObstacleDetection()
- if obstacle > Ed.OBSTACLE_NONE:
- Ed.LeftLed(Ed.ON)
- Ed.RightLed(Ed.ON)
- Ed.PlayBeep()
- Ed.SendIRData(10)
- stop()
- else:
- temp_score = 0
- Ed.Drive(Ed.FORWARD, Ed.SPEED_1, 10)
- temp_score = victory()
- total_score += temp_score
- pass
- if total_score == 4:
- while True:
- Ed.PlayBeep()
- Ed.Drive(Ed.SPIN_RIGHT,Ed.SPEED_1,180)
- def victory():
- if Ed.ReadIRData() == 10:
- return 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement