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
67fed26e
Commit
67fed26e
authored
1 year ago
by
Fabian Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
Get state image as np array
parent
a0ff8b34
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!52
Resolve "gym env"
Pipeline
#45659
passed
1 year ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
overcooked_simulator/gui_2d_vis/drawing.py
+18
-1
18 additions, 1 deletion
overcooked_simulator/gui_2d_vis/drawing.py
with
18 additions
and
1 deletion
overcooked_simulator/gui_2d_vis/drawing.py
+
18
−
1
View file @
67fed26e
...
...
@@ -399,6 +399,8 @@ class Visualizer:
if
"
center_offset
"
in
part
:
d
=
pygame
.
math
.
Vector2
(
part
[
"
center_offset
"
])
*
grid_size
d
.
rotate_ip
(
angle_offset
)
d
[
0
]
=
-
d
[
0
]
draw_pos
+=
np
.
array
(
d
)
height
=
part
[
"
height
"
]
*
grid_size
width
=
part
[
"
width
"
]
*
grid_size
...
...
@@ -805,9 +807,24 @@ class Visualizer:
flags
=
pygame
.
HIDDEN
screen
=
pygame
.
display
.
set_mode
((
width
,
height
),
flags
=
flags
)
self
.
draw_gamescreen
(
screen
,
state
,
grid_size
)
self
.
draw_gamescreen
(
screen
,
state
,
grid_size
,
[
0
for
_
in
state
[
"
players
"
]]
)
pygame
.
image
.
save
(
screen
,
filename
)
def
get_state_image
(
self
,
grid_size
:
int
,
state
:
dict
)
->
npt
.
NDArray
[
np
.
uint8
]:
width
=
int
(
np
.
ceil
(
state
[
"
kitchen
"
][
"
width
"
]
*
grid_size
))
height
=
int
(
np
.
ceil
(
state
[
"
kitchen
"
][
"
height
"
]
*
grid_size
))
flags
=
pygame
.
HIDDEN
screen
=
pygame
.
display
.
set_mode
((
width
,
height
),
flags
=
flags
)
self
.
draw_gamescreen
(
screen
,
state
,
grid_size
,
[
0
for
_
in
state
[
"
players
"
]])
red
=
pygame
.
surfarray
.
array_red
(
screen
)
green
=
pygame
.
surfarray
.
array_green
(
screen
)
blue
=
pygame
.
surfarray
.
array_blue
(
screen
)
res
=
np
.
stack
([
red
,
green
,
blue
],
axis
=
2
)
return
res
def
save_screenshot
(
state
:
dict
,
config
:
dict
,
filename
:
str
|
Path
)
->
None
:
"""
Standalone function to save a screenshot. Creates a visualizer from the config and visualizes
...
...
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