Activate() public méthode

public Activate ( ) : void
Résultat void
Exemple #1
0
    public void RunBest()
    {
        Time.timeScale = 1;

        NeatGenome genome = null;


        // Try to load the genome from the XML document.
        try
        {
            using (XmlReader xr = XmlReader.Create(champFileSavePath))
                genome = NeatGenomeXmlIO.ReadCompleteGenomeList(xr, false, (NeatGenomeFactory)experiment.CreateGenomeFactory())[0];
        }
        catch (Exception e1)
        {
            // print(champFileLoadPath + " Error loading genome from file!\nLoading aborted.\n"
            //						  + e1.Message + "\nJoe: " + champFileLoadPath);
            return;
        }

        // Get a genome decoder that can convert genomes to phenomes.
        var genomeDecoder = experiment.CreateGenomeDecoder();

        // Decode the genome into a phenome (neural network).
        var phenome = genomeDecoder.Decode(genome);

        GameObject     obj        = Instantiate(Unit, Unit.transform.position, Unit.transform.rotation) as GameObject;
        UnitController controller = obj.GetComponent <UnitController>();

        ControllerMap.Add(phenome, controller);

        controller.Activate(phenome);
    }
        public void RunBest()
        {
            Time.timeScale = 1;

            NeatGenome genome = null;

            // Try to load the genome from the XML document.
            try
            {
                using (XmlReader xr = XmlReader.Create(champFileSavePath))
                    genome = NeatGenomeXmlIO.ReadCompleteGenomeList(xr, false, (NeatGenomeFactory)experiment.CreateGenomeFactory())[0];
            }
            catch (Exception e1)
            {
                Debug.Log(" Error loading genome from file! Loading aborted.\n" + e1.Message);
                return;
            }

            // Genomedecoders convert genomes to pheonomes
            var genomeDecoder = experiment.CreateGenomeDecoder();

            // Decode into a network
            var phenome = genomeDecoder.Decode(genome);

            GameObject obj = Instantiate(Unit, transform.position, Unit.transform.rotation) as GameObject;

            obj.AddComponent <Creature>();
            UnitController controller = obj.GetComponent <UnitController>();

            ControllerMap.Add(phenome, controller);

            controller.Activate(phenome);
        }
Exemple #3
0
    public void Evaluate(IBlackBox box)
    {
        GameObject     obj        = Instantiate(Unit, Unit.transform.position, Unit.transform.rotation) as GameObject;
        UnitController controller = obj.GetComponent <UnitController>();

        ControllerMap.Add(box, controller);

        controller.Activate(box);
    }
Exemple #4
0
    /// <summary>
    /// Called by SimpleEvaluator and NeatManualEvaluator.
    /// Instantiates and activates a unit. Adds its controller (box parameter)
    /// to the dictionary ControllerMap.
    /// </summary>
    public override void InstantiateCandidate(SharpNeat.Phenomes.IBlackBox box)
    {
        GameObject obj = Instantiate(Unit, Unit.transform.position,
                                     Unit.transform.rotation) as GameObject;
        UnitController controller = obj.GetComponent <UnitController>();

        ControllerMap.Add(box, controller);
        controller.Activate(box);
    }
    public void Evaluate(IBlackBox box)
    {
        Vector3        position   = Unit.transform.position + Vector3.Scale(UnityEngine.Random.onUnitSphere, new Vector3(5, 4, 0));
        Quaternion     rotation   = Quaternion.Euler(Unit.transform.rotation.eulerAngles + new Vector3(0, 0, UnityEngine.Random.Range(0, 360)));
        GameObject     obj        = Instantiate(Unit, position, rotation) as GameObject;
        UnitController controller = obj.GetComponent <UnitController> ();

        ControllerMap.Add(box, controller);

        controller.Activate(box);
    }
Exemple #6
0
    public void EvaluateLayers(IBlackBox box, int layers)
    {
        GameObject     obj            = Instantiate(Unit, Unit.transform.position, Unit.transform.rotation) as GameObject;
        UnitController controller     = obj.GetComponent <UnitController>();
        Agar           agarController = obj.GetComponent <Agar>();

        obj.SetActive(true);
        ControllerMap.Add(box, controller);

        controller.Activate(box);
        agarController.ActivateLayers(layers);
    }
        public void Evaluate(IBlackBox box)
        {
            int rand = UnityEngine.Random.Range(0, TestSettings.Instance.MaxFish);

            //Vector3 pos = new Vector3(fishStartPos[rand].x,fishStartPos[rand].y);
            obj = Instantiate(Unit, transform.position, Unit.transform.rotation) as GameObject;
            obj.AddComponent <Creature>();
            UnitController controller = obj.GetComponent <UnitController>();

            ControllerMap.Add(box, controller);
            controller.Activate(box);
        }
