New version features:
- New tinyMap API which drastically reduces the file size of the map saves.
- Implemented sessions which help to increase successful pathfinding in constantly changing environments.
- Added the ability to limit the search area, to stop your turtle wandering off too far!
- Turtle remembers it's position and heading at all times (not between server restarts though).
Usage:
The API has an easy installer available on pastebin at rNZx09j4.
(See Downloads for individual file list)
Setup process:
Spoiler
To get yourself up and running, follow these three easy steps!
1) The turtle requires a reliable GPS network to be able to determine it's position, so make sure to fully cover the area you want to navigate with GPS points.
2) The turtle needs to have a wireless modem to access the GPS network, as well as fuel!!! (You can also optionally equip the turtle with a sensor from openPeripheral to massively speed up it's navigation)
3) Once you have installed all the files, either use the 'starNav.goto' function, or the provided 'goto' program.
Using the 'goto' program: goto x y z
Using the starNav API: starNav.goto(x, y, z)
goto program - Easy to use program based on the starNav API
Spoiler
Simply run the program in shell, providing the co-ordinates you want to pathfind to:
goto x y z
You can provide an additional argument to limit the search area so that the turtle doesn't wander too far:
goto x y z maxDistance
starNav API - Main API that let's you use the pathfinding functions in your own programs
Spoiler
function goto(<number> xPos, <number> yPos, <number> zPos, <(optional)number> maxDistance)
function getPosition()
returns <number> xPos, <number> yPos, <number> zPos, <number> heading
aStar API - The raw A* API
Spoiler
Utility functions:
function newMap()
returns a basic 3D map that can be used to store any values
function vectorEquals(<vector> vec1, <vector> vec2)
returns true if vec1 and vec2 have the same value or false otherwise
function adjacent(<vector> vec1)
returns a table with all 6 adjecent coords to the one at vec1 (e.g up, down, left, right, forward, backward)
function distance(<vector> vec1, <vector> vec2)
return the 1-norm / manhattan distance between two vectors
Main function:
function compute(<function> distanceFunction, <vector> startCoord, <vector> endCoord)
returns an array of the path in vector format or false if no path can be found
pQueue API - A binary heap based priority queue
Spoiler
Create a new by calling the new function:
function new(<(optional)function> compareFunction)
return a new instance of a priority queue with compareFunction as the function used two compare two elements in the queue
The priority queue then has the following methods:
queue:insert(element, value)
returns the position the element is inserted into the queue at
queue:remove(element, <(optional)function> elementEqualsFunction)
queue:pop()
queue:peek()
queue:contains(element, <(optional)function> elementEqualsFunction)
queue:isEmpty()
queue:size()
queue:getValue(element, <(optional)function> elementEqualsFunction)
queue:setValue(element, value, <(optional)function> elementEqualsFunction)
tinyMap API - API used to save 3D data
Spoiler
TODO
location API - Modified version of an API I found somewhere???, altered to use Minecraft's values for headings
I saw this post a while back, and it's an amazing idea, I just didn't really no what to do with it. So now I'm interested in what you come up with, result-wise, BaRF.
@blunty666 - How exactly would I go about implementing this in my programs, etc.? I have no experience with APIs such as this.
Thanks for the feedback, let me know how you get on trying it out BaRF.
ReconTurtle, on 09 July 2014 - 08:23 PM, said:
@blunty666 - How exactly would I go about implementing this in my programs, etc.? I have no experience with APIs such as this.
At the moment the main way to use it would be to know the world coordinates of the location you want the turtle to move to and call starNav.goto(x, y, z) from within your program with these coordinates (replace starNav with whatever name you have saved/loaded the API under). It will then start pathfinding and will return to your program when it reaches those coordinates. If it can't find a path it will throw errors describing why, though fuel checking is something I need to add, at the moment I'm just testing to see if the pathfinding works successfully.
i get an error:
starNav:90: could not determine direction - phase 3
Sorry for the slow response, did you manage to get it working? The error you gave is most likely due to the turtle not having any fuel I think, so it might be worth checking that.
starNav 3.0 Changelog (everything's changed!)
- Is now more modular, split off the aStar API so it can be used on its own
- New tinyMap API that has smaller file sizes so that a larger area of the world can be mapped and saved
- Various refinements to the starNav goto algorithm to improve success rates when the world changes, and to define a max distance so the turtle can't wander off too far