Nibato 3 Posted September 22, 2014 Share Posted September 22, 2014 I wrote a simple robot navigation API/library for my own personal use, and figured someone else might be able to make use of it.I spent a good hour documenting all the code so hopefully it isn't too hard to figure out. Unfortunately though, I'm not the best at explaining things If you have any issues with it, just yell at me and I'll take a look at it. DownloadLicense Quote Link to post Share on other sites
Qanthelas 0 Posted October 23, 2014 Share Posted October 23, 2014 Thanks for the post! I'm trying to come up with a way to map out an area with a robot using the new component.geolyzer.analyze() function so that we can give the robot a specific block name to search for and go to. I've been looking at this code from Akuukis and now it's really helpful for me to compare it with yours, so thanks for posting! Am I correct in reading your code that the way you plot your map to see which blocks are air and which are not is simply by trying to move there and reading the error message that comes up if the block isn't air? The nav.lua from Akuukis uses robot.detect() to plot out the blocks around it, that's why I ask. Quote Link to post Share on other sites
Nibato 3 Posted October 23, 2014 Author Share Posted October 23, 2014 If you're talking about nibnav.pathfind() in particular, no. It lets you use your own callback for "plotting" the path. You basically pass it a callback function (getCost, it's documented in the code) and the callback should return a numerical weight if it's a reachable block or null if it's impassable. In other words, you provide the block data, all it does is find and return a path in said block data.The algorithm will try to find the path with the lowest weight cost. I'd recommend reading this article if you're unfamiliar with A* pathfinding.Now, It does check for the success of the movement functions for the purpose of changing/updating it's internal x,y,z coordinates. nibnav.moveY/X/Z/XZ only move in straight lines, and they're basically meant to be helper functions used in conjuction with nibnav.pathfind()The code is pretty messy but you can look at this code to see an example of how it's used. This is my personal circular branch mining script, but it's still a heavy WIP so I don't have any documentation for it at the moment unfortunately. Look at genMap(), moveTo(), and getMoveCost(). genMap() generates a 2d bitmap of what the mine shaft will look like once it's completely dug out. Quote Link to post Share on other sites