diff --git a/mine.lua b/mine.lua index d2eb74f..2912df1 100644 --- a/mine.lua +++ b/mine.lua @@ -6,9 +6,13 @@ local FUEL_RESERVE = 800 local FUEL_REFUEL_UNIT = 8 -- how many items to refuel with at a time local FULL_CHECK_SLOT = 14 -- slot to check for "fullness" + +-- what size is good for a medium-size piece +local MED_DIM = 11 + -- what size of a dimension is considered big enough to split into medium-size -- pieces -local BIG_DIM = 7 +local BIG_DIM = MED_DIM * 3 local V_ZERO = vector.new(0, 0, 0) local UNIT_X = vector.new(1, 0, 0) @@ -280,32 +284,19 @@ end function splitHorizontal (block) -- TODO make this less naive? - -- Future work: potentially split a large block into smaller blocks - -- based on currentPos (think splitting down the middle instead of - -- splitting off of one end) - local differentSigns = function (a, b) - return math.abs(a + b) < math.abs(a) + math.abs(b) - end + local take_amt = 1 local bigBlock = function (block) - return (block.v2.x >= BIG_DIM) and (block.v2.z >= BIG_DIM) + return (block.v2.x >= BIG_DIM) or (block.v2.z >= BIG_DIM) end - local inMiddleOfBlock = function (block) - local middle_of_x = differentSigns(block.v1.x, block.v2.x) - local middle_of_z = differentSigns(block.v1.z, block.v2.z) - return middle_of_x or middle_of_z - end - local inMiddleOfBigBlock = function (block) - return bigBlock(block) and inMiddleOfBlock(block) - end - if inMiddleOfBigBlock(block) then - -- TODO split the big block at where the turtle is near + if bigBlock(block) then + take_amt = MED_DIM end -- decide whether to take a slice off of the x or z direction - -- (criteria: take the dimension that is not too big) - if math.abs(block.v2.z) < BIG_DIM then - return block:take(1, "z") + -- (criteria: bite a piece off the bigger dimension) + if math.abs(block.v2.z) >= math.abs(block.v2.x) then + return block:take(take_amt, "z") else - return block:take(1, "x") + return block:take(take_amt, "x") end end