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
pranjal_dhole
Flatland
Commits
f56bea42
Commit
f56bea42
authored
3 years ago
by
mmarti
Browse files
Options
Downloads
Patches
Plain Diff
removed some whitespace
parent
3393af8b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
flatland/contrib/wrappers/flatland_wrappers.py
+1
-8
1 addition, 8 deletions
flatland/contrib/wrappers/flatland_wrappers.py
with
1 addition
and
8 deletions
flatland/contrib/wrappers/flatland_wrappers.py
+
1
−
8
View file @
f56bea42
...
...
@@ -13,7 +13,6 @@ from flatland.envs.rail_env import RailEnv, RailEnvActions
def
possible_actions_sorted_by_distance
(
env
:
RailEnv
,
handle
:
int
):
agent
=
env
.
agents
[
handle
]
if
agent
.
state
==
TrainState
.
READY_TO_DEPART
:
agent_virtual_position
=
agent
.
initial_position
elif
agent
.
state
.
is_on_map_state
():
...
...
@@ -153,7 +152,6 @@ def find_all_cells_where_agent_can_choose(env: RailEnv):
directions
=
list
(
range
(
4
))
for
h
in
range
(
env
.
height
):
for
w
in
range
(
env
.
width
):
pos
=
(
h
,
w
)
is_switch
=
False
...
...
@@ -176,9 +174,7 @@ def find_all_cells_where_agent_can_choose(env: RailEnv):
decision_cells
=
switches
+
switches_neighbors
return
tuple
(
map
(
set
,
(
switches
,
switches_neighbors
,
decision_cells
)))
class
SkipNoChoiceCellsWrapper
(
RailEnvWrapper
):
# env can be a real RailEnv, or anything that shares the same interface
...
...
@@ -206,15 +202,13 @@ class SkipNoChoiceCellsWrapper(RailEnvWrapper):
def
next_to_switch
(
self
,
agent
:
EnvAgent
)
->
bool
:
return
agent
.
position
in
self
.
switches_neighbors
def
reset_cells
(
self
)
->
None
:
self
.
switches
,
self
.
switches_neighbors
,
self
.
decision_cells
=
find_all_cells_where_agent_can_choose
(
self
.
env
)
def
step
(
self
,
action_dict
:
Dict
[
int
,
RailEnvActions
])
->
Tuple
[
Dict
,
Dict
,
Dict
,
Dict
]:
o
,
r
,
d
,
i
=
{},
{},
{},
{}
#
NEED TO INITIALIZE
i["..."]
#
need to initialize
i["..."]
# as we will access i["..."][agent_id]
i
[
"
action_required
"
]
=
dict
()
i
[
"
malfunction
"
]
=
dict
()
...
...
@@ -255,7 +249,6 @@ class SkipNoChoiceCellsWrapper(RailEnvWrapper):
return
o
,
r
,
d
,
i
def
reset
(
self
,
**
kwargs
)
->
Tuple
[
Dict
,
Dict
]:
obs
,
info
=
self
.
env
.
reset
(
**
kwargs
)
# resets decision cells, switches, etc. These can change with an env.reset(...)!
...
...
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