Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Flatland
Flatland
Commits
f56bea42
Commit
f56bea42
authored
Oct 12, 2021
by
mmarti
Browse files
removed some whitespace
parent
3393af8b
Pipeline
#8734
failed with stages
in 5 minutes and 52 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
flatland/contrib/wrappers/flatland_wrappers.py
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(...)!
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment