two_room_domain.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:rl_algorithms 作者: DanielTakeshi 项目源码 文件源码
def _init_grid(self):
        """ Initializes the grid. Currently works best for multiples of 3 which
        are also odd. For now let's only test on 9x9 grids. """

        self.grid.fill(OPEN)
        w1 = np.maximum((self.length/3), 1)
        w2 = np.minimum(2*(self.length/3), self.length)
        self.grid[:, w1:w2].fill(WALL)
        self.grid[self.length/2, :].fill(OPEN)

        sx = np.random.randint(0, self.length)
        sy = np.random.randint(0, w1)
        gx = np.random.randint(0, self.length)
        gy = np.random.randint(w2, self.length)
        s_agent = (sx,sy)
        s_goal = (gx,gy)

        assert s_agent != s_goal
        assert self.grid[s_agent] != WALL
        assert self.grid[s_goal] != WALL
        self.grid[s_agent] = AGENT
        self.grid[s_goal] = GOAL
        s_start = s_agent
        return s_start, s_agent, s_goal
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号