training.py 文件源码

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

项目:relaax 作者: deeplearninc 项目源码 文件源码
def _init_random_maze(self):
        # init goal position
        goal = np.zeros_like(self._level)
        while True:
            row_idx = np.random.randint(0, self._level.shape[0])
            col_idx = np.random.randint(0, self._level.shape[1])
            if self._level[row_idx, col_idx] == 0:
                goal[row_idx, col_idx] = 1
                self._goal_pos = np.array([row_idx, col_idx])
                break

        # init player position
        player = np.zeros_like(self._level)
        while True:
            row_idx = np.random.randint(0, self._level.shape[0])
            col_idx = np.random.randint(0, self._level.shape[1])
            if self._level[row_idx, col_idx] == 0 and goal[row_idx, col_idx] == 0:
                player[row_idx, col_idx] = 1
                self._player_pos = np.array([row_idx, col_idx])
                break

        # stack all together in depth (along third axis)
        self._maze = np.dstack((self._level, goal, player))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号