|
|
@@ -6,16 +6,19 @@ class LightSampler:
|
|
|
"""
|
|
|
根据一天中的时间,以概率方式为光照设置生成下一个状态。
|
|
|
"""
|
|
|
- def __init__(self, light_ids: list, light_period_start: datetime.time = None, light_period_end: datetime.time = None):
|
|
|
+ def __init__(self, light_ids: list, light_period_start: datetime.time = None, light_period_end: datetime.time = None, seed: int = 42):
|
|
|
"""
|
|
|
初始化采样器。
|
|
|
:param light_ids: 此采样器应为其生成状态的所有灯光的ID列表。
|
|
|
:param light_period_start: 光周期的开始时间 (datetime.time object)。
|
|
|
:param light_period_end: 光周期的结束时间 (datetime.time object)。
|
|
|
+ :param seed: 可选的随机种子,用于确保采样的可重现性。
|
|
|
"""
|
|
|
self.light_ids = light_ids
|
|
|
self.light_period_start = light_period_start or datetime.time(6, 0)
|
|
|
self.light_period_end = light_period_end or datetime.time(22, 0)
|
|
|
+ random.seed(seed)
|
|
|
+ logging.info(f"随机种子已设置为 {seed}。")
|
|
|
logging.info(f"光照采样器已初始化,光周期为 {self.light_period_start.strftime('%H:%M')} - {self.light_period_end.strftime('%H:%M')}。")
|
|
|
|
|
|
def sample_next_light_state(self) -> dict:
|