Seed before env initialization

Fixes #6
pull/7/head 0.14.9
J. Fernando Sánchez 4 years ago
parent 6118f917ee
commit 3b2c6a3db5

@ -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

@ -1 +1 @@
0.14.8
0.14.9

@ -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):

Loading…
Cancel
Save