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
64ca6836
Commit
64ca6836
authored
5 years ago
by
u214892
Browse files
Options
Downloads
Patches
Plain Diff
bugfix speeddate shared over all instances
parent
d2c0ce1c
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
+4
-2
4 additions, 2 deletions
flatland/envs/agent_utils.py
flatland/envs/rail_env.py
+2
-5
2 additions, 5 deletions
flatland/envs/rail_env.py
with
6 additions
and
7 deletions
flatland/envs/agent_utils.py
+
4
−
2
View file @
64ca6836
from
itertools
import
starmap
import
numpy
as
np
from
attr
import
attrs
,
attrib
from
attr
import
attrs
,
attrib
,
Factory
@attrs
...
...
@@ -18,7 +18,9 @@ class EnvAgentStatic(object):
# speed_data: speed is added to position_fraction on each moving step, until position_fraction>=1.0,
# after which 'transition_action_on_cellexit' is executed (equivalent to executing that action in the previous
# cell if speed=1, as default)
speed_data
=
attrib
(
default
=
dict
({
'
position_fraction
'
:
0.0
,
'
speed
'
:
1.0
,
'
transition_action_on_cellexit
'
:
0
}))
# N.B. we need to use factory since default arguments are not recreated on each call!
speed_data
=
attrib
(
default
=
Factory
(
lambda
:
dict
({
'
position_fraction
'
:
0.0
,
'
speed
'
:
1.0
,
'
transition_action_on_cellexit
'
:
0
})))
@classmethod
def
from_lists
(
cls
,
positions
,
directions
,
targets
,
speeds
=
None
):
...
...
This diff is collapsed.
Click to expand it.
flatland/envs/rail_env.py
+
2
−
5
View file @
64ca6836
...
...
@@ -12,8 +12,8 @@ import msgpack
import
numpy
as
np
from
flatland.core.env
import
Environment
from
flatland.envs.agent_utils
import
EnvAgentStatic
,
EnvAgent
from
flatland.core.grid.grid4_utils
import
get_new_position
from
flatland.envs.agent_utils
import
EnvAgentStatic
,
EnvAgent
from
flatland.envs.generators
import
random_rail_generator
from
flatland.envs.observations
import
TreeObsForRailEnv
...
...
@@ -196,7 +196,7 @@ class RailEnv(Environment):
for
iAgent
in
range
(
self
.
get_num_agents
()):
agent
=
self
.
agents
[
iAgent
]
if
iAgent
%
2
==
0
:
agent
.
speed_data
[
"
speed
"
]
=
1.
/
10.
agent
.
speed_data
[
"
speed
"
]
=
1.
/
10.
if
self
.
dones
[
iAgent
]:
# this agent has already completed...
continue
...
...
@@ -277,7 +277,6 @@ class RailEnv(Environment):
if
agent
.
speed_data
[
'
position_fraction
'
]
>=
1.0
:
# Perform stored action to transition to the next cell
# Now 'transition_action_on_cellexit' will be guaranteed to be valid; it was checked on entering
...
...
@@ -292,8 +291,6 @@ class RailEnv(Environment):
agent
.
direction
=
new_direction
agent
.
speed_data
[
'
position_fraction
'
]
=
0.0
if
np
.
equal
(
agent
.
position
,
agent
.
target
).
all
():
self
.
dones
[
iAgent
]
=
True
else
:
...
...
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