Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions agents/craftassist/tests/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def record_mobs(self):
self.maybe_add_entry()
self.tape[self.agent.count]["mobs"] = self.agent.get_mobs()

def record_items(self):
self.maybe_add_entry()
self.tape[self.agent.count]["items"] = self.agent.get_item_stacks(get_all=True)

def record_players(self):
self.maybe_add_entry()
player_list = self.agent.get_other_players()
Expand Down Expand Up @@ -87,6 +91,7 @@ def record_world(self):
self.record_mobs()
self.record_agent()
self.record_players()
self.record_items()
self.record_block_changes()

def get_last_record(self):
Expand Down Expand Up @@ -119,4 +124,5 @@ def __next__(self):
"agent": r.get("agent"),
"players": r.get("players"),
"actions": r.get("actions"),
"items": r.get("items"),
}
8 changes: 5 additions & 3 deletions agents/craftassist/tests/test_get_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def setUp(self):
def test_get_name_and_left_of(self):
# set the name
name = "fluffball"
self.agent.memory.nodes[TripleNode.NODE_TYPE].create(self.agent.memory, subj=self.cube.memid, pred_text="has_name", obj_text=name)
self.agent.memory.nodes[TripleNode.NODE_TYPE].create(
self.agent.memory, subj=self.cube.memid, pred_text="has_name", obj_text=name
)

# get the name
d = GET_MEMORY_COMMANDS["what is where I am looking"]
Expand Down Expand Up @@ -89,15 +91,15 @@ def test_what_are_you_building(self):

def test_where_are_you_going(self):
# start moving
d = MOVE_COMMANDS["move to 42 65 0"]
d = MOVE_COMMANDS["move to 8 65 0"]
self.handle_logical_form(d, max_steps=3)

# where are you going?
d = GET_MEMORY_COMMANDS["where are you going"]
self.handle_logical_form(d, stop_on_chat=True)

# check that proper chat was sent
self.assertIn("42", self.last_outgoing_chat())
self.assertIn("8", self.last_outgoing_chat())
self.assertIn("65", self.last_outgoing_chat())

def test_where_are_you(self):
Expand Down
4 changes: 2 additions & 2 deletions droidlet/base_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
T = TypeVar("T") # generic type

"""FIXME!!!!!! make all these dicts all through code"""
Pos = namedtuple("pos", "x, y, z", defaults=(None,) * 3)
Look = namedtuple("look", "yaw, pitch")
Pos = namedtuple("Pos", "x, y, z", defaults=(None,) * 3)
Look = namedtuple("Look", "yaw, pitch")
Player = namedtuple("Player", "entityId, name, pos, look")


Expand Down
5 changes: 3 additions & 2 deletions droidlet/interpreter/craftassist/mc_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,8 @@ def handle_get(self, agent, speaker, d) -> Tuple[Any, Optional[str], Any]:
)

for obj in objs:
task_data = {"target": pos, "eid": obj.eid, "obj_memid": obj.memid}
tasks.append(self.task_objects["drop"](agent, task_data))
if "_in_others_inventory" not in obj.get_tags():
task_data = {"target": pos, "eid": obj.eid, "obj_memid": obj.memid}
tasks.append(self.task_objects["drop"](agent, task_data))

return maybe_bundle_task_list(agent, tasks)
10 changes: 8 additions & 2 deletions droidlet/interpreter/craftassist/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ def __init__(self, agent, task_data):
return
self.target = to_block_pos(np.array(task_data["target"]))
self.approx = task_data.get("approx", 1)
# allows agent to destroy blocks to get to a location
self.destructive = task_data.get("destructive", False)
self.path = None
self.replace = set()
self.last_stepped_time = agent.memory.get_time()
Expand Down Expand Up @@ -235,8 +237,12 @@ def step(self):
if self.path is None or tuple(agent.pos) != self.path[-1]:
self.path = astar(agent, self.target, self.approx)
if self.path is None:
self.handle_no_path(agent)
return
if not self.destructive:
self.finished = True
raise Exception("Could not move to location {}".format(self.target))
else:
self.handle_no_path(agent)
return

# take a step on the path
assert tuple(agent.pos) == self.path.pop()
Expand Down
4 changes: 2 additions & 2 deletions droidlet/interpreter/tests/all_test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,13 @@ def command(d):
}

MOVE_COMMANDS = {
"move to 42 65 0": {
"move to 8 65 0": {
"dialogue_type": "HUMAN_GIVE_COMMAND",
"event_sequence": [
{
"action_type": "MOVE",
"location": {
"reference_object": {"special_reference": {"coordinates_span": "42 65 0"}}
"reference_object": {"special_reference": {"coordinates_span": "8 65 0"}}
},
}
],
Expand Down
14 changes: 5 additions & 9 deletions droidlet/lowlevel/minecraft/pyworld/fake_mobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) Facebook, Inc. and its affiliates.
"""
import numpy as np
from collections import namedtuple
from droidlet.base_util import Pos, Look
from droidlet.shared_data_struct.craftassist_shared_utils import MOBS_BY_ID

Expand All @@ -27,8 +28,7 @@ class Opt:
pass


class MobInfo:
pass
MobInfo = namedtuple("MobInfo", "entityId, pos, look, mobType, color, mobname")


def make_mob_opts(mobname):
Expand Down Expand Up @@ -84,13 +84,9 @@ def add_to_world(self, world):
self.world.mobs.append(self)

def get_info(self):
info = MobInfo()
info.entityId = self.entityId
info.pos = Pos(*self.pos)
info.look = Look(*self.look)
info.mobType = self.mobType
info.color = self.color
info.mobname = self.mobname
info = MobInfo(
self.entityId, Pos(*self.pos), Look(*self.look), self.mobType, self.color, self.mobname
)
return info

def new_direction(self):
Expand Down
1 change: 1 addition & 0 deletions droidlet/lowlevel/minecraft/pyworld/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def update_position(self, x, y, z):
def add_to_world(self, world):
self.entityId = world.new_eid(entityId=self.entityId)
x, y, z, _, _ = make_pose(world.sl, world.sl, height_map=world.get_height_map())
x, y, z = world.from_npy_coords((x, y, z))
self.update_position(x, y, z)
world.items[self.entityId] = self

Expand Down