Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function Define()
- Maze = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}
- Maze[1] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
- for i = 2, 15 do
- Maze[i] = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}
- end
- Maze[16] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
- end
- local function ChangeDir(dir, curdir)
- if (curdir+1)%4 == dir
- turtle.turnRight()
- elseif (curdir-1)%4 == dir
- turtle.turnLeft()
- else
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- local function CheckCoord()
- local openlist = {}
- local closedlist = {}
- local k = 1
- local tempH = 9*(math.abs(px-dx) + math.abs(py-dy))
- local tempG = 0
- table.insert(openlist, k, { x = dx, y = dy, g = tempG, h = tempH, f = tempG+tempH, par = 1})
- while #openlist > 0 do
- local lowestF = openlist[k].f
- for i = 1, #openlist do
- if openlist[i] < lowestF then
- lowestF = openlist[i].f
- k = i
- end
- end
- if not CheckCoord()
- if not
- table.insert(closedlist,openlist[k])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement