示例#1
0
 def setUp(self):
     super().setUp()
     red_cube_triples = {
         "has_name": "cube",
         "has_shape": "cube",
         "has_colour": "red"
     }
     blue_cube_triples = {
         "has_name": "cube",
         "has_shape": "cube",
         "has_colour": "blue"
     }
     red_sphere_triples = {
         "has_name": "sphere",
         "has_shape": "sphere",
         "has_colour": "red"
     }
     blue_sphere_triples = {
         "has_name": "sphere",
         "has_shape": "sphere",
         "has_colour": "blue"
     }
     self.cube1 = self.add_object(shapes.cube(bid=(35, 14)), (19, 63, 14),
                                  relations=red_cube_triples)
     self.cube2 = self.add_object(shapes.cube(bid=(35, 14)), (15, 63, 15),
                                  relations=red_cube_triples)
     self.cube3 = self.add_object(shapes.cube(bid=(35, 11)), (14, 63, 19),
                                  relations=blue_cube_triples)
     self.sphere1 = self.add_object(shapes.sphere(bid=(35, 14), radius=2),
                                    (14, 63, 8),
                                    relations=red_sphere_triples)
     self.sphere2 = self.add_object(shapes.sphere(bid=(35, 11), radius=2),
                                    (8, 63, 14),
                                    relations=blue_sphere_triples)
     self.set_looking_at(list(self.cube1.blocks.keys())[0])
示例#2
0
def add_two_cubes(test):
    triples = {"has_name": "cube", "has_shape": "cube"}
    test.cube_right: List[Block] = list(
        test.add_object(xyzbms=shapes.cube(bid=(42, 0)),
                        origin=(9, 63, 4),
                        relations=triples).blocks.items())
    test.cube_left: List[Block] = list(
        test.add_object(xyzbms=shapes.cube(),
                        origin=(9, 63, 10),
                        relations=triples).blocks.items())
    test.set_looking_at(test.cube_right[0][0])
示例#3
0
 def setUp(self):
     super().setUp()
     cube_triples = {"has_name": "cube", "has_shape": "cube"}
     self.cube = self.add_object(shapes.cube(bid=(42, 0)), (9, 63, -2),
                                 relations=cube_triples)
     sphere_triples = {"has_name": "sphere", "has_shape": "sphere"}
     self.sphere = self.add_object(shapes.sphere(radius=1), (11, 64, 2),
                                   relations=sphere_triples)
     triangle_triples = {"has_name": "triangle", "has_shape": "triangle"}
     self.triangle = self.add_object(shapes.triangle(), (6, 64, -5),
                                     relations=triangle_triples)
     self.set_looking_at(list(self.cube.blocks.keys())[0])
示例#4
0
def add_many_objects(test):
    # loc, size, material, time (in world steps~secs)
    cube_data = [
        [(-5, 63, 4), 3, (57, 0), 1],
        [(10, 63, 9), 5, (41, 0), 5],
        [(5, 63, 4), 4, (41, 0), 10],
    ]
    cube_triples = {"has_name": "cube", "has_shape": "cube"}
    test.shapes = [
        list(
            test.agent.add_object_ff_time(
                cd[3],
                xyzbms=shapes.cube(size=cd[1], bid=cd[2]),
                origin=cd[0],
                relations=cube_triples,
            ).blocks.items()) for cd in cube_data
    ]
    test.set_looking_at(test.shapes[0][0][0])
示例#5
0
    def test_undo_destroy(self):
        tag = "fluffy"

        # Build something
        obj = self.add_object(shapes.cube(bid=(41, 0)), (0, 63, 0))
        self.set_looking_at(list(obj.blocks.keys())[0])

        # Tag it
        d = PUT_MEMORY_COMMANDS["that is fluffy"]
        self.handle_logical_form(d)
        self.assertIn(tag, obj.get_tags())

        # Destroy it
        d = DESTROY_COMMANDS["destroy where I am looking"]
        self.handle_logical_form(d)
        self.assertIsNone(
            self.agent.memory.get_block_object_by_xyz(
                list(obj.blocks.keys())[0]))

        # Undo destroy (will ask confirmation)
        d = OTHER_COMMANDS["undo"]
        self.handle_logical_form(d)
        self.assertIsInstance(
            self.agent.dialogue_manager.dialogue_stack.peek(), AwaitResponse)

        # confirm undo
        # TODO change tests to record different speakers to avoid the sleep?
        time.sleep(0.02)
        self.add_incoming_chat("yes", self.speaker)
        self.flush()

        # Check that block object has tag
        newobj = self.agent.memory.get_block_object_by_xyz(
            list(obj.blocks.keys())[0])
        self.assertIsNotNone(newobj)
        self.assertIn(tag, newobj.get_tags())
示例#6
0
 def setUp(self):
     super().setUp()
     self.cube_right = self.add_object(shapes.cube(bid=(42, 0)), (9, 63, 4))
     self.cube_left = self.add_object(shapes.cube(), (9, 63, 10))
     self.set_looking_at(list(self.cube_right.blocks.keys())[0])
示例#7
0
 def setUp(self):
     super().setUp()
     self.cube_right: List[Block] = list(
         self.add_object(shapes.cube(bid=(42, 0)),
                         (9, 63, 4)).blocks.items())
     self.set_looking_at(self.cube_right[0][0])