From a5a55c10b7df7e400265101d4dbe292a83098412 Mon Sep 17 00:00:00 2001 From: MagDish <2717360869@qq.com> Date: Wed, 13 Nov 2024 19:56:15 +0800 Subject: [PATCH] new --- scripts/gyms/sprint.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/gyms/sprint.py b/scripts/gyms/sprint.py index 3de0924..1d1b0c1 100644 --- a/scripts/gyms/sprint.py +++ b/scripts/gyms/sprint.py @@ -286,7 +286,11 @@ class sprint(gym.Env): x = np.random.uniform(x_range[0], x_range[1]) y = np.random.uniform(y_range[0], y_range[1]) - + if np.linalg.norm(np.array([x, y]) - self.Gen_player_pos[:2]) < 5: + dir_x = (x - self.Gen_player_pos[0]) / abs (x - self.Gen_player_pos[0]) + dir_y = (y - self.Gen_player_pos[1]) / abs (y - self.Gen_player_pos[1]) + x = x + 5 * dir_x + y = y + 5 * dir_y self.walk_target = np.array([x, y]) def step(self, action): @@ -336,7 +340,7 @@ class sprint(gym.Env): robot_speed = r.loc_torso_velocity[0] direction_error = abs(self.walk_rel_orientation) direction_error = min(direction_error, 10) - reward = robot_speed * (3 - 0.5 * direction_error / 10) + reward = robot_speed * (1.5 - direction_error / 10) if self.walk_distance < 1: reward += 20 self.generate_random_target()