Batch nether wart farming

This commit is contained in:
Tanner
2026-11-07 17:44:18 +00:00
parent a019b54396
commit 34d902c46d
2 changed files with 35 additions and 2 deletions
+9
View File
@@ -9,6 +9,7 @@ from mosfet.info import items
class GatherWartStates:
WARTS_PER_BATCH = 16
BREAK_TIMEOUT = 5.0
ITEM_TIMEOUT = 8.0
PLACE_TIMEOUT = 3.0
@@ -118,8 +119,15 @@ class GatherWartStates:
def wait_place(self):
current = self.g.world.block_at(*self.wart)
if current in blocks.NETHERWART_IDS and current != self.type_id:
self.completed_warts += 1
print('Nether wart replanted at', self.wart)
if self.completed_warts >= self.WARTS_PER_BATCH:
print('Completed {} nether wart harvests; running maintenance'.format(
self.completed_warts))
self.completed_warts = 0
self.state = self.cleanup
else:
self.state = self.find_new_wart
elif time.monotonic() > self.place_deadline:
print('Nether wart did not replant; blacklisting', self.wart)
self._blacklist_wart()
@@ -138,6 +146,7 @@ class GatherWartStates:
self.wart = None
self.type_id = None
self.bad_warts = []
self.completed_warts = 0
self.break_deadline = None
self.item_deadline = None
self.place_deadline = None
+25 -1
View File
@@ -118,7 +118,8 @@ class GatherWartTests(unittest.TestCase):
self.assertEqual(game.place_calls, [(support, 1)])
world.state_id = unripe
state.wait_place()
self.assertIs(state.state.__func__, state.cleanup.__func__)
self.assertEqual(state.completed_warts, 1)
self.assertIs(state.state.__func__, state.find_new_wart.__func__)
def test_navigation_looks_at_the_wart_target(self):
position = (5, 64, 8)
@@ -137,6 +138,29 @@ class GatherWartTests(unittest.TestCase):
self.assertEqual(g.look_at, position)
self.assertEqual(g.path[-1], position)
def test_gather_wart_finishes_after_sixteen_successful_replants(self):
mature = max(blocks.NETHERWART_IDS)
unripe = min(blocks.NETHERWART_IDS)
class FakeWorld:
@staticmethod
def block_at(*_position):
return unripe
state = GatherWartStates(Munch(world=FakeWorld()))
state.wart = (5, 64, 8)
state.type_id = mature
for completed in range(1, state.WARTS_PER_BATCH):
state.wait_place()
self.assertEqual(state.completed_warts, completed)
self.assertIs(state.state.__func__, state.find_new_wart.__func__)
state.state = state.wait_place
state.wait_place()
self.assertEqual(state.completed_warts, 0)
self.assertIs(state.state.__func__, state.cleanup.__func__)
def test_unreachable_wart_is_blacklisted_without_undefined_variable(self):
position = (5, 64, 8)