Advertisement
Guest User

Untitled

a guest
May 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. def main():
  2. robot = Robot("outB", "outC")
  3. time = current_time()
  4. while True:
  5.  
  6. directions = robot.process_colors(robot.register_colors(robot.forward_color()))
  7. print(directions)
  8.  
  9. if len(directions) == 0:
  10. continue
  11.  
  12. if Robot.WIN in directions:
  13. break
  14.  
  15. print(directions)
  16.  
  17. if len(directions) > 1 and Robot.D_BACKWARD in directions:
  18. directions.remove(Robot.D_BACKWARD)
  19.  
  20. print(directions)
  21. print("----")
  22.  
  23. time2 = current_time()
  24.  
  25. while time < time2:
  26. angle = robot.gyroscope.value()%360
  27. if 45 <= temp < 135:
  28. dir = "E"
  29. elif 135 <= temp < 225:
  30. dir = "S"
  31. elif 225 <= temp < 315:
  32. dir = "W"
  33. else:
  34. dir = "N"
  35.  
  36. robot.textMap += dir
  37. time += 100
  38.  
  39.  
  40. robot.rotate_to_direction(random.sample(directions, 1)[0])
  41. time = current_time()
  42. robot.forward(duration=500)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement