Commit 3b2c6a3d authored by J. Fernando Sánchez's avatar J. Fernando Sánchez
Browse files

Seed before env initialization

Fixes #6
parent 6118f917
Pipeline #3601 canceled with stage
in 1 minute and 34 seconds
......@@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.14.9]
### Changed
* Seed random before environment initialization
## [0.14.8]
### Fixed
* Invalid directory names in Windows gsi-upm/soil#5
......
0.14.8
\ No newline at end of file
0.14.9
\ No newline at end of file
......@@ -44,6 +44,8 @@ class Environment(nxsim.NetworkEnvironment):
topology=None,
*args, **kwargs):
self.name = name or 'UnnamedEnvironment'
seed = seed or time.time()
random.seed(seed)
if isinstance(states, list):
states = dict(enumerate(states))
self.states = deepcopy(states) if states else {}
......@@ -55,12 +57,11 @@ class Environment(nxsim.NetworkEnvironment):
self.interval = interval
self._history = history.History(name=self.name,
backup=True)
self['SEED'] = seed
# Add environment agents first, so their events get
# executed before network agents
self.environment_agents = environment_agents or []
self.network_agents = network_agents or []
self['SEED'] = seed or time.time()
random.seed(self['SEED'])
@property
def agents(self):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment