13 posts
Posted 19 November 2014 - 12:04 AM
I have a rectangle represented by L x W x H and I need ideas on how to send out N turtles to mine out the area.
My goal is to get something like this, but I'm not sure how to go about it. Not to mention handling odd dimensions
Anyone have ideas on how I might go about this.
7083 posts
Location
Tasmania (AU)
Posted 19 November 2014 - 01:14 AM
I would use shapes that require as few turns as possible, a turning is slow. For example, rather than dividing along the length, then the width, then the length, then the width, etc… just keep dividing along the length. This also has the benefit of keeping the shapes simpler.
math.ceil() and math.floor() are two mathematical functions, handy for rounding up and down, respectively. Eg:
local turtleAssignments = {[0] = 0}
local turtles, width = 4, 15
local units = width / turtles
for i = 1, turtles do
turtleAssignments[i] = math.floor(units * i)
print("Turtle "..i.." will dig from "..(turtleAssignments[i-1]+1).." to "..turtleAssignments[i]..".")
end
13 posts
Posted 19 November 2014 - 07:30 PM
Thanks for the help, I was over complicating things. :D/>