Exemple #8
0
    public void RunBest(int mode)     //0 for normal best, 1 for experimental best
    {
        Time.timeScale = 1;

        NeatGenome genome = null;

        Debug.Log(champFileSavePath);
        string FileString;

        Color visualEffect = Color.blue;

        if (mode == 0)
        {
            FileString = champFileSavePath;
        }
        else
        {
            FileString   = champFileSavePath2;
            visualEffect = Color.red;
        }
        // Try to load the genome from the XML document.
        try
        {
            using (XmlReader xr = XmlReader.Create(FileString))
                genome = NeatGenomeXmlIO.ReadCompleteGenomeList(xr, false, (NeatGenomeFactory)experiment.CreateGenomeFactory())[0];
        }
        catch (Exception e1)
        {
            // print(champFileLoadPath + " Error loading genome from file!\nLoading aborted.\n"
            //						  + e1.Message + "\nJoe: " + champFileLoadPath);
            Debug.Log("get error in best");
            return;
        }

        // Get a genome decoder that can convert genomes to phenomes.
        var genomeDecoder = experiment.CreateGenomeDecoder();

        // Decode the genome into a phenome (neural network).
        var phenome = genomeDecoder.Decode(genome);

        GameObject     obj        = Instantiate(Unit, Unit.transform.position, Unit.transform.rotation) as GameObject;
        UnitController controller = obj.GetComponent <UnitController>();

        obj.GetComponent <SpriteRenderer> ().color = visualEffect;

        ControllerMap.Add(phenome, controller);

        controller.Activate(phenome);
    }
Exemple #9
0
    void InstantiateCar(NeatGenome genome)
    {
        // Get a genome decoder that can convert genomes to phenomes.
        var genomeDecoder = experiment.CreateGenomeDecoder();
        // Decode the genome into a phenome (neural network).
        // 30-((30-0)*(1-0,75))
        var        phenome = genomeDecoder.Decode(genome);
        GameObject car     = Instantiate(Unit, StartPos.transform.position, StartPos.transform.rotation) as GameObject;
        //obj.GetComponent<CarController> ().rain = minRain + (bestCounter * rainInterval);
        UnitController controller = car.GetComponent <UnitController> ();

        runningCars.Add(car);
        ControllerMap.Add(phenome, controller);
        controller.Activate(phenome);
    }
Exemple #10
0
    public void Evaluate(IBlackBox box)
    {
        GameObject tar;

        if (targetCreated == false)
        {
            tar           = Instantiate(Target, new Vector3(8.5f, 3, 0), Quaternion.identity);
            targetCreated = true;
        }
        GameObject     obj        = Instantiate(Unit, Unit.transform.position, Unit.transform.rotation) as GameObject;
        UnitController controller = obj.transform.GetChild(0).GetComponent <UnitController>();

        ControllerMap.Add(box, controller);

        controller.Activate(box);
    }
Exemple #11
0
    public void Evaluate(IBlackBox box)
    {
        int xPos, zPos;

        lock (this)
        {
            xPos = _xCounter * _xFactor + _xOffset;
            if (xPos < _xLimit)
            {
                _xCounter++;
            }

            else
            {
                _xCounter = 0;
                _zCounter++;
            }
            zPos = _zCounter * _zFactor;
            _counter++;
            if (_counter == experiment.DefaultPopulationSize)
            {
                ResetCounters();
            }
        }

        GameObject     obj        = Instantiate(Unit, new Vector3(xPos, 0, zPos), Unit.transform.rotation) as GameObject;
        UnitController controller = obj.GetComponent <UnitController>();

        controller.MouseDownEvent += (sender, args) =>
        {
            var shapeController = sender as ShapeController;
            if (SelectedController != null)
            {
                SelectedController.DeSelect();
            }
            if (shapeController != null)
            {
                SelectedController = shapeController;
            }
        };
        ControllerMap.Add(box, controller);

        controller.Activate(box);
    }
Exemple #12
0
    public void RunBest()
    {
        timeScale = 1;

        NeatGenome genome = null;


        // Try to load the genome from the XML document.
        try
        {
            TextAsset popTxtAsset = (TextAsset)Resources.Load(champFileSavePath);
            string    stream      = popTxtAsset.text;

            string      xrString = stream;
            XmlDocument xdoc     = new XmlDocument();
            xdoc.LoadXml(xrString);

            using (XmlReader xr = new XmlNodeReader(xdoc))
                genome = NeatGenomeXmlIO.ReadCompleteGenomeList(xr, false, (NeatGenomeFactory)experiment.CreateGenomeFactory())[0];
        }
        catch (Exception e1)
        {
            Debug.LogError(" Error loading genome from file!\nLoading aborted.\n" + e1.Message + "\nin: " + champFileSavePath);
            return;
        }

        // Get a genome decoder that can convert genomes to phenomes.
        var genomeDecoder = experiment.CreateGenomeDecoder();

        // Decode the genome into a phenome (neural network).
        var phenome = genomeDecoder.Decode(genome);

        GameObject     obj        = Instantiate(Unit, Unit.transform.position, Unit.transform.rotation) as GameObject;
        UnitController controller = obj.GetComponent <UnitController>();

        ControllerMap.Add(phenome, controller);

        controller.Activate(phenome);
    }