Advertisement
Ham62

Movement.rbs

Jan 29th, 2018
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. float WallDistance = 0 ' Distance from a wall
  2. float MinDistance = 20 ' Minimum distance threshold from a wall
  3.  
  4. float ChangePath = 0 ' Randomly change direction?
  5. float ChangeValue = 5 ' If we pull this value, change direction
  6.  
  7. Start:
  8. ' If we get too close to a wall turn away from it
  9. BIOS.ReadSensor(WallDistance)
  10. if WallDistance < MinDistance Goto TurnRobot
  11.  
  12. ' Pick a random number, if it's 5 then change direction
  13. Rnd(ChangePath, 1, 25)
  14. if ChangePath = ChangeValue then goto TurnRobot
  15.  
  16. BIOS.Move(1)
  17. GOTO Start
  18.  
  19. TurnRobot:
  20. float TurnDirection
  21. Rnd(TurnDirection, -10, 10)
  22. BIOS.Turn(TurnDirection)
  23. Goto Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement