"""Minimal closed-loop policy. Change only the first line to switch backends.""" from hth_sdk import Control, HTH def decide(state): valid = [t for t in state.temperatures_c if t is not None] heat = 25 if valid and max(valid) < 45 else 0 return Control(fans=[20] * 4, heaters=[heat] * 4, doors={"x": 0, "y": 0, "z": 0}) def run(hth: HTH, steps: int = 8) -> None: for state in hth.watch(period=0.05, count=steps): if not state.ready or not state.fresh: continue result = hth.set(decide(state)) print(state.time, result.ok, state.temperatures_c[0]) if __name__ == "__main__": with HTH.mock(scenario="coupled_4chamber", seed=1, speed=20) as hth: run(hth)