Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float WallDistance = 0 ' Distance from a wall
- float MinDistance = 20 ' Minimum distance threshold from a wall
- float ChangePath = 0 ' Randomly change direction?
- float ChangeValue = 5 ' If we pull this value, change direction
- Start:
- ' If we get too close to a wall turn away from it
- BIOS.ReadSensor(WallDistance)
- if WallDistance < MinDistance Goto TurnRobot
- ' Pick a random number, if it's 5 then change direction
- Rnd(ChangePath, 1, 25)
- if ChangePath = ChangeValue then goto TurnRobot
- BIOS.Move(1)
- GOTO Start
- TurnRobot:
- float TurnDirection
- Rnd(TurnDirection, -10, 10)
- BIOS.Turn(TurnDirection)
- Goto Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement