Remove grab_sand item pickup job, not worth it
This commit is contained in:
1 parent
e50b9dc697
commit
5f5dde1a62
2 files changed
-128
No files matched your search
@@ -25,7 +25,6 @@ from mosfet.jobs import (
|
|||||||
gather_sand,
|
gather_sand,
|
||||||
gather_wart,
|
gather_wart,
|
||||||
gather_wood,
|
gather_wood,
|
||||||
grab_sand,
|
|
||||||
grab_sapling,
|
grab_sapling,
|
||||||
grab_supplies,
|
grab_supplies,
|
||||||
plant_tree,
|
plant_tree,
|
||||||
@@ -43,7 +42,6 @@ for module in [
|
|||||||
gather_sand,
|
gather_sand,
|
||||||
gather_wart,
|
gather_wart,
|
||||||
gather_wood,
|
gather_wood,
|
||||||
grab_sand,
|
|
||||||
grab_sapling,
|
grab_sapling,
|
||||||
grab_supplies,
|
grab_supplies,
|
||||||
plant_tree,
|
plant_tree,
|
||||||
@@ -67,7 +65,6 @@ class LegacyJobStates:
|
|||||||
self.plant_tree_states = plant_tree.PlantTreeStates(self.g)
|
self.plant_tree_states = plant_tree.PlantTreeStates(self.g)
|
||||||
self.clear_leaves_states = clear_leaves.ClearLeavesStates(self.g)
|
self.clear_leaves_states = clear_leaves.ClearLeavesStates(self.g)
|
||||||
self.grab_sapling_states = grab_sapling.GrabSaplingStates(self.g)
|
self.grab_sapling_states = grab_sapling.GrabSaplingStates(self.g)
|
||||||
self.grab_sand_states = grab_sand.GrabSandStates(self.g)
|
|
||||||
self.fill_blocks_states = fill_blocks.FillBlocksStates(self.g)
|
self.fill_blocks_states = fill_blocks.FillBlocksStates(self.g)
|
||||||
self.gather_wart_states = gather_wart.GatherWartStates(self.g)
|
self.gather_wart_states = gather_wart.GatherWartStates(self.g)
|
||||||
self.gather_crop_states = gather_crop.GatherCropStates(self.g)
|
self.gather_crop_states = gather_crop.GatherCropStates(self.g)
|
||||||
@@ -92,7 +89,6 @@ class LegacyJobStates:
|
|||||||
def gather_sand(self):
|
def gather_sand(self):
|
||||||
machines = [
|
machines = [
|
||||||
self.gather_sand_states,
|
self.gather_sand_states,
|
||||||
self.grab_sand_states,
|
|
||||||
self.cache_items_states,
|
self.cache_items_states,
|
||||||
self.sleep_with_bed_states,
|
self.sleep_with_bed_states,
|
||||||
self.eat_food_states,
|
self.eat_food_states,
|
||||||
@@ -103,7 +99,6 @@ class LegacyJobStates:
|
|||||||
machines = [
|
machines = [
|
||||||
self.grab_supplies_states,
|
self.grab_supplies_states,
|
||||||
self.gather_sand_states,
|
self.gather_sand_states,
|
||||||
self.grab_sand_states,
|
|
||||||
self.cache_items_states,
|
self.cache_items_states,
|
||||||
self.sleep_with_bed_states,
|
self.sleep_with_bed_states,
|
||||||
self.eat_food_states,
|
self.eat_food_states,
|
||||||
@@ -272,7 +267,6 @@ class JobStates(LegacyJobStates):
|
|||||||
self.gather_crop_states = gather_crop.GatherCropStates(global_state)
|
self.gather_crop_states = gather_crop.GatherCropStates(global_state)
|
||||||
self.gather_wart_states = gather_wart.GatherWartStates(global_state)
|
self.gather_wart_states = gather_wart.GatherWartStates(global_state)
|
||||||
self.gather_sand_states = gather_sand.GatherSandStates(global_state)
|
self.gather_sand_states = gather_sand.GatherSandStates(global_state)
|
||||||
self.grab_sand_states = grab_sand.GrabSandStates(global_state)
|
|
||||||
self.grab_supplies_states = grab_supplies.GrabSuppliesStates(
|
self.grab_supplies_states = grab_supplies.GrabSuppliesStates(
|
||||||
global_state)
|
global_state)
|
||||||
self.clear_leaves_states = clear_leaves.ClearLeavesStates(global_state)
|
self.clear_leaves_states = clear_leaves.ClearLeavesStates(global_state)
|
||||||
@@ -361,7 +355,6 @@ class JobStates(LegacyJobStates):
|
|||||||
self.gather_wood_states.state = self.gather_wood_states.idle
|
self.gather_wood_states.state = self.gather_wood_states.idle
|
||||||
self.gather_crop_states.state = self.gather_crop_states.idle
|
self.gather_crop_states.state = self.gather_crop_states.idle
|
||||||
self.gather_sand_states.state = self.gather_sand_states.idle
|
self.gather_sand_states.state = self.gather_sand_states.idle
|
||||||
self.grab_sand_states.state = self.grab_sand_states.idle
|
|
||||||
self.grab_supplies_states.state = self.grab_supplies_states.idle
|
self.grab_supplies_states.state = self.grab_supplies_states.idle
|
||||||
self.clear_leaves_states.state = self.clear_leaves_states.idle
|
self.clear_leaves_states.state = self.clear_leaves_states.idle
|
||||||
self.plant_tree_states.state = self.plant_tree_states.idle
|
self.plant_tree_states.state = self.plant_tree_states.idle
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
"""Pick up dropped sand using 26.3 entity and navigation state."""
|
|
||||||
import time
|
|
||||||
|
|
||||||
from mosfet import utils
|
|
||||||
from mosfet import path
|
|
||||||
from mosfet.info import blocks
|
|
||||||
from mosfet.info import items
|
|
||||||
|
|
||||||
|
|
||||||
class GrabSandStates:
|
|
||||||
PICKUP_DISTANCE = 1.5
|
|
||||||
PICKUP_TIMEOUT = 5.0
|
|
||||||
|
|
||||||
def idle(self):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def init(self):
|
|
||||||
self.eid_blacklist.clear()
|
|
||||||
self.state = self.find_sand
|
|
||||||
print('Looking for dropped sand')
|
|
||||||
|
|
||||||
def _object(self, entity_id):
|
|
||||||
obj = self.g.get('objects', {}).get(entity_id)
|
|
||||||
if obj is None or obj.get('item_id') != items.SAND_ID:
|
|
||||||
return None
|
|
||||||
return obj
|
|
||||||
|
|
||||||
def _skip_target(self):
|
|
||||||
if self.entity_id is not None:
|
|
||||||
self.eid_blacklist.add(self.entity_id)
|
|
||||||
self.g.path = []
|
|
||||||
self.g.look_at = None
|
|
||||||
self.state = self.find_sand
|
|
||||||
|
|
||||||
def find_sand(self):
|
|
||||||
world = self.g.world
|
|
||||||
position = utils.pint(self.g.pos)
|
|
||||||
candidates = [
|
|
||||||
(entity_id, obj) for entity_id, obj in
|
|
||||||
self.g.get('objects', {}).items()
|
|
||||||
if obj.get('item_id') == items.SAND_ID and
|
|
||||||
entity_id not in self.eid_blacklist
|
|
||||||
]
|
|
||||||
candidates.sort(key=lambda pair: utils.phyp(
|
|
||||||
position, (pair[1].x, pair[1].y, pair[1].z)))
|
|
||||||
|
|
||||||
for entity_id, obj in candidates:
|
|
||||||
item_position = (obj.x, obj.y, obj.z)
|
|
||||||
if utils.phyp(position, item_position) > 6:
|
|
||||||
continue
|
|
||||||
item_block = utils.pint(item_position)
|
|
||||||
support = world.block_at(*utils.padd(item_block, path.BLOCK_BELOW))
|
|
||||||
if support is None or support in blocks.NON_SOLID_IDS:
|
|
||||||
continue
|
|
||||||
|
|
||||||
self.entity_id = entity_id
|
|
||||||
self.sand = item_block
|
|
||||||
if utils.phyp(tuple(self.g.pos), item_position) <= self.PICKUP_DISTANCE:
|
|
||||||
self.pickup_deadline = time.monotonic() + self.PICKUP_TIMEOUT
|
|
||||||
self.state = self.wait_for_pickup
|
|
||||||
return
|
|
||||||
|
|
||||||
navpath = world.path_to_place(position, item_block)
|
|
||||||
if not navpath:
|
|
||||||
self.eid_blacklist.add(entity_id)
|
|
||||||
continue
|
|
||||||
|
|
||||||
self.entity_id = entity_id
|
|
||||||
self.sand = item_block
|
|
||||||
self.g.path = navpath
|
|
||||||
self.g.look_at = item_block
|
|
||||||
print('Going to dropped sand', self.sand)
|
|
||||||
self.state = self.going_to_sand
|
|
||||||
return
|
|
||||||
|
|
||||||
print('No reachable dropped sand nearby')
|
|
||||||
self.state = self.cleanup
|
|
||||||
|
|
||||||
def going_to_sand(self):
|
|
||||||
obj = self._object(self.entity_id)
|
|
||||||
if obj is None:
|
|
||||||
self.g.path = []
|
|
||||||
self.state = self.find_sand
|
|
||||||
return
|
|
||||||
|
|
||||||
item_position = (obj.x, obj.y, obj.z)
|
|
||||||
distance = utils.phyp(tuple(self.g.pos), item_position)
|
|
||||||
if distance <= self.PICKUP_DISTANCE:
|
|
||||||
self.g.path = []
|
|
||||||
self.pickup_deadline = time.monotonic() + self.PICKUP_TIMEOUT
|
|
||||||
self.state = self.wait_for_pickup
|
|
||||||
elif not self.g.path:
|
|
||||||
self._skip_target()
|
|
||||||
|
|
||||||
def wait_for_pickup(self):
|
|
||||||
if self._object(self.entity_id) is None:
|
|
||||||
print('Picked up dropped sand')
|
|
||||||
self.g.look_at = None
|
|
||||||
self.state = self.find_sand
|
|
||||||
elif time.monotonic() > self.pickup_deadline:
|
|
||||||
print('Could not pick up dropped sand; skipping', self.sand)
|
|
||||||
self._skip_target()
|
|
||||||
|
|
||||||
def cleanup(self):
|
|
||||||
self.g.path = []
|
|
||||||
self.g.look_at = None
|
|
||||||
self.state = self.done
|
|
||||||
|
|
||||||
def done(self):
|
|
||||||
return None
|
|
||||||
|
|
||||||
def __init__(self, global_state):
|
|
||||||
self.g = global_state
|
|
||||||
self.state = self.idle
|
|
||||||
self.sand = None
|
|
||||||
self.entity_id = None
|
|
||||||
self.eid_blacklist = set()
|
|
||||||
self.pickup_deadline = None
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
self.state()
|
|
||||||
Reference in new issue
Block a user