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
4fcb40b3
Commit
4fcb40b3
authored
1 year ago
by
Fabian Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
Added viz for tomatoes and cutting process.
parent
c509030b
No related branches found
No related tags found
1 merge request
!3
Resolve "Interaction with objects"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
overcooked_simulator/images/tomato_cut.png
+0
-0
0 additions, 0 deletions
overcooked_simulator/images/tomato_cut.png
overcooked_simulator/pygame_gui.py
+40
-3
40 additions, 3 deletions
overcooked_simulator/pygame_gui.py
tests/test_start.py
+1
-1
1 addition, 1 deletion
tests/test_start.py
with
41 additions
and
4 deletions
overcooked_simulator/images/tomato_cut.png
0 → 100644
+
0
−
0
View file @
4fcb40b3
16.7 KiB
This diff is collapsed.
Click to expand it.
overcooked_simulator/pygame_gui.py
+
40
−
3
View file @
4fcb40b3
import
numpy
as
np
import
pygame
from
overcooked_simulator.counters
import
CuttingBoard
from
overcooked_simulator.game_items
import
ProgressibleItem
from
overcooked_simulator.game_items
import
Tomato
from
overcooked_simulator.overcooked_environment
import
Action
from
overcooked_simulator.simulation_runner
import
Simulator
...
...
@@ -16,6 +18,7 @@ BLUE = (0, 0, 255)
YELLOW
=
(
255
,
255
,
0
)
BACKGROUND_COLOR
=
GREY
BACKGROUND_LINES_COLOR
=
(
200
,
200
,
200
)
KNIFE_COLOR
=
(
120
,
120
,
120
)
class
PlayerKeyset
:
...
...
@@ -160,12 +163,31 @@ class PyGameGUI:
def
draw_item
(
self
,
pos
,
item
):
"""
Visualisation of an item at the specified position. On a counter or in the hands of the player.
"""
if
isinstance
(
item
,
Tomato
):
IMAGE
=
pygame
.
image
.
load
(
"
overcooked_simulator/images/tomato.png
"
).
convert_alpha
()
# or .convert_alpha()
if
item
.
finished
:
IMAGE
=
pygame
.
image
.
load
(
"
overcooked_simulator/images/tomato_cut.png
"
).
convert_alpha
()
# or .convert_alpha()
else
:
IMAGE
=
pygame
.
image
.
load
(
"
overcooked_simulator/images/tomato.png
"
).
convert_alpha
()
# or .convert_alpha()
rect
=
IMAGE
.
get_rect
()
rect
.
center
=
pos
self
.
screen
.
blit
(
IMAGE
,
rect
)
if
isinstance
(
item
,
ProgressibleItem
)
and
not
item
.
finished
:
self
.
draw_progress_bar
(
pos
,
item
.
progressed_steps
,
item
.
steps_needed
)
def
draw_progress_bar
(
self
,
pos
,
current
,
needed
):
if
current
!=
0
:
bar_height
=
self
.
counter_size
*
0.2
progress_width
=
(
current
/
needed
)
*
self
.
counter_size
progress_bar
=
pygame
.
Rect
(
pos
[
0
]
-
(
self
.
counter_size
/
2
),
pos
[
1
]
-
(
self
.
counter_size
/
2
)
+
self
.
counter_size
-
bar_height
,
progress_width
,
bar_height
,
)
pygame
.
draw
.
rect
(
self
.
screen
,
GREEN
,
progress_bar
)
def
draw_counter
(
self
,
counter
):
"""
Visualisation of a counter at its position. If it is occupied by an item, it is also shown.
...
...
@@ -173,6 +195,7 @@ class PyGameGUI:
Args:
counter: The counter to visualize.
"""
counter_rect_outline
=
pygame
.
Rect
(
counter
.
pos
[
0
]
-
(
self
.
counter_size
/
2
),
counter
.
pos
[
1
]
-
(
self
.
counter_size
/
2
),
...
...
@@ -181,6 +204,20 @@ class PyGameGUI:
)
pygame
.
draw
.
rect
(
self
.
screen
,
COUNTERCOLOR
,
counter_rect_outline
)
if
isinstance
(
counter
,
CuttingBoard
):
board_size
=
30
board_rect
=
pygame
.
Rect
(
counter
.
pos
[
0
]
-
(
board_size
/
2
),
counter
.
pos
[
1
]
-
(
board_size
/
2
),
board_size
,
board_size
,
)
BOARD_COLOR
=
(
239
,
193
,
151
)
pygame
.
draw
.
rect
(
self
.
screen
,
BOARD_COLOR
,
board_rect
)
knife_rect
=
pygame
.
Rect
(
counter
.
pos
[
0
]
+
6
,
counter
.
pos
[
1
]
-
8
,
5
,
20
)
pygame
.
draw
.
rect
(
self
.
screen
,
KNIFE_COLOR
,
knife_rect
)
if
counter
.
occupied_by
is
not
None
:
self
.
draw_item
(
counter
.
pos
,
counter
.
occupied_by
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_start.py
+
1
−
1
View file @
4fcb40b3
...
...
@@ -77,7 +77,7 @@ def test_movement():
expected
=
start_pos
+
do_moves_number
*
(
move_direction
*
player1
.
move_dist
)
assert
(
np
.
linalg
.
norm
(
expected
-
sim
.
env
.
players
[
player_name
].
pos
)
==
0
np
.
linalg
.
norm
(
expected
-
sim
.
env
.
players
[
player_name
].
pos
)
==
0
),
"
Should be here?
"
...
...
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