Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Cooperative Cuisine Environment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Social Cognitive Systems
CoCoSy
Cooperative Cuisine Environment
Commits
67bd4e81
Commit
67bd4e81
authored
6 months ago
by
Fabian Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
removed unused return value
parent
f0f3eb38
No related branches found
No related tags found
2 merge requests
!110
V1.2.0 changes
,
!104
Resolve "Faster Drawing"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cooperative_cuisine/movement.py
+8
-9
8 additions, 9 deletions
cooperative_cuisine/movement.py
with
8 additions
and
9 deletions
cooperative_cuisine/movement.py
+
8
−
9
View file @
67bd4e81
...
...
@@ -107,25 +107,25 @@ class Movement:
def
get_player_push
(
self
,
player_positions
:
npt
.
NDArray
[
float
]
)
->
Tuple
[
npt
.
NDArray
[
bool
],
npt
.
NDArray
[
float
]
]
:
)
->
npt
.
NDArray
[
float
]:
"""
Calculates the collision and push vectors for each player.
Args:
player_positions (numpy.ndarray): An array of shape (n, 2) representing the positions of the players.
Returns:
tuple: A tuple containing two numpy arrays. The first array (collisions) is a boolean array of shape (n,) indicating
whether each player has collided with another player. The second array (push_vectors) is a numpy array of shape (2,)
Array (push_vectors) is a numpy array of shape (2,)
representing the total push vector for each player.
"""
distances_players_after_scipy
=
distance_matrix
(
distances_players_after
=
distance_matrix
(
player_positions
,
player_positions
)
collisions
=
distances_players_after
<
2
*
self
.
player_radius
player_diff_vecs
=
-
(
player_positions
[:,
np
.
newaxis
,
:]
-
player_positions
[
np
.
newaxis
,
:,
:]
)
collisions
=
distances_players_after_scipy
<
(
2
*
self
.
player_radius
)
eye_idxs
=
np
.
eye
(
len
(
player_positions
),
len
(
player_positions
),
dtype
=
bool
)
collisions
[
eye_idxs
]
=
False
if
np
.
any
(
collisions
):
...
...
@@ -135,8 +135,7 @@ class Movement:
)
player_diff_vecs
[
collisions
==
False
]
=
0
push_vectors
=
np
.
sum
(
player_diff_vecs
,
axis
=
0
)
collisions
=
np
.
any
(
collisions
,
axis
=
1
)
return
collisions
,
push_vectors
return
push_vectors
def
perform_movement
(
self
,
...
...
@@ -181,13 +180,13 @@ class Movement:
# Collisions player between player
force_factor
=
1.2
_
,
push_vectors
=
self
.
get_player_push
(
targeted_positions
)
push_vectors
=
self
.
get_player_push
(
targeted_positions
)
updated_movement
=
(
force_factor
*
push_vectors
)
+
player_movement_vectors
new_targeted_positions
=
player_positions
+
(
updated_movement
*
(
self
.
player_movement_speed
*
d_time
)
)
# same again to prevent squeezing into other players
_
,
push_vectors2
=
self
.
get_player_push
(
new_targeted_positions
)
push_vectors2
=
self
.
get_player_push
(
new_targeted_positions
)
updated_movement
=
(
force_factor
*
push_vectors2
)
+
updated_movement
new_targeted_positions
=
player_positions
+
(
updated_movement
*
(
self
.
player_movement_speed
*
d_time
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment