public void ForceSaveInConfigurationMenu(bool overridePrevious)
    {
        float mut, sel;

        PopulationManagerScript popScript = PassValuesToPopulationManager(out mut, out sel);

        popScript.MakeLearningProcess(NumberOfCarsPanel.NumberOfCars, mut, sel, overridePrevious);

        if (overridePrevious)
        {
            process = null;
        }

        using (SaveFileDialog sfd = new SaveFileDialog())
        {
            sfd.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";

            switch (sfd.ShowDialog())
            {
            case DialogResult.OK:
                Debug.Log(sfd.FileName);

                popScript.SaveLearningProcess(sfd.FileName);

                break;
            }
        }
    }
    public void LoadLearningProcess()
    {
        PopulationManagerScript popScript = PopulationManagerObject.GetComponent <PopulationManagerScript>();

        process = popScript.LoadLearningProcess(GetOpenFilePath());

        if (process != null)
        {
            ParentChoosingDropdown.value = (int)process.LearningAlgorithm.Config.ParentMethod;
            ParentChoosingDropdown.RefreshShownValue();

            MutationChanceInputField.text = process.LearningAlgorithm.Config.MutationChance.ToString();
            SelectPercentInputField.text  = process.LearningAlgorithm.Config.PercentToSelect.ToString();

            SigmaInputField.text = process.LearningAlgorithm.Config.RandOptions.Sigma.ToString();

            while (NumberOfCarsPanel.NumberOfCars > process.PopulationCount)
            {
                NumberOfCarsPanel.LessCars();
            }

            while (NumberOfCarsPanel.NumberOfCars < process.PopulationCount)
            {
                NumberOfCarsPanel.MoreCars();
            }
        }
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        popManager = GetComponent <PopulationManagerScript>();

        populationSize = InstanceData.PopulationSize;
        mutationRate   = InstanceData.MutationRate;

        population = new Chromosome[populationSize];
        GenerateInitialPopulation();
    }
    public void StopSimulation()
    {
        CarsOnSceneManager carsManager =
            CarsCollectionObject.GetComponent <CarsOnSceneManager>();

        carsManager.StopSimulation();
        carsManager.StopAllCoroutines();

        PopulationManagerScript populationScript =
            PopulationManagerObject.GetComponent <PopulationManagerScript>();

        populationScript.StopSimulation(true);
        populationScript.StopAllCoroutines();
    }
    private PopulationManagerScript PassValuesToPopulationManager(out float mut, out float sel)
    {
        PopulationManagerScript popScript = PopulationManagerObject.GetComponent <PopulationManagerScript>();

        if (!float.TryParse(MutationChanceInputField.text, out mut))
        {
            Debug.LogWarning("Mutation Chance ma błędny format");
            string temp = MutationChanceInputField.text.Replace(".", ",");

            if (!float.TryParse(temp, out mut))
            {
                Debug.LogWarning("Mutation Chance ma błędny format... wait what");
                //MutationChanceInputField.text.Replace(".", ",");
            }
        }

        if (!float.TryParse(SelectPercentInputField.text, out sel))
        {
            Debug.LogWarning("Selection Chance ma błędny format");
            string temp = SelectPercentInputField.text.Replace(".", ",");

            if (!float.TryParse(temp, out sel))
            {
                Debug.LogWarning("Selection Chance ma błędny format... wait what");
            }
        }

        if (!float.TryParse(SigmaInputField.text, out popScript.sigma))
        {
            string temp = SigmaInputField.text.Replace(".", ",");

            if (!float.TryParse(temp, out popScript.sigma))
            {
            }
        }

        popScript.SetParentChoosingMethod((ParentChoosingMethod)ParentChoosingDropdown.value);

        mut = Mathf.Clamp01(mut);
        sel = Mathf.Clamp01(sel);

        return(popScript);
    }
Example #6
0
    //Ensures GameController is a singleton
    void Awake()
    {
        if(gameController != null)
        {
            Destroy(this.gameObject);
        }
        else
        {
            gameController = this;
        }

        populationManager = gameObject.AddComponent<PopulationManagerScript>();
        foodManager = gameObject.AddComponent<FoodManagerScript> ();
        pollutionManager = gameObject.AddComponent <PollutionManagerScript> ();
        materialManager = gameObject.AddComponent<MaterialManagerScript> ();

        previousPopulation = totalPopulation;
    }