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
0b306b57
Commit
0b306b57
authored
1 year ago
by
Fabian Heinrich
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' into 89-more-fov
parents
3a6ad1fc
a61fe9d0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!56
Resolve "More FOV"
Pipeline
#46092
passed
1 year ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
overcooked_simulator/overcooked_environment.py
+39
-3
39 additions, 3 deletions
overcooked_simulator/overcooked_environment.py
overcooked_simulator/player.py
+1
-13
1 addition, 13 deletions
overcooked_simulator/player.py
tests/test_start.py
+2
-2
2 additions, 2 deletions
tests/test_start.py
with
42 additions
and
18 deletions
overcooked_simulator/overcooked_environment.py
+
39
−
3
View file @
0b306b57
...
@@ -239,8 +239,6 @@ class Environment:
...
@@ -239,8 +239,6 @@ class Environment:
)
=
self
.
parse_layout_file
()
)
=
self
.
parse_layout_file
()
self
.
hook
(
LAYOUT_FILE_PARSED
)
self
.
hook
(
LAYOUT_FILE_PARSED
)
self
.
counter_positions
=
np
.
array
([
c
.
pos
for
c
in
self
.
counters
])
self
.
world_borders
=
np
.
array
(
self
.
world_borders
=
np
.
array
(
[[
-
0.5
,
self
.
kitchen_width
-
0.5
],
[
-
0.5
,
self
.
kitchen_height
-
0.5
]],
[[
-
0.5
,
self
.
kitchen_width
-
0.5
],
[
-
0.5
,
self
.
kitchen_height
-
0.5
]],
dtype
=
float
,
dtype
=
float
,
...
@@ -250,6 +248,9 @@ class Environment:
...
@@ -250,6 +248,9 @@ class Environment:
"
player_speed_units_per_seconds
"
"
player_speed_units_per_seconds
"
]
]
self
.
player_radius
=
self
.
environment_config
[
"
player_config
"
][
"
radius
"
]
self
.
player_radius
=
self
.
environment_config
[
"
player_config
"
][
"
radius
"
]
self
.
player_interaction_range
=
self
.
environment_config
[
"
player_config
"
][
"
interaction_range
"
]
progress_counter_classes
=
list
(
progress_counter_classes
=
list
(
filter
(
filter
(
...
@@ -269,6 +270,8 @@ class Environment:
...
@@ -269,6 +270,8 @@ class Environment:
)
)
"""
Counters that needs to be called in the step function via the `progress` method.
"""
"""
Counters that needs to be called in the step function via the `progress` method.
"""
self
.
counter_positions
=
np
.
array
([
c
.
pos
for
c
in
self
.
counters
])
self
.
order_and_score
.
create_init_orders
(
self
.
env_time
)
self
.
order_and_score
.
create_init_orders
(
self
.
env_time
)
self
.
start_time
=
self
.
env_time
self
.
start_time
=
self
.
env_time
"""
The relative env time when it started.
"""
"""
The relative env time when it started.
"""
...
@@ -290,6 +293,27 @@ class Environment:
...
@@ -290,6 +293,27 @@ class Environment:
env_start_time_worldtime
=
datetime
.
now
(),
env_start_time_worldtime
=
datetime
.
now
(),
)
)
def
overwrite_counters
(
self
,
counters
):
self
.
counters
=
counters
self
.
counter_positions
=
np
.
array
([
c
.
pos
for
c
in
self
.
counters
])
progress_counter_classes
=
list
(
filter
(
lambda
cl
:
hasattr
(
cl
,
"
progress
"
),
dict
(
inspect
.
getmembers
(
sys
.
modules
[
"
overcooked_simulator.counters
"
],
inspect
.
isclass
)
).
values
(),
)
)
self
.
progressing_counters
=
list
(
filter
(
lambda
c
:
c
.
__class__
in
progress_counter_classes
,
self
.
counters
,
)
)
@property
@property
def
game_ended
(
self
)
->
bool
:
def
game_ended
(
self
)
->
bool
:
"""
Whether the game is over or not based on the calculated `Environment.env_time_end`
"""
"""
Whether the game is over or not based on the calculated `Environment.env_time_end`
"""
...
@@ -666,9 +690,21 @@ class Environment:
...
@@ -666,9 +690,21 @@ class Environment:
for
idx
,
p
in
enumerate
(
self
.
players
.
values
()):
for
idx
,
p
in
enumerate
(
self
.
players
.
values
()):
if
not
(
new_positions
[
idx
]
==
player_positions
[
idx
]).
all
():
if
not
(
new_positions
[
idx
]
==
player_positions
[
idx
]).
all
():
p
.
move_abs
(
new_positions
[
idx
])
p
.
pos
=
new_positions
[
idx
]
p
.
perform_interact_stop
()
p
.
turn
(
player_movement_vectors
[
idx
])
p
.
turn
(
player_movement_vectors
[
idx
])
facing_distances
=
np
.
linalg
.
norm
(
p
.
facing_point
-
self
.
counter_positions
,
axis
=
1
)
closest_counter
=
self
.
counters
[
facing_distances
.
argmin
()]
p
.
current_nearest_counter
=
(
closest_counter
if
facing_distances
.
min
()
<=
self
.
player_interaction_range
else
None
)
def
add_player
(
self
,
player_name
:
str
,
pos
:
npt
.
NDArray
=
None
):
def
add_player
(
self
,
player_name
:
str
,
pos
:
npt
.
NDArray
=
None
):
"""
Add a player to the environment.
"""
Add a player to the environment.
...
...
This diff is collapsed.
Click to expand it.
overcooked_simulator/player.py
+
1
−
13
View file @
0b306b57
...
@@ -91,19 +91,7 @@ class Player:
...
@@ -91,19 +91,7 @@ class Player:
function of the environment
"""
function of the environment
"""
self
.
current_movement
=
move_vector
self
.
current_movement
=
move_vector
self
.
movement_until
=
move_until
self
.
movement_until
=
move_until
self
.
perform_interact_stop
()
def
move
(
self
,
movement
:
npt
.
NDArray
[
float
]):
"""
Moves the player position by the given movement vector.
A unit direction vector multiplied by move_dist is added to the player position.
Args:
movement: 2D-Vector of length 1
"""
if
self
.
interacting
and
np
.
any
(
movement
):
self
.
perform_interact_stop
()
self
.
pos
+=
movement
if
np
.
linalg
.
norm
(
movement
)
!=
0
:
self
.
turn
(
movement
)
def
move_abs
(
self
,
new_pos
:
npt
.
NDArray
[
float
]):
def
move_abs
(
self
,
new_pos
:
npt
.
NDArray
[
float
]):
"""
Overwrites the player location by the new_pos 2d-vector. Absolute movement.
"""
Overwrites the player location by the new_pos 2d-vector. Absolute movement.
...
...
This diff is collapsed.
Click to expand it.
tests/test_start.py
+
2
−
2
View file @
0b306b57
...
@@ -124,7 +124,7 @@ def test_player_reach(env_config, layout_empty_config, item_info):
...
@@ -124,7 +124,7 @@ def test_player_reach(env_config, layout_empty_config, item_info):
counter_pos
=
np
.
array
([
2
,
2
])
counter_pos
=
np
.
array
([
2
,
2
])
counter
=
Counter
(
pos
=
counter_pos
,
hook
=
Hooks
(
env
))
counter
=
Counter
(
pos
=
counter_pos
,
hook
=
Hooks
(
env
))
env
.
counters
=
[
counter
]
env
.
overwrite_
counters
(
[
counter
]
)
env
.
add_player
(
"
1
"
,
np
.
array
([
2
,
4
]))
env
.
add_player
(
"
1
"
,
np
.
array
([
2
,
4
]))
env
.
player_movement_speed
=
1
env
.
player_movement_speed
=
1
player
=
env
.
players
[
"
1
"
]
player
=
env
.
players
[
"
1
"
]
...
@@ -144,7 +144,7 @@ def test_pickup(env_config, layout_config, item_info):
...
@@ -144,7 +144,7 @@ def test_pickup(env_config, layout_config, item_info):
counter_pos
=
np
.
array
([
2
,
2
])
counter_pos
=
np
.
array
([
2
,
2
])
counter
=
Counter
(
pos
=
counter_pos
,
hook
=
Hooks
(
env
))
counter
=
Counter
(
pos
=
counter_pos
,
hook
=
Hooks
(
env
))
counter
.
occupied_by
=
Item
(
name
=
"
Tomato
"
,
item_info
=
None
)
counter
.
occupied_by
=
Item
(
name
=
"
Tomato
"
,
item_info
=
None
)
env
.
counters
=
[
counter
]
env
.
overwrite_
counters
(
[
counter
]
)
env
.
add_player
(
"
1
"
,
np
.
array
([
2
,
3
]))
env
.
add_player
(
"
1
"
,
np
.
array
([
2
,
3
]))
player
=
env
.
players
[
"
1
"
]
player
=
env
.
players
[
"
1
"
]
...
...
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