hoblin

Maze solver

Dec 4th, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.54 KB | None | 0 0
  1.  
  2. function step()
  3.   turtle.turnLeft()
  4.   if not turtle.detect() then -- Check left
  5.     storeTurn('L')
  6.   else
  7.     turtle.turnRight()
  8.     if not turtle.detect() then -- Check forward
  9.       storeTurn('F')
  10.     else
  11.       turtle.turnRight()
  12.       if not turtle.detect() then -- Check right
  13.         storeTurn('R')
  14.       else
  15.         turtle.turnRight()
  16.         storeTurn('B')
  17.       end
  18.     end
  19.   end
  20.   turtle.forward()
  21. end
  22.  
  23. function storeTurn(turn)
  24.   print(turn)
  25. end
  26.  
  27. while not rs.getInput('front') do
  28.   step()
  29. end
  30.  
  31. print('SOLVED!')
Advertisement
Add Comment
Please, Sign In to add comment