From a49caaedf587818ef2a9f8794a5b46515fbe8a36 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sun, 25 Apr 2021 23:39:57 +0000 Subject: [PATCH] Sleep 0.1 s after failing to pathfind to prevent timeouts --- mosfet/jobs/cache_items.py | 1 + mosfet/jobs/check_threats.py | 1 + mosfet/jobs/fill_blocks.py | 3 +-- mosfet/jobs/gather_crop.py | 9 +-------- mosfet/jobs/gather_sand.py | 1 + mosfet/jobs/gather_wart.py | 9 +-------- mosfet/jobs/gather_wood.py | 2 ++ mosfet/jobs/grab_sand.py | 1 + mosfet/jobs/grab_supplies.py | 1 + mosfet/jobs/sell_to_villager.py | 1 + mosfet/jobs/sleep_with_bed.py | 1 + 11 files changed, 12 insertions(+), 18 deletions(-) diff --git a/mosfet/jobs/cache_items.py b/mosfet/jobs/cache_items.py index b613197..38d5aba 100644 --- a/mosfet/jobs/cache_items.py +++ b/mosfet/jobs/cache_items.py @@ -65,6 +65,7 @@ class CacheItemsStates: return else: self.trapped_chests.pop(0) + time.sleep(0.1) def going_to_trapped_chest(self): if utils.pint(self.g.pos) == self.opening: diff --git a/mosfet/jobs/check_threats.py b/mosfet/jobs/check_threats.py index 38075e1..f61eee7 100644 --- a/mosfet/jobs/check_threats.py +++ b/mosfet/jobs/check_threats.py @@ -64,6 +64,7 @@ class CheckThreatsStates: return else: print('Cant get to safety', self.safety) + time.sleep(0.1) print('Cant get to safety, aborting') self.state = self.cleanup diff --git a/mosfet/jobs/fill_blocks.py b/mosfet/jobs/fill_blocks.py index 633b292..31243f1 100644 --- a/mosfet/jobs/fill_blocks.py +++ b/mosfet/jobs/fill_blocks.py @@ -139,8 +139,7 @@ class FillBlocksStates: else: print('Cant get to that block') self.state = self.cleanup - #self.bad_sand.append(self.sand) - #self.state = self.find_new_sand + time.sleep(0.1) def going_to_block(self): if not len(self.g.path): diff --git a/mosfet/jobs/gather_crop.py b/mosfet/jobs/gather_crop.py index 7917435..7f7ff5d 100644 --- a/mosfet/jobs/gather_crop.py +++ b/mosfet/jobs/gather_crop.py @@ -61,15 +61,8 @@ class GatherCropStates: self.state = self.going_to_crop else: print('Cant get to it, blacklisting') + time.sleep(0.1) 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 def going_to_crop(self): diff --git a/mosfet/jobs/gather_sand.py b/mosfet/jobs/gather_sand.py index 38830ba..10fe9f6 100644 --- a/mosfet/jobs/gather_sand.py +++ b/mosfet/jobs/gather_sand.py @@ -89,6 +89,7 @@ class GatherSandStates: self.state = self.going_to_sand else: print('Cant get to that sand') + time.sleep(0.1) self.bad_sand.append(self.sand) self.state = self.find_new_sand diff --git a/mosfet/jobs/gather_wart.py b/mosfet/jobs/gather_wart.py index d99ab84..8f1a47e 100644 --- a/mosfet/jobs/gather_wart.py +++ b/mosfet/jobs/gather_wart.py @@ -54,15 +54,8 @@ class GatherWartStates: self.state = self.going_to_wart else: print('Cant get to it, blacklisting') + time.sleep(0.1) 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 def going_to_wart(self): diff --git a/mosfet/jobs/gather_wood.py b/mosfet/jobs/gather_wood.py index 32443fe..012eb3e 100644 --- a/mosfet/jobs/gather_wood.py +++ b/mosfet/jobs/gather_wood.py @@ -80,6 +80,7 @@ class GatherWoodStates: self.state = self.going_to_tree else: self.openings.pop(0) + time.sleep(0.1) def going_to_tree(self): if utils.pint(self.g.pos) == self.openings[0]: @@ -126,6 +127,7 @@ class GatherWoodStates: else: self.openings.pop(0) self.state = self.choose_opening + time.sleep(0.1) def going_to_trunk_base(self): if utils.pint(self.g.pos) == self.tree: diff --git a/mosfet/jobs/grab_sand.py b/mosfet/jobs/grab_sand.py index 0d1c99c..bafb88a 100644 --- a/mosfet/jobs/grab_sand.py +++ b/mosfet/jobs/grab_sand.py @@ -61,6 +61,7 @@ class GrabSandStates: return else: print('Cant get to sand', self.sand) + time.sleep(0.1) print('Cant get to any more sand, aborting') self.state = self.cleanup diff --git a/mosfet/jobs/grab_supplies.py b/mosfet/jobs/grab_supplies.py index d168cc0..7ebbc7d 100644 --- a/mosfet/jobs/grab_supplies.py +++ b/mosfet/jobs/grab_supplies.py @@ -100,6 +100,7 @@ class GrabSuppliesStates: return else: print('No path, blacklisting barrel') + time.sleep(0.1) self.bad_barrels.append(self.barrel) self.state = self.choose_barrel diff --git a/mosfet/jobs/sell_to_villager.py b/mosfet/jobs/sell_to_villager.py index 698963f..5dd2d0d 100644 --- a/mosfet/jobs/sell_to_villager.py +++ b/mosfet/jobs/sell_to_villager.py @@ -69,6 +69,7 @@ class SellToVillagerStates: self.state = self.going_to_villager else: self.openings.pop(0) + time.sleep(0.1) def going_to_villager(self): if utils.pint(self.g.pos) == self.openings[0]: diff --git a/mosfet/jobs/sleep_with_bed.py b/mosfet/jobs/sleep_with_bed.py index 4116702..55de0f7 100644 --- a/mosfet/jobs/sleep_with_bed.py +++ b/mosfet/jobs/sleep_with_bed.py @@ -81,6 +81,7 @@ class SleepWithBedStates: self.beds.pop(0) self.bad_beds.append(bed) print('Cant get to bed, blacklisting') + time.sleep(0.1) self.state = self.select_bed def going_to_bed(self):