Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flatland
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
Model registry
Operate
Environments
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yoogottamk
Flatland
Commits
a0791a3f
Commit
a0791a3f
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
initial commit
parent
2c17b423
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
flatland/envs/rail_env.py
+28
-0
28 additions, 0 deletions
flatland/envs/rail_env.py
with
28 additions
and
0 deletions
flatland/envs/rail_env.py
+
28
−
0
View file @
a0791a3f
...
@@ -418,6 +418,34 @@ class RailEnv(Environment):
...
@@ -418,6 +418,34 @@ class RailEnv(Environment):
self
.
rail
.
width
=
self
.
width
self
.
rail
.
width
=
self
.
width
self
.
dones
=
dict
.
fromkeys
(
list
(
range
(
self
.
get_num_agents
()))
+
[
"
__all__
"
],
False
)
self
.
dones
=
dict
.
fromkeys
(
list
(
range
(
self
.
get_num_agents
()))
+
[
"
__all__
"
],
False
)
def
set_full_state_dist_msg
(
self
,
msg_data
):
data
=
msgpack
.
unpackb
(
msg_data
,
use_list
=
False
)
self
.
rail
.
grid
=
np
.
array
(
data
[
b
"
grid
"
])
# agents are always reset as not moving
self
.
agents_static
=
[
EnvAgentStatic
(
d
[
0
],
d
[
1
],
d
[
2
],
moving
=
False
)
for
d
in
data
[
b
"
agents_static
"
]]
self
.
agents
=
[
EnvAgent
(
d
[
0
],
d
[
1
],
d
[
2
],
d
[
3
],
d
[
4
])
for
d
in
data
[
b
"
agents
"
]]
# setup with loaded data
self
.
height
,
self
.
width
=
self
.
rail
.
grid
.
shape
self
.
rail
.
height
=
self
.
height
self
.
rail
.
width
=
self
.
width
self
.
dones
=
dict
.
fromkeys
(
list
(
range
(
self
.
get_num_agents
()))
+
[
"
__all__
"
],
False
)
def
get_full_state_dist_msg
(
self
):
grid_data
=
self
.
rail
.
grid
.
tolist
()
agent_static_data
=
[
agent
.
to_list
()
for
agent
in
self
.
agents_static
]
agent_data
=
[
agent
.
to_list
()
for
agent
in
self
.
agents
]
msgpack
.
packb
(
grid_data
)
msgpack
.
packb
(
agent_data
)
msgpack
.
packb
(
agent_static_data
)
msg_data
=
{
"
grid
"
:
grid_data
,
"
agents_static
"
:
agent_static_data
,
"
agents
"
:
agent_data
}
return
msgpack
.
packb
(
msg_data
,
use_bin_type
=
True
)
def
save
(
self
,
filename
):
def
save
(
self
,
filename
):
with
open
(
filename
,
"
wb
"
)
as
file_out
:
with
open
(
filename
,
"
wb
"
)
as
file_out
:
file_out
.
write
(
self
.
get_full_state_msg
())
file_out
.
write
(
self
.
get_full_state_msg
())
...
...
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