Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
marl-flatland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
manavsinghal157
marl-flatland
Commits
98d00d0b
Commit
98d00d0b
authored
4 years ago
by
Egli Adrian (IT-SCI-API-PFI)
Browse files
Options
Downloads
Patches
Plain Diff
.
parent
42713083
No related branches found
Branches containing commit
Tags
submission-v0.5
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/extra.py
+5
-1
5 additions, 1 deletion
src/extra.py
src/observations.py
+5
-0
5 additions, 0 deletions
src/observations.py
with
10 additions
and
1 deletion
src/extra.py
+
5
−
1
View file @
98d00d0b
...
@@ -3,7 +3,6 @@ from flatland.core.grid.grid4_utils import get_new_position
...
@@ -3,7 +3,6 @@ from flatland.core.grid.grid4_utils import get_new_position
from
flatland.envs.agent_utils
import
RailAgentStatus
from
flatland.envs.agent_utils
import
RailAgentStatus
from
flatland.envs.rail_env
import
RailEnv
from
flatland.envs.rail_env
import
RailEnv
from
flatland.envs.rail_env
import
RailEnvActions
from
flatland.envs.rail_env
import
RailEnvActions
from
flatland.utils.rendertools
import
RenderTool
,
AgentRenderVariant
from
src.agent.dueling_double_dqn
import
Agent
from
src.agent.dueling_double_dqn
import
Agent
from
src.observations
import
normalize_observation
from
src.observations
import
normalize_observation
...
@@ -150,6 +149,7 @@ class Extra:
...
@@ -150,6 +149,7 @@ class Extra:
position
=
self
.
env
.
agents
[
a
].
initial_position
position
=
self
.
env
.
agents
[
a
].
initial_position
first_step
=
True
first_step
=
True
direction
=
self
.
env
.
agents
[
a
].
direction
direction
=
self
.
env
.
agents
[
a
].
direction
cnt
=
0
while
position
is
not
None
:
# and position != self.env.agents[a].target:
while
position
is
not
None
:
# and position != self.env.agents[a].target:
possible_transitions
=
self
.
env
.
rail
.
get_transitions
(
*
position
,
direction
)
possible_transitions
=
self
.
env
.
rail
.
get_transitions
(
*
position
,
direction
)
# num_transitions = np.count_nonzero(possible_transitions)
# num_transitions = np.count_nonzero(possible_transitions)
...
@@ -200,6 +200,10 @@ class Extra:
...
@@ -200,6 +200,10 @@ class Extra:
else
:
else
:
position
=
None
position
=
None
cnt
+=
1
if
cnt
>
100
:
position
=
None
return
agents_with_deadlock
return
agents_with_deadlock
def
generate_state
(
self
,
handle
:
int
,
root
,
max_depth
:
int
):
def
generate_state
(
self
,
handle
:
int
,
root
,
max_depth
:
int
):
...
...
This diff is collapsed.
Click to expand it.
src/observations.py
+
5
−
0
View file @
98d00d0b
...
@@ -264,6 +264,7 @@ class MyTreeObsForRailEnv(ObservationBuilder):
...
@@ -264,6 +264,7 @@ class MyTreeObsForRailEnv(ObservationBuilder):
last_is_a_decision_cell
=
False
last_is_a_decision_cell
=
False
target_encountered
=
0
target_encountered
=
0
cnt
=
0
while
exploring
:
while
exploring
:
dist_min_to_target
=
min
(
dist_min_to_target
,
self
.
env
.
distance_map
.
get
()[
handle
,
position
[
0
],
position
[
1
],
dist_min_to_target
=
min
(
dist_min_to_target
,
self
.
env
.
distance_map
.
get
()[
handle
,
position
[
0
],
position
[
1
],
...
@@ -327,6 +328,10 @@ class MyTreeObsForRailEnv(ObservationBuilder):
...
@@ -327,6 +328,10 @@ class MyTreeObsForRailEnv(ObservationBuilder):
direction
=
np
.
argmax
(
cell_transitions
)
direction
=
np
.
argmax
(
cell_transitions
)
position
=
get_new_position
(
position
,
direction
)
position
=
get_new_position
(
position
,
direction
)
cnt
+=
1
if
cnt
>
1000
:
exploring
=
False
# #############################
# #############################
# #############################
# #############################
# Modify here to append new / different features for each visited cell!
# Modify here to append new / different features for each visited cell!
...
...
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