sprint
Her-darling 2 months ago
parent e8cdff3a43
commit a5a55c10b7

@ -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()

Loading…
Cancel
Save