Fix more sand bugs

This commit is contained in:
Tanner Collin 2020-09-17 00:01:10 -06:00
parent 5c21634d16
commit ce22946023
2 changed files with 9 additions and 8 deletions

View File

@ -93,7 +93,7 @@ class MCWorld:
try: try:
s = maze_solver.astar(start, place) s = maze_solver.astar(start, place)
return list(s) if s else None return list(s) if s else None
except AStarTimeout: except path.AStarTimeout:
return None return None
def find_bed_areas(self, center, distance): def find_bed_areas(self, center, distance):
@ -131,7 +131,7 @@ class MCWorld:
sand = [] sand = []
for i in range(10): for i in range(10):
check = utils.padd(center, utils.alternate(i, 1)) check = utils.padd(center, utils.alternate(i, 1))
sand.extend(self.find_blocks(check, distance, [66], 20)) sand.extend(self.find_blocks(check, distance, [blocks.SAND], 20))
safe_sand = [] safe_sand = []
for s in sand: for s in sand:
@ -195,7 +195,7 @@ class Game:
if solution: if solution:
solution = list(solution) solution = list(solution)
self.g.path = solution self.g.path = solution
#g.jobstate.state = self.g.jobstate.stop self.g.job.state = self.g.job.stop
print(len(solution)) print(len(solution))
print(solution) print(solution)
print(round(time.time() - start, 3), 'seconds') print(round(time.time() - start, 3), 'seconds')
@ -284,7 +284,6 @@ class Game:
self.g.job.state = self.g.job.stop self.g.job.state = self.g.job.stop
reply = 'ok' reply = 'ok'
if command == 'inv': if command == 'inv':
for i in self.g.inv.values(): for i in self.g.inv.values():
if i.present: if i.present:

10
jobs.py
View File

@ -180,12 +180,14 @@ class GatherSandStates:
w = self.g.world w = self.g.world
p = utils.pint(self.g.pos) p = utils.pint(self.g.pos)
sand = w.find_sand(p, 150, self.origin) sand = w.find_sand(p, 50, self.origin)
print('Found sand:', sand) print('Found sand:', sand)
while sand[0] in self.bad_sand: for check in sand:
sand.pop(0) if check in self.bad_sand:
self.sand = sand[0] continue
self.sand = check
break
self.state = self.nav_to_sand self.state = self.nav_to_sand