Advertisement
Guest User

Untitled

a guest
Dec 9th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.39 KB | None | 0 0
  1. Ed.ObstacleDetectionBeam(Ed.ON)
  2.  
  3. Ed.Drive(Ed.FORWARD,Ed.SPEED_1,Ed.DISTANCE_UNLIMITED)
  4.  
  5. def stop():
  6.     while True:
  7.         Ed.Drive(Ed.STOP, 0, 1000)
  8.  
  9. for i in range(100):
  10.     temp_score = 0
  11.     total_score = 0
  12.     if i % 4 == 1:
  13.           temp_score = 0
  14.           obstacle = Ed.ReadObstacleDetection()
  15.           if obstacle > Ed.OBSTACLE_NONE:
  16.             Ed.LeftLed(Ed.ON)
  17.             Ed.RightLed(Ed.ON)
  18.             Ed.PlayBeep()
  19.             Ed.SendIRData(10)
  20.             stop()
  21.           else:
  22.               temp_score = 0
  23.               Ed.Drive(Ed.BACKWARD,Ed.SPEED_1,10)
  24.               temp_score = victory()
  25.               total_score += temp_score
  26.               pass
  27.     elif i % 4 == 2:
  28.           temp_score = 0
  29.           obstacle = Ed.ReadObstacleDetection()
  30.           if obstacle > Ed.OBSTACLE_NONE:
  31.             Ed.LeftLed(Ed.ON)
  32.             Ed.RightLed(Ed.ON)
  33.             Ed.PlayBeep()
  34.             Ed.SendIRData(10)
  35.             stop()
  36.           else:
  37.              temp_score = 0
  38.              Ed.Drive(Ed.SPIN_RIGHT, Ed.SPEED_1, 90)
  39.              Ed.Drive(Ed.FORWARD,Ed.SPEED_1,10)
  40.              temp_score = victory()
  41.              total_score += temp_score
  42.              pass
  43.  
  44.     elif i % 4 == 3:
  45.          temp_score = 0
  46.          obstacle = Ed.ReadObstacleDetection()
  47.          if obstacle > Ed.OBSTACLE_NONE:
  48.             Ed.LeftLed(Ed.ON)
  49.             Ed.RightLed(Ed.ON)
  50.             Ed.PlayBeep()
  51.             Ed.SendIRData(10)
  52.             stop()
  53.          else:
  54.               temp_score = 0
  55.               Ed.Drive(Ed.SPIN_LEFT, Ed.SPEED_1, 90)
  56.               Ed.Drive(Ed.FORWARD,Ed.SPEED_1,10)
  57.               temp_score = victory()
  58.               total_score += temp_score
  59.               pass
  60.  
  61.     elif i % 4 ==0:
  62.           temp_score = 0
  63.           obstacle = Ed.ReadObstacleDetection()
  64.           if obstacle > Ed.OBSTACLE_NONE:
  65.             Ed.LeftLed(Ed.ON)
  66.             Ed.RightLed(Ed.ON)
  67.             Ed.PlayBeep()
  68.             Ed.SendIRData(10)
  69.             stop()
  70.           else:
  71.               temp_score = 0
  72.               Ed.Drive(Ed.FORWARD, Ed.SPEED_1, 10)
  73.               temp_score = victory()
  74.               total_score += temp_score
  75.               pass
  76.          
  77.     if total_score == 4:
  78.         while True:
  79.              Ed.PlayBeep()
  80.              Ed.Drive(Ed.SPIN_RIGHT,Ed.SPEED_1,180)
  81.  
  82. def victory():
  83.     if Ed.ReadIRData() == 10:
  84.         return 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement