1
0
mirror of https://github.com/gsi-upm/soil synced 2024-11-13 06:52:28 +00:00

Seed before env initialization

Fixes #6
This commit is contained in:
J. Fernando Sánchez 2020-07-27 11:49:04 +02:00
parent 6118f917ee
commit 3b2c6a3db5
3 changed files with 7 additions and 3 deletions

View File

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

View File

@ -1 +1 @@
0.14.8
0.14.9

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