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
sfwatergit
Flatland
Commits
4ab8dbe4
Commit
4ab8dbe4
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of gitlab.aicrowd.com:flatland/flatland
parents
54953851
d0bb6d8f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flatland/envs/agent_utils.py
+13
-1
13 additions, 1 deletion
flatland/envs/agent_utils.py
flatland/envs/rail_env.py
+5
-0
5 additions, 0 deletions
flatland/envs/rail_env.py
with
18 additions
and
1 deletion
flatland/envs/agent_utils.py
+
13
−
1
View file @
4ab8dbe4
from
attr
import
attrs
,
attrib
from
itertools
import
starmap
import
numpy
as
np
# from flatland.envs.rail_env import RailEnv
...
...
@@ -36,7 +37,18 @@ class EnvAgentStatic(object):
return
list
(
starmap
(
EnvAgentStatic
,
zip
(
positions
,
directions
,
targets
)))
def
to_list
(
self
):
return
[
self
.
position
,
self
.
direction
,
self
.
target
]
# I can't find an expression which works on both tuples, lists and ndarrays
# which converts them all to a list of native python ints.
lPos
=
self
.
position
if
type
(
lPos
)
is
np
.
ndarray
:
lPos
=
lPos
.
tolist
()
lTarget
=
self
.
target
if
type
(
lTarget
)
is
np
.
ndarray
:
lTarget
=
lTarget
.
tolist
()
return
[
lPos
,
int
(
self
.
direction
),
lTarget
]
@attrs
...
...
This diff is collapsed.
Click to expand it.
flatland/envs/rail_env.py
+
5
−
0
View file @
4ab8dbe4
...
...
@@ -329,6 +329,11 @@ class RailEnv(Environment):
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
,
...
...
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