Skip to content
Snippets Groups Projects
Commit 0d59ed25 authored by Fabian Heinrich's avatar Fabian Heinrich
Browse files

Small simplifications

parent b29e3a41
No related branches found
No related tags found
1 merge request!44Resolve "GUI Player Management"
Pipeline #45512 failed
...@@ -414,6 +414,7 @@ class Environment: ...@@ -414,6 +414,7 @@ class Environment:
], ],
dtype=float, dtype=float,
) )
number_players = len(player_positions)
targeted_positions = player_positions + ( targeted_positions = player_positions + (
player_movement_vectors * (self.player_movement_speed * d_time) player_movement_vectors * (self.player_movement_speed * d_time)
...@@ -428,11 +429,7 @@ class Environment: ...@@ -428,11 +429,7 @@ class Environment:
player_positions[:, np.newaxis, :] - player_positions[np.newaxis, :, :] player_positions[:, np.newaxis, :] - player_positions[np.newaxis, :, :]
) )
collision_idxs = distances_players_after_scipy < (2 * self.player_radius) collision_idxs = distances_players_after_scipy < (2 * self.player_radius)
eye_idxs = np.eye( eye_idxs = np.eye(number_players, number_players, dtype=bool)
distances_players_after_scipy.shape[0],
distances_players_after_scipy.shape[1],
dtype=bool,
)
collision_idxs[eye_idxs] = False collision_idxs[eye_idxs] = False
# Player push players around # Player push players around
...@@ -497,8 +494,10 @@ class Environment: ...@@ -497,8 +494,10 @@ class Environment:
new_positions[collision_idxs] = player_positions[collision_idxs] new_positions[collision_idxs] = player_positions[collision_idxs]
# Collisions player world borders # Collisions player world borders
new_positions = np.max( new_positions = np.clip(
[new_positions, self.world_borders_lower + self.player_radius], axis=0 new_positions,
self.world_borders_lower + self.player_radius,
self.world_borders_upper - self.player_radius,
) )
new_positions = np.min( new_positions = np.min(
[new_positions, self.world_borders_upper - self.player_radius], axis=0 [new_positions, self.world_borders_upper - self.player_radius], axis=0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment