feat: improves and initilize player pipeline

This commit is contained in:
2026-03-05 00:33:48 -03:00
parent 06ae9b41f0
commit 53eb34a83e
13 changed files with 248 additions and 60 deletions

View File

@@ -1,8 +1,41 @@
from diceplayer.config.player_config import PlayerConfig
from diceplayer.logger import logger
from diceplayer.state.state_handler import StateHandler
from diceplayer.state.state_model import StateModel
from typing_extensions import TypedDict, Unpack
class PlayerFlags(TypedDict):
continuation: bool
force: bool
class Player:
def __init__(self, config: PlayerConfig):
self.config = config
def play(self, continuation=False): ...
def play(self, **flags: Unpack[PlayerFlags]):
state_handler = StateHandler(self.config.simulation_dir)
if not flags["continuation"]:
logger.info(
"Continuation flag is not set. Starting a new simulation and deleting any existing state."
)
state_handler.delete()
state = state_handler.get(self.config, force=flags["force"])
if state is None:
state = StateModel.from_config(self.config)
else:
logger.info("Resuming from existing state.")
while state.current_cycle < self.config.max_cyc:
logger.info(
f"Starting cycle {state.current_cycle + 1} of {self.config.max_cyc}."
)
state.current_cycle += 1
state_handler.save(state)
logger.info("Reached maximum number of cycles. Simulation complete.")