import random
from layer1_core.managers.service import ServiceRegistry, Service


class WorldBuilder:
    """WorldBuilder class for constructing the initial conditions of a simulation."""

    def __init__(self, param_dict):
        """
        Initialize a WorldBuilder.

        Args:
            param_dict: Dictionary of parameters for the simulation.
                       Can include 'random_seed' for reproducible randomness.
        """
        self.param_dict = param_dict
        self.world = None
        self.services = ServiceRegistry()

        # Set random seed if provided for reproducibility
        if 'random_seed' in param_dict:
            random.seed(param_dict['random_seed'])

    def build(self):
        """
        Build the initial world state using the Core Layer.

        Returns:
            The initialized world/simulation state
        """
        # TODO: Implement world construction using Core Layer entities
        # This will construct agents, collectives, networks, etc.
        pass

    def get_world(self):
        """
        Get the constructed world.

        Returns:
            The initialized world state
        """
        return self.world

    def __repr__(self):
        return f"WorldBuilder(params={len(self.param_dict)})"