Here I am 2K lines of code and 8 weeks later with my first post for help. I’ve made it a point to exhaust all the computercraft and lua forums to the extent possible. Every time I started to type a question I would go double check everything and each time I found the error and cancelled the post.
Now I’m sitting here on day three trying to find a logic problem and could use a fresh set of eyes.
I’ve never considered myself a programmer so this will probably look unorthodox. I’ve also tried a bunch of new things to learn more about functions, tables and the like so it may be overly complicated in places.
I would appreciate any feedback to find the problem and understand where the error(s) are.
This is a seek function that is part of a larger program. I’m attempting to implement A* to somewhat intelligently get my turtle to a set of supply chests. My offset is going up each turn until it does not return a best node around turn 4.
My approach is:
1) Specify destination location for the inventory chest (Captured in another function)
2) Get current location from GPS
3) Get facing direction so that I know which way to move
4) Inspect all neighbor blocks and close the ones that are not “Air”
5) Close the current/parent block.
6) Calculate g (distance from start) for each neighbor
7) Calculate h (distance to end) for each neighbor
8) Calculate f (overall move cost) to each neighbor
9) Make up/down moves cost slightly more
10) Select the lowest cost open node from the list
11) Use absolute distance to end as a tie breaker
12) Move to that node
13) Repeat 2 – 12 while current location does not equal target location
A little over 500 lines. Here is the pastebin:
http://pastebin.com/J4qXNPkp