def link()

in rtfm/dynamics/world_object.py [0:0]


    def link(self, another, world):
        path = self.get_path_to(another, world, ignore={Wall})
        if path is None:
            raise Exception('Path link error from {} to {}\nWorld\n{}'.format(self.position, another.position, world.render(' ')))
        path = path[1:-1]
        path_nodes = set(path)
        for x, y in path:
            # put some walls
            candidates = [(x-1, y), (x+1, y), (x, y-1), (x, y+1)]
            for pos in candidates:
                xc, yc = pos
                if pos not in path_nodes and 0 <= xc and 0 <= yc:
                    if world.is_empty_at(pos):
                        Wall().place(pos, world)