This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Skiouros's profile picture

Distributing Turtles

Started by Skiouros, 18 November 2014 - 11:04 PM
Skiouros #1
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.
Bomb Bloke #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:

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
Skiouros #3
Posted 19 November 2014 - 07:30 PM
Thanks for the help, I was over complicating things. :D/>