This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
TechnoColt's profile picture

[Question] Any pathfinding tutorials?

Started by TechnoColt, 01 July 2012 - 02:46 AM
TechnoColt #1
Posted 01 July 2012 - 04:46 AM
I was wondering if any of you pros out there know of any good pathfinding tutorials. I can program other things fairly easily, but pathfinding has always eluded me. None of the results I've found when searching are easily applied to the turtles. If anyone has any suggestions, I would love to hear them. I realize there are already APIs and such that do this, but I am interested in learning how to do it myself. I am in college studying for a game development degree and learning something like this would be very useful.
Binarin #2
Posted 24 July 2012 - 03:15 AM
I don't know any tutorial. But try looking for general pathfinding algorithms or tutorials. Most pathfinders in games use A*
Noodle #3
Posted 24 July 2012 - 03:27 AM
Use turtle.compare()
Just put the item in the first slot of your turtle, select that slot, have it compare to see which way is next.
EXAMPLE:

while true do
  if turtle.compare() then
    turtle.dig()
    turtle.forward()
  else
    turtle.turnRight()
  end
end
-- This is the most basic code for this.. Just manipulate this for the actual movement (Left/Right)