Exemplo n.º 1
0
    void SetupNewExperiment()
    {
        experiment = new SimpleExperiment();
        XmlDocument xmlConfig = new XmlDocument();
        TextAsset   textAsset = (TextAsset)Resources.Load("experiment.config");

        xmlConfig.LoadXml(textAsset.text);
        experiment.SetOptimizer(this);

        experiment.Initialize("test1", xmlConfig.DocumentElement, NUM_INPUTS, NUM_OUTPUTS);
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        Utility.DebugLog = true;
        experiment       = new SimpleExperiment();
        XmlDocument xmlConfig = new XmlDocument();
        TextAsset   textAsset = (TextAsset)Resources.Load("experiment.config");

        xmlConfig.LoadXml(textAsset.text);
        experiment.SetOptimizer(this);

        // Calculate number of inputs
        numInputs = 0;
        AttributesController unitAttrs = Unit.GetComponent <AttributesController>();

        SectorSensor[]     sectorSensors   = Unit.GetComponents <SectorSensor>();
        DistanceSensor[]   distanceSensors = Unit.GetComponents <DistanceSensor>();
        MovementController movement        = Unit.GetComponent <MovementController>();

        if (unitAttrs != null)
        {
            numInputs += unitAttrs.needsFood ? 1 : 0;
            numInputs += unitAttrs.needsWater ? 1 : 0;
        }
        if (movement != null)
        {
            numInputs += movement.senseSpeed ? 1 : 0;
            numInputs += movement.senseSwimming ? 1 : 0;
        }
        if (sectorSensors.Length > 0)
        {
            foreach (SectorSensor sectorSensor in sectorSensors)
            {
                //numInputs += sectorSensor.senseAngles ? sectorSensor.numSectors * 2 : sectorSensor.numSectors;
                numInputs += sectorSensor.NumSenses;
            }
        }
        if (distanceSensors.Length > 0)
        {
            foreach (DistanceSensor distanceSensor in distanceSensors)
            {
                numInputs += distanceSensor.numSensors;
            }
        }

        experiment.Initialize("Car Experiment", xmlConfig.DocumentElement, numInputs, NumOutputs);

        champFileSavePath = Application.persistentDataPath + string.Format("/{0}.champ.xml", SaveFileName);
        popFileSavePath   = Application.persistentDataPath + string.Format("/{0}.pop.xml", SaveFileName);

        print(champFileSavePath);
    }
Exemplo n.º 3
0
    void SetupNewMAPExperiment()
    {
        map        = new Dictionary <int, NeatGenome> ();//NeatGenome[10];
        experiment = new SimpleExperiment();

        XmlDocument xmlConfig = new XmlDocument();
        TextAsset   textAsset = (TextAsset)Resources.Load("experiment.config");

        xmlConfig.LoadXml(textAsset.text);
        experiment.SetOptimizer(this);

        experiment.Initialize("test1", xmlConfig.DocumentElement, NUM_INPUTS, NUM_OUTPUTS);
        loadMap();
    }
Exemplo n.º 4
0
    void InitExperiment()
    {
        // We get rid of spaces in the experiment name to avoid trouble with paths
        experiment_name = experiment_name.Replace(' ', '_');
        experiment      = new SimpleExperiment(this);

        // Loads experiment parameters into XML document.
        XmlDocument xmlConfig = new XmlDocument();
        TextAsset   textAsset = (TextAsset)Resources.Load("experiment.config");

        xmlConfig.LoadXml(textAsset.text);

        // Loads the experiment parameters from the xml file "experiment.config"
        experiment.Initialize(experiment_name, xmlConfig.DocumentElement,
                              num_inputs, num_outputs);
    }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("Starting XOR experiment");
        SimpleExperiment experiment = new SimpleExperiment();

        XmlDocument xmlConfig = new XmlDocument();

        xmlConfig.Load(@"Assets\Scripts\xor.config.xml");
        experiment.Initialize("XOR", xmlConfig.DocumentElement);

        _ea = experiment.CreateEvolutionAlgorithm();

        _ea.UpdateEvent += new EventHandler(ea_UpdateEvent);

        _ea.StartContinue();
    }
Exemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        Utility.DebugLog = true;
        experiment       = new SimpleExperiment();
        XmlDocument xmlConfig = new XmlDocument();
        TextAsset   textAsset = (TextAsset)Resources.Load("experiment.config");

        xmlConfig.LoadXml(textAsset.text);
        experiment.SetOptimizer(this);

        experiment.Initialize("Car Experiment", xmlConfig.DocumentElement, NUM_INPUTS, NUM_OUTPUTS);

        champFileSavePath = Application.persistentDataPath + string.Format("/{0}.champ.xml", "car");
        popFileSavePath   = Application.persistentDataPath + string.Format("/{0}.pop.xml", "car");

        print(champFileSavePath);
    }
Exemplo n.º 7
0
    private void ActivateFromFile()
    {
        NeatGenome       genome     = null;
        SimpleExperiment experiment = new SimpleExperiment();
        XmlDocument      xmlConfig  = new XmlDocument();
        TextAsset        textAsset  = (TextAsset)Resources.Load("experiment.config");

        xmlConfig.LoadXml(textAsset.text);

        experiment.Initialize("Tmp Experiment", xmlConfig.DocumentElement, 8 + 2, 1);

        string champFileSavePath = Application.persistentDataPath + "/car_movement.champ.xml";

        using (XmlReader xr = XmlReader.Create(champFileSavePath))
            genome = NeatGenomeXmlIO.ReadCompleteGenomeList(xr, false, (NeatGenomeFactory)experiment.CreateGenomeFactory())[0];

        var genomeDecoder = experiment.CreateGenomeDecoder();

        box = genomeDecoder.Decode(genome);
    }
Exemplo n.º 8
0
    public string trainedObjectName = "bob"; //name of file to use / create


    // Use this for initialization
    void Start()
    {
        accum            = 0;
        Utility.DebugLog = showDebugger;
        experiment       = new SimpleExperiment();
        XmlDocument xmlConfig = new XmlDocument();
        TextAsset   textAsset = (TextAsset)Resources.Load("experiment.config");

        xmlConfig.LoadXml(textAsset.text);
        experiment.SetOptimizer(this);

        experiment.Initialize(trainedObjectName + " Experiment", xmlConfig.DocumentElement, NUM_INPUTS, NUM_OUTPUTS);

        champFileSavePath = string.Format("{0}/{1}.champ", "AIAgents", trainedObjectName);
        popFileSavePath   = string.Format("{0}/{1}.pop", "IAgents", trainedObjectName);

        if (Utility.DebugLog)
        {
            Utility.Log(champFileSavePath);
        }
    }
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        Utility.DebugLog = true;
        experiment = new SimpleExperiment();
        XmlDocument xmlConfig = new XmlDocument();
        TextAsset textAsset = (TextAsset)Resources.Load("experiment.config");
        xmlConfig.LoadXml(textAsset.text);
        experiment.SetOptimizer(this);

        experiment.Initialize("Car Experiment", xmlConfig.DocumentElement, NUM_INPUTS, NUM_OUTPUTS);

        champFileSavePath = Application.persistentDataPath + string.Format("/{0}.champ.xml", "car");
        popFileSavePath = Application.persistentDataPath + string.Format("/{0}.pop.xml", "car");

        print(champFileSavePath);
    }