|
|
|
@ -280,23 +280,13 @@ class sprint(gym.Env):
|
|
|
|
|
self.player.terminate()
|
|
|
|
|
|
|
|
|
|
def change_target(self):
|
|
|
|
|
original_angle = self.walk_rel_orientation
|
|
|
|
|
|
|
|
|
|
# 生成一个 -10 到 +10 度之间的随机角度
|
|
|
|
|
orientations = random.choice([-1, 1])
|
|
|
|
|
random_angle_delta = orientations * np.random.uniform(45, 60) # 单位是度
|
|
|
|
|
random_target = orientations * 10 # 单位是度
|
|
|
|
|
|
|
|
|
|
# 新的角度
|
|
|
|
|
new_angle = original_angle + np.radians(random_angle_delta) # 转换为弧度
|
|
|
|
|
self.walk_rel_target = (15, random_target)
|
|
|
|
|
|
|
|
|
|
# 计算新的目标向量,保持原来的距离不变
|
|
|
|
|
new_walk_rel_target = np.array([
|
|
|
|
|
np.cos(new_angle) * self.walk_distance * 2,
|
|
|
|
|
np.sin(new_angle) * self.walk_distance * 5
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
# 保存新的目标向量
|
|
|
|
|
self.walk_rel_target = new_walk_rel_target
|
|
|
|
|
def step(self, action):
|
|
|
|
|
|
|
|
|
|
r = (self.
|
|
|
|
|