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.
1
Distributing Turtles
Started by Skiouros, Nov 19 2014 12:04 AM
2 replies to this topic
#1
Posted 19 November 2014 - 12:04 AM
#2
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:
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
#3
Posted 19 November 2014 - 07:30 PM
Thanks for the help, I was over complicating things.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users