"""
Module to build experiments (worlds, agents, etc.).
"""

import random
import pygame

import model.interaction
import model.agent
import experiment
import agentprogram.agentprogram
from elements import Elements

class LoadWorldExperiment(experiment.Experiment):
    """
    Load a world to this experiment. Note: experiment control setup is not 
    saved and loaded.
    """
    def __init__(self, world_file_name):
        """
        :param world_file_name: The file name of the world to load.
        """
        super(LoadWorldExperiment, self).__init__()

        self.world = self.load_world(world_file_name)

class BasicExperiment(experiment.Experiment):
    world_representation = [
        "wwwwwwwwwwwwwww",
        "w.............w",
        "w.wwwwwww.....w",
        "w.......wwwww.w",
        "w.wwwww.......w",
        "w.w.......w...w",
        "w.w.wwwww.w...w",
        "w.w.w...w.ww..w",
        "w.www.....w...w",
        "w.....wwwww.a.w",
        "wwwwwwwwwwwwwww"
        ]

    def __init__(self):
        super(BasicExperiment, self).__init__()

        # Parse world
        self.world = self.parse_world(self.world_representation)

        # Rgister enact logic
        enact_logic = Elements.get_enact_logic()

        # Set primitives known/enactable by the agents.
        primitives = []
        primitives.append(Elements.step)
        primitives.append(Elements.step_fail)
        primitives.append(Elements.turn_right)
        primitives.append(Elements.turn_left)
        primitives.append(Elements.wait)
        primitives.append(Elements.feel)
        primitives.append(Elements.feel_fail)

        # Set intrinsic motivation values.
        motivation = {}
        motivation[Elements.step] = 1