Reverse order slices are found, fix bugs

This commit is contained in:
2020-12-02 00:02:26 -07:00
parent b7295b4beb
commit 00846538e8
2 changed files with 29 additions and 26 deletions
+9 -9
View File
@@ -211,19 +211,17 @@ class MCWorld:
return False
def find_sand_slice(self, center, distance, skip_to=(0, 0)):
def find_sand_slice(self, center, distance, bad_slices=[]):
# returns the centre coord of the next 5x5x1 slice that still has
# diggable sand in it. lower slices are only valid if there's an
# adjacent slice farther at the same level. this should ensure an
# upside down pyramid gets excavated so the edges are still climbable
skip_vertical, skip_spiral = skip_to
for v in count(skip_vertical):
for v in count():
peak = utils.padd(center, (0, 20-v, 0))
slices = []
layer = 0
start_step = skip_spiral if v == skip_vertical else 0
for step in count(start_step):
for step in count():
offset = utils.spiral(step)
layer = max(layer, *offset)
offset = utils.pmul(offset, 3)
@@ -233,10 +231,12 @@ class MCWorld:
if utils.phyp(center, check) >= distance:
break
if self.check_sand_slice(check):
return (v-1, step+1), check
if self.check_sand_slice(check) and check not in bad_slices:
slices.append(check)
if v > 40:
if len(slices):
return slices[-1]
elif v > 40:
return None, None