added env variable to overwrite seeding seed when in competition mode

This commit is contained in:
Joel Klimont 2022-11-11 17:47:40 +01:00
parent 765336231b
commit be9a5c9f19
2 changed files with 11 additions and 3 deletions

View file

@ -19,6 +19,7 @@ pip install sphinx-rtd-theme
+ `DEBUG`, default="0", If set to != "0" (default), debug prints will be enabled
+ `API_URL`, default="http://localhost:5000/"
+ `API_FORCE`, default="", if set to !="" (default), it will replace the API_URL env variable
+ `FORCE_SEED`, default="-1", if set to !="-1" (default), the seeding seed supplied by the user will be ignored and this seed will be used instead
# Stream Video

View file

@ -1,8 +1,10 @@
import logging
import os
import numpy as np
# TODO: if set to competition mode, get the seed from the api
FORCE_SEED = int(os.getenv("FORCE_SEED", "-1"))
logger = logging.getLogger("complib-logger")
@ -32,9 +34,14 @@ Logistic Centers: {self.logistic_center}"""
:param seed: Seed welcher zum Erstellen des Gamestates benutzt werden soll.
"""
logger.debug(f"Creating gamestate with seed: {seed}")
self.seed = seed
self.__set_random_seed(seed)
if FORCE_SEED == -1:
self.seed = seed
else:
print(f"Wettkampfmodus, zufälliger Seed wird verwendet: Seed={FORCE_SEED}")
self.seed = FORCE_SEED
logger.debug(f"Creating gamestate with seed: {self.seed}")
self.__set_random_seed(self.seed)
self.heu_color = self.__get_random_number(1, 2)