Sleep 0.1 s after failing to pathfind to prevent timeouts

This commit is contained in:
Tanner Collin 2021-04-25 23:39:57 +00:00
parent 7caa51f011
commit a49caaedf5
11 changed files with 12 additions and 18 deletions

View File

@ -65,6 +65,7 @@ class CacheItemsStates:
return return
else: else:
self.trapped_chests.pop(0) self.trapped_chests.pop(0)
time.sleep(0.1)
def going_to_trapped_chest(self): def going_to_trapped_chest(self):
if utils.pint(self.g.pos) == self.opening: if utils.pint(self.g.pos) == self.opening:

View File

@ -64,6 +64,7 @@ class CheckThreatsStates:
return return
else: else:
print('Cant get to safety', self.safety) print('Cant get to safety', self.safety)
time.sleep(0.1)
print('Cant get to safety, aborting') print('Cant get to safety, aborting')
self.state = self.cleanup self.state = self.cleanup

View File

@ -139,8 +139,7 @@ class FillBlocksStates:
else: else:
print('Cant get to that block') print('Cant get to that block')
self.state = self.cleanup self.state = self.cleanup
#self.bad_sand.append(self.sand) time.sleep(0.1)
#self.state = self.find_new_sand
def going_to_block(self): def going_to_block(self):
if not len(self.g.path): if not len(self.g.path):

View File

@ -61,15 +61,8 @@ class GatherCropStates:
self.state = self.going_to_crop self.state = self.going_to_crop
else: else:
print('Cant get to it, blacklisting') print('Cant get to it, blacklisting')
time.sleep(0.1)
self.bad_crops.append(self.crop) self.bad_crops.append(self.crop)
self.wait_time = 0.5
self.state = self.wait_to_restart
def wait_to_restart(self):
# prevent timeouts
if self.wait_time > 0:
self.wait_time -= utils.TICK
else:
self.state = self.find_new_crop self.state = self.find_new_crop
def going_to_crop(self): def going_to_crop(self):

View File

@ -89,6 +89,7 @@ class GatherSandStates:
self.state = self.going_to_sand self.state = self.going_to_sand
else: else:
print('Cant get to that sand') print('Cant get to that sand')
time.sleep(0.1)
self.bad_sand.append(self.sand) self.bad_sand.append(self.sand)
self.state = self.find_new_sand self.state = self.find_new_sand

View File

@ -54,15 +54,8 @@ class GatherWartStates:
self.state = self.going_to_wart self.state = self.going_to_wart
else: else:
print('Cant get to it, blacklisting') print('Cant get to it, blacklisting')
time.sleep(0.1)
self.bad_warts.append(wart) self.bad_warts.append(wart)
self.wait_time = 0.5
self.state = self.wait_to_restart
def wait_to_restart(self):
# prevent timeouts
if self.wait_time > 0:
self.wait_time -= utils.TICK
else:
self.state = self.find_new_wart self.state = self.find_new_wart
def going_to_wart(self): def going_to_wart(self):

View File

@ -80,6 +80,7 @@ class GatherWoodStates:
self.state = self.going_to_tree self.state = self.going_to_tree
else: else:
self.openings.pop(0) self.openings.pop(0)
time.sleep(0.1)
def going_to_tree(self): def going_to_tree(self):
if utils.pint(self.g.pos) == self.openings[0]: if utils.pint(self.g.pos) == self.openings[0]:
@ -126,6 +127,7 @@ class GatherWoodStates:
else: else:
self.openings.pop(0) self.openings.pop(0)
self.state = self.choose_opening self.state = self.choose_opening
time.sleep(0.1)
def going_to_trunk_base(self): def going_to_trunk_base(self):
if utils.pint(self.g.pos) == self.tree: if utils.pint(self.g.pos) == self.tree:

View File

@ -61,6 +61,7 @@ class GrabSandStates:
return return
else: else:
print('Cant get to sand', self.sand) print('Cant get to sand', self.sand)
time.sleep(0.1)
print('Cant get to any more sand, aborting') print('Cant get to any more sand, aborting')
self.state = self.cleanup self.state = self.cleanup

View File

@ -100,6 +100,7 @@ class GrabSuppliesStates:
return return
else: else:
print('No path, blacklisting barrel') print('No path, blacklisting barrel')
time.sleep(0.1)
self.bad_barrels.append(self.barrel) self.bad_barrels.append(self.barrel)
self.state = self.choose_barrel self.state = self.choose_barrel

View File

@ -69,6 +69,7 @@ class SellToVillagerStates:
self.state = self.going_to_villager self.state = self.going_to_villager
else: else:
self.openings.pop(0) self.openings.pop(0)
time.sleep(0.1)
def going_to_villager(self): def going_to_villager(self):
if utils.pint(self.g.pos) == self.openings[0]: if utils.pint(self.g.pos) == self.openings[0]:

View File

@ -81,6 +81,7 @@ class SleepWithBedStates:
self.beds.pop(0) self.beds.pop(0)
self.bad_beds.append(bed) self.bad_beds.append(bed)
print('Cant get to bed, blacklisting') print('Cant get to bed, blacklisting')
time.sleep(0.1)
self.state = self.select_bed self.state = self.select_bed
def going_to_bed(self): def going_to_bed(self):