找到simple_tag.py文件,在reset_world()函数中找到改语句
for i, landmark in enumerate(world.landmarks):
landmark.state.p_pos = np.random.uniform(-0.9, +0.9, world.dim_p)
landmark.state.p_vel = np.zeros(world.dim_p)`
这里是生成一个随机的初始坐标。将循环内的语句注释,改成下列(我设置的障碍物数量是3,所以设置3次)
for i, landmark in enumerate(world.landmarks):
if not landmark.boundary:
if i == 0:
landmark.state.p_pos = np.array([-0.6,0.65])
landmark.state.p_vel = np.zeros(world.dim_p)
if i == 1:
landmark.state.p_pos = np.array([0.5,0.45])
landmark.state.p_vel = np.zeros(world.dim_p)
if i == 2:
landmark.state.p_pos = np.array([0.2,-0.6])
landmark.state.p_vel = np.zeros(world.dim_p)
np.array([-0.6,0.65])中的值为障碍物的 x, y 的坐标值,在-1~1之间,坐标的设定规则见下图:
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删