diff --git a/pyAmakCore/classes/environment.py b/pyAmakCore/classes/environment.py index b811398e0659b7d460003f7ff86007c08f9dedf7..2b4aa0ad4e31f3917594c93edd214f5488d13053 100644 --- a/pyAmakCore/classes/environment.py +++ b/pyAmakCore/classes/environment.py @@ -16,14 +16,16 @@ class Environment(Schedulable): Environment class """ - def __init__(self) -> None: - self.set_seed() + def __init__(self, seed_int: int = None) -> None: + self.set_seed(seed_int) super().__init__() self.on_initialization() - def set_seed(self): + def set_seed(self, number): """ This method set the seed for all random in the system, it should be override to set a custom seed """ - seed() - + if number is None: + seed() + return + seed(number) diff --git a/pyAmakCore/tests/seed/main.py b/pyAmakCore/tests/seed/main.py deleted file mode 100644 index 6a8163203a1d4307096fc4f39a64c34d51918745..0000000000000000000000000000000000000000 --- a/pyAmakCore/tests/seed/main.py +++ /dev/null @@ -1,54 +0,0 @@ -from random import randint, seed -from time import sleep - -from pyAmakCore.classes.amas import Amas -from pyAmakCore.classes.environment import Environment -from pyAmakCore.classes.agent import Agent -from pyAmakCore.exception.override import ToOverrideWarning - - -class SimpleAgent(Agent): - """ - test - """ - def on_act(self) -> None: - print(randint(0, 100)) - - - -class SimpleAmas(Amas): - """ - test - """ - - def on_initialization(self) -> None: - ToOverrideWarning.enable_warning(False) - - def on_initial_agents_creation(self) -> None: - for i in range(10): - self.add_agent(SimpleAgent(self)) - - def on_cycle_begin(self) -> None: - pass - # print(randint(0, 100)) - - def on_cycle_end(self) -> None: - if self.get_cycle() == 30: - sleep(300) - - -class SimpleEnv(Environment): - """ - test - """ - - def set_seed(self): - seed(30) - - -env = SimpleEnv() -amas = SimpleAmas(env) - -amas.put_token() - -amas.start()