38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from diceplayer.config.player_config import RoutineType
|
|
from diceplayer.dice.dice_wrapper import DiceEnvironmentItem
|
|
from diceplayer.environment import Atom
|
|
from diceplayer.logger import logger
|
|
from diceplayer.state.state_model import StateModel
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
class OptimizationHandler:
|
|
def __init__(self, step_directory: Path):
|
|
self.optimization_directory = step_directory / "optimization"
|
|
|
|
def run(
|
|
self,
|
|
state: StateModel,
|
|
current_cycle: int,
|
|
dice_environment: list[Atom],
|
|
) -> StateModel:
|
|
routine = self._fetch_current_routine(state, current_cycle)
|
|
logger.info(
|
|
f"Running Optimization - {current_cycle} - {routine} - {self.optimization_directory}"
|
|
)
|
|
|
|
logger.info(dice_environment)
|
|
|
|
return state
|
|
|
|
@staticmethod
|
|
def _fetch_current_routine(state: StateModel, current_cycle: int) -> RoutineType:
|
|
if state.config.type != RoutineType.BOTH:
|
|
return state.config.type
|
|
|
|
if current_cycle < state.config.switch_cyc:
|
|
return RoutineType.CHARGE
|
|
|
|
return RoutineType.GEOMETRY
|