Skip to content

Commit 2625ba5

Browse files
author
Chris Elion
authored
remove obsolete code, offset worker seeds (#3645)
1 parent 8dae85a commit 2625ba5

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

docs/Python-API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ env = UnityEnvironment(file_name="3DBall", base_port=5005, seed=1, side_channels
6464
- `worker_id` indicates which port to use for communication with the
6565
environment. For use in parallel training regimes such as A3C.
6666
- `seed` indicates the seed to use when generating random numbers during the
67-
training process. In environments which do not involve physics calculations,
67+
training process. In environments which are deterministic,
6868
setting the seed enables reproducible experimentation by ensuring that the
6969
environment and trainers utilize the same random seed.
7070
- `side_channels` provides a way to exchange data with the Unity simulation that

ml-agents/mlagents/trainers/learn.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def create_environment_factory(
407407
env_path: Optional[str],
408408
docker_target_name: Optional[str],
409409
no_graphics: bool,
410-
seed: Optional[int],
410+
seed: int,
411411
start_port: int,
412412
env_args: Optional[List[str]],
413413
) -> Callable[[int, List[SideChannel]], BaseEnv]:
@@ -426,15 +426,12 @@ def create_environment_factory(
426426
# container.
427427
# Navigate in docker path and find env_path and copy it.
428428
env_path = prepare_for_docker_run(docker_target_name, env_path)
429-
seed_count = 10000
430-
seed_pool = [np.random.randint(0, seed_count) for _ in range(seed_count)]
431429

432430
def create_unity_environment(
433431
worker_id: int, side_channels: List[SideChannel]
434432
) -> UnityEnvironment:
435-
env_seed = seed
436-
if not env_seed:
437-
env_seed = seed_pool[worker_id % len(seed_pool)]
433+
# Make sure that each environment gets a different seed
434+
env_seed = seed + worker_id
438435
return UnityEnvironment(
439436
file_name=env_path,
440437
worker_id=worker_id,

0 commit comments

Comments
 (0)