public void InitializePanelWithTrainerData()
    {
        DebugBot.DebugFunctionCall("TTrialRowUI; InitializePanelWithTrainerData(); ", debugFunctionCalls);

        Player currentPlayer = trainerModuleScript.gameController.masterTrainer.PlayerList[trainerModuleScript.gameController.masterTrainer.CurPlayer - 1];

        if (currentPlayer.masterTrialsList[trialIndex] != null)          // error catch
        //textCurrentPopulationSize.text = "Current Population Size: " + (populationRef.isFunctional ? populationRef.masterAgentArray.Length.ToString() : "0"); // Update this later!!
        //Current Max Population Size:
        {
            sliderNumPlays.minValue = minNumPlays;             // set up slider bounds
            sliderNumPlays.maxValue = maxNumPlays;
            pendingNumPlays         = currentPlayer.masterTrialsList[trialIndex].numberOfPlays;
            sliderEvalTime.minValue = minEvalTime;             // set up slider bounds
            sliderEvalTime.maxValue = maxEvalTime;
            pendingEvalTime         = currentPlayer.masterTrialsList[trialIndex].maxEvaluationTimeSteps;
            sliderPower.minValue    = minPower;          // set up slider bounds
            sliderPower.maxValue    = maxPower;
            pendingPower            = currentPlayer.masterTrialsList[trialIndex].power;
            sliderWeight.minValue   = minWeight;           // set up slider bounds
            sliderWeight.maxValue   = maxWeight;
            pendingWeight           = currentPlayer.masterTrialsList[trialIndex].weight;
        }

        UpdateUIWithCurrentData();
    }
 public void ClickDataView()
 {
     DebugBot.DebugFunctionCall("TModuleUI; ClickDataView(); ", debugFunctionCalls);
     TurnOffExclusivePanelsPlayspace();
     panelDataViewOn = true;
     UpdatePanelVisibility();
 }
Example #3
0
 public void UpdateUIElementStates()
 {
     DebugBot.DebugFunctionCall("TTrialsUI; UpdateUIElementStates(); ", debugFunctionCalls);
     // Changing Button Displays !!
     if (panelActive)
     {
         panelVisible.SetActive(true);
     }
     else
     {
         panelVisible.SetActive(false);
     }
     if (valuesChanged)
     {
         buttonApply.interactable  = true;
         buttonCancel.interactable = true;
     }
     else
     {
         buttonApply.interactable  = false;
         buttonCancel.interactable = false;
     }
     if (applyPressed)
     {
         bgImage.color = new Color(0.99f, 0.75f, 0.6f);
     }
     else
     {
         bgImage.color = trainerModuleScript.defaultBGColor;
     }
 }
    public void InitializePanelWithTrainerData()
    {
        DebugBot.DebugFunctionCall("TPopUI; InitializePanelWithTrainerData(); ", debugFunctionCalls);
        Trainer trainer = trainerModuleScript.gameController.masterTrainer;

        if (trainer.PlayerList != null)
        {
            int curPlayer = trainer.CurPlayer;
            //Debug.Log ("InitializePanelWithTrainerData(), " + trainer.PlayerList[curPlayer-1].maxMaxPopulationSize.ToString());
            //sliderMaxPopulationSize.minValue = trainer.PlayerList[curPlayer-1].minMaxPopulationSize;
            //sliderMaxPopulationSize.maxValue = trainer.PlayerList[curPlayer-1].maxMaxPopulationSize;
            //sliderMaxPopulationSize.value = trainer.PlayerList[curPlayer-1].maxPopulationSize;
            if (trainer.PlayerList[curPlayer - 1].masterPopulation != null)                                                                                           // if the current player has a Population instance:
            {
                populationRef = trainer.PlayerList[curPlayer - 1].masterPopulation;                                                                                   // get current population instance
                //Current Population text:
                textCurrentPopulationSize.text = "Current Population Size: " + (populationRef.isFunctional ? populationRef.masterAgentArray.Length.ToString() : "0"); // Update this later!!
                //Current Max Population Size:
                sliderMaxPopulationSize.minValue = minMaxPopulationSize;                                                                                              // set up slider bounds
                sliderMaxPopulationSize.maxValue = maxMaxPopulationSize;
                sliderMaxPopulationSize.value    = populationRef.populationMaxSize;
                textMaxPopulationSize.text       = populationRef.populationMaxSize.ToString();
            }
            else                // Population hasn't been created yet:
                                //textMaxPopulationSize.text = trainer.PlayerList[curPlayer-1].maxPopulationSize.ToString();
            {
            }
        }

        valuesChanged = false;
        applyPressed  = false;

        UpdateUIWithCurrentData();
    }
    private void InitializeAgentBrainAndBody(Agent newAgent, CritterGenome bodyGenome)        /// Configure newly-created Agent (brain + body) for the FIRST TIME!! to change settings on an existing agent, use a different method.
    {
        DebugBot.DebugFunctionCall("Population; InitializeAgentInstance(); ", debugFunctionCalls);
        // Figure out Agent Body HERE:
        newAgent.bodyGenome = bodyGenome;         // set as this agent's body Genome

        // BRAIN BELOW:
        // Initialize Brain:
        newAgent.brain = new BrainNEAT();

        GenomeNEAT brainGenome;

        Debug.Log("InitializeAgentBrainAndBody numInputNodes: " + numInputNodes.ToString() + ", NumHiddenNodes: " + initNumHiddenNodes.ToString() + ", numOutputNodes: " + numOutputNodes.ToString() + ", initConnectedness: " + initConnectedness.ToString() + ", initRandom: " + initRandom.ToString());
        // OLD // brainGenome = newAgent.brain.InitializeNewBrain(numInputNodes, initNumHiddenNodes, numOutputNodes, initConnectedness, initRandom);
        brainGenome = newAgent.brain.InitializeNewBrain(bodyGenome, initNumHiddenNodes, initConnectedness, initRandom);

        /*if(initRandom) {  // OLD
         *  brainGenome = newAgent.brain.InitializeRandomBrain(numInputNodes, numOutputNodes); // 'builds' the brain and spits out a Genome
         *      }
         *      else {
         *  brainGenome = newAgent.brain.InitializeBlankBrain(numInputNodes, numOutputNodes);
         *      }*/

        newAgent.brainGenome = brainGenome;
        newAgent.brain.BuildBrainNetwork();          // constructs the brain from its sourceGenome
        //AssignAgentToSpecies(newAgent);
        isFunctional = true;
    }
    public void CopyInputChannelsList(List <BrainInputChannel> source, List <BrainInputChannel> target)                 // Maybe update this by making it a function of BrainInputChannel that takes an instance of itself
    // Check if both are the same length?
    {
        int numInputs = source.Count;

        if (numInputs == target.Count)
        {
            for (int i = 0; i < numInputs; i++)
            {
                string newName = "";
                newName = source[i].channelName;                  // Make sure these are allocating new memory and will be copies, not references!
                target[i].channelName = newName;
                float newValue = 0f;
                newValue = source[i].channelValue[0];                  // Make sure these are allocating new memory and will be copies, not references!
                target[i].channelValue[0] = newValue;
                bool newOn = false;
                newOn        = source[i].on;            // Make sure these are allocating new memory and will be copies, not references!
                target[i].on = newOn;
                DebugBot.DebugFunctionCall("TMiniGameUI; CopyInputChannelsList: " + source[i].on.ToString() + ", targ: " + target[i].on.ToString(), debugFunctionCalls);
            }
        }
        else
        {
            DebugBot.DebugFunctionCall("TMiniGameUI; CopyInputChannelsList(); Arrays of Different Length!", debugFunctionCalls);
        }
    }
    // Constructor Method:
    public TestGame()
    {
        DebugBot.DebugFunctionCall("TestGame; Constructor();", true);
        ownPosX[0]    = 1f;
        targetPosX[0] = 2f;
        ownVelX[0]    = 3f;
        targetVelX[0] = 4f;
        // Brain Inputs!:
        inputChannelsList = new List <TestChannel>();
        TestChannel BIC_ownPosX = new TestChannel(ref ownPosX, true, "ownPosX");

        inputChannelsList.Add(BIC_ownPosX);          // 0
        TestChannel BIC_targetPosX = new TestChannel(ref targetPosX, true, "targetPosX");

        inputChannelsList.Add(BIC_targetPosX);          // 1
        TestChannel BIC_ownVelX = new TestChannel(ref ownVelX, false, "ownVelX");

        inputChannelsList.Add(BIC_ownVelX);          // 2
        TestChannel BIC_targetVelX = new TestChannel(ref targetVelX, false, "targetVelX");

        inputChannelsList.Add(BIC_targetVelX);          // 3

        // Brain Outputs!:
        outputChannelsList = new List <TestChannel>();
        TestChannel BOC_ownVelX = new TestChannel(ref ownVelX, true, "ownVelX");

        outputChannelsList.Add(BOC_ownVelX);          // 0
    }
    public void InitializeMasterAgentArray(CritterGenome bodyGenome, bool useSpeciation)        // Creates a new population for the FIRST TIME!!!
    {
        DebugBot.DebugFunctionCall("Population; InitializeMasterAgentArray(CritterGenome); ", debugFunctionCalls);
        templateGenome = bodyGenome;

        // $$$$$$$$$$$$ TRY TO REMOVE THIS SOON!!!!!!!!!!!!!!!!  $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
        int[] critterData = templateGenome.CalculateNumberOfSegmentsInputsOutputs(); // just to check number of segments, inputs, and outputs
        int   numSegments = critterData[0];

        numInputNodes  = critterData[1];
        numOutputNodes = critterData[2];
        Debug.Log("Critter Stats [0]: " + numSegments.ToString() + ", [1]: " + numInputNodes.ToString() + ", [2]: " + numOutputNodes.ToString());
        // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

        masterAgentArray = new Agent[populationMaxSize];
        for (int i = 0; i < populationMaxSize; i++)
        {
            Agent newAgent = new Agent();
            //newAgent.fitnessRank =
            InitializeAgentBrainAndBody(newAgent, bodyGenome);              // create Agent's brain as proper type, and copies over templateBrain's settings
            masterAgentArray[i] = newAgent;
            numAgents++;
        }

        InitializeSpeciesPoolsAndAgents(useSpeciation); // assigns agents to a species and populates the breeding pools
    }
    public void CopyOptionsChannelsList(List <GameOptionChannel> source, List <GameOptionChannel> target)
    {
        // Check if both are the same length?
        int numOptions = source.Count;

        if (numOptions == target.Count)
        {
            for (int i = 0; i < numOptions; i++)
            {
                string newName = "";
                newName = source[i].channelName;                  // Make sure these are allocating new memory and will be copies, not references!
                target[i].channelName = newName;
                float newValue = 0f;
                newValue = source[i].channelValue[0];                  // Make sure these are allocating new memory and will be copies, not references!
                target[i].channelValue[0] = newValue;
                //bool newOn = false;
                //newOn = source[i].on;   // Make sure these are allocating new memory and will be copies, not references!
                //target[i].on = newOn;
            }
        }
        else
        {
            DebugBot.DebugFunctionCall("TMiniGameUI; CopyOptionsChannelsList(); Arrays of Different Length!", debugFunctionCalls);
        }
    }
    public void ClickLoadPopulation()
    {
        DebugBot.DebugFunctionCall("LoadPopulationUI; ClickLoadPopulation(); ", debugFunctionCalls);
        Player currentPlayer = trainerModuleScript.gameController.masterTrainer.PlayerList[trainerModuleScript.gameController.masterTrainer.CurPlayer - 1];

        fileRootPath = Application.dataPath + "/SaveFiles/TrainingSaves/";
        string fileName = inputFieldFileName.text + fileExt;

        Debug.Log(fileRootPath + fileName);

        if (System.IO.File.Exists(fileRootPath + fileName))
        {
            TrainingSave trainingDataToLoad = ES2.Load <TrainingSave>(fileRootPath + fileName);;
            trainerModuleScript.gameController.masterTrainer.loadedTrainingSave = trainingDataToLoad;
            trainerModuleScript.gameController.masterTrainer.trainingModifierManager.activeTrainingModifierList = trainerModuleScript.gameController.masterTrainer.loadedTrainingSave.savedTrainingModifierList;
            // Leap of Faith:
            currentPlayer.masterPopulation                     = trainingDataToLoad.savedPopulation;
            GenomeNEAT.nextAvailableInnovationNumber           = trainingDataToLoad.savedPopulation.nextAvailableGeneInno;
            currentPlayer.masterPopulation.trainingGenerations = trainingDataToLoad.endGeneration; // keep track of total gens this population has trained on
            currentPlayer.masterPopulation.InitializeLoadedMasterAgentArray();                     // <-- somewhat hacky, re-assess later, but this is where the brains are created from genome
            currentPlayer.masterPopulation.isFunctional = true;
            currentPlayer.hasValidPopulation            = true;
            Debug.Log("Loaded Training Save!!! body nodes: " + currentPlayer.masterPopulation.templateGenome.ToString() + ", startGen: " + trainingDataToLoad.beginGeneration.ToString() + ", endGen: " + trainingDataToLoad.endGeneration.ToString());

            currentPlayer.masterCupid       = trainingDataToLoad.savedCrossoverManager;
            CrossoverManager.nextNodeInnov  = currentPlayer.masterCupid.savedNextNodeInnov;
            CrossoverManager.nextAddonInnov = currentPlayer.masterCupid.savedNextAddonInnov;

            trainerModuleScript.SetAllPanelsFromTrainerData();
        }
        else
        {
            Debug.LogError("No TrainingData File Exists!");
        }
    }
 private void TurnOffExclusivePanelsTrials()
 {
     DebugBot.DebugFunctionCall("TModuleUI; TurnOffExclusivePanelsTrials(); ", debugFunctionCalls);
     panelTrialsOn           = false;
     panelFitnessFunctionOn  = false;
     panelMiniGameSettingsOn = false;
 }
 public void ClickArena()
 {
     DebugBot.DebugFunctionCall("TModuleUI; ClickArena(); ", debugFunctionCalls);
     TurnOffExclusivePanelsPlayspace();
     panelArenaOn = true;
     ArenaGroup.arenaGroupStatic.ArenaViewOn();
     UpdatePanelVisibility();
 }
 public void ClickAddTrial()
 {
     DebugBot.DebugFunctionCall("TModuleUI; ClickAddTrial(); ", debugFunctionCalls);
     TurnOffExclusivePanelsTrials();
     panelFitnessFunctionOn = true;
     UpdatePanelVisibility();
     panelFitnessScript.InitializePanelWithTrainerData();
 }
 public void ClickChooseMiniGame()
 {
     DebugBot.DebugFunctionCall("TModuleUI; ClickChooseMiniGame(); ", debugFunctionCalls);
     TurnOffExclusivePanelsTrials();
     panelMiniGameSettingsOn = true;
     UpdatePanelVisibility();
     panelMiniGameScript.InitializePanelWithTrainerData();
 }
 public void ClickSavePopulation()
 {
     DebugBot.DebugFunctionCall("TModuleUI; ClickSavePopulation(); ", debugFunctionCalls);
     TurnOffExclusivePanelsPlayspace();
     panelSavePopulationOn = true;
     UpdatePanelVisibility();
     panelSavePopulationScript.InitializePanelWithTrainerData();
 }
 public void SliderWeight(float sliderValue)       // On Slider Value Changed
 {
     DebugBot.DebugFunctionCall("TTrialRowUI; SliderWeight(); ", debugFunctionCalls);
     pendingWeight = sliderValue;
     trainerTrialsScript.valuesChanged = true;
     trainerTrialsScript.UpdateUIWithCurrentData();
     UpdateUIWithCurrentData();
 }
Example #17
0
 public void SliderNumNodes(float sliderValue)       // On Slider Value Changed
 {
     DebugBot.DebugFunctionCall("TMiniGameInputRowUI; SliderNumPlays(); ", debugFunctionCalls);
     pendingNumNodes = (int)sliderValue;
     trainerMiniGameScript.valuesChanged = true;
     trainerMiniGameScript.UpdateUIWithCurrentData();
     UpdateUIWithCurrentData();
 }
    public List <float[]> brainOutput;    // !! Or if this should live inside the miniGameInstance


    public MiniGameManager(Player playerReference)
    {
        DebugBot.DebugFunctionCall("MiniGameManager; MiniGameManager(); Constructor", debugFunctionCalls);
        playerRef = playerReference;
        //SetMiniGameType(gameType);
        //inputSourceList = new string[0];
        //outputActionsList = new string[0];
    }
 public void ClickOptionsPanel()
 {
     DebugBot.DebugFunctionCall("TMiniGameUI; ClickOptionsPanel(); ", debugFunctionCalls);
     inputsPanelOn  = false;
     outputsPanelOn = false;
     optionsPanelOn = true;
     UpdateUIWithCurrentData();
 }
    // Primary Function
    public void Tick()        // Runs the mini-game for a single evaluation step.
    //inputChannelsList[0].channelValue += 222f;
    //ownPosX -= 57.02417f;
    //inputChannelsList[0].SetValue(222f);

    {
        DebugBot.DebugFunctionCall("TestGame; Tick(); ownPosX= " + ownPosX[0].ToString() + ", targPosX= " + targetPosX[0].ToString() + ", ownvelX= " + ownVelX[0].ToString() + ", targetVelX= " + targetVelX[0].ToString() + ", ", true);
    }
 // Constructor Methods:
 public Population()
 {
     DebugBot.DebugFunctionCall("Population; Population() Constructor!; ", debugFunctionCalls);
     if (speciesBreedingPoolList == null)
     {
         speciesBreedingPoolList = new List <SpeciesBreedingPool>();
     }
     brainSettings = new BrainSettings(); // CHANGE THIS LATER!!!!!
 }
Example #22
0
    public void ClickRender()
    {
        DebugBot.DebugFunctionCall("TMenuBarUI; ClickRender(); ", debugFunctionCalls);
        Trainer trainer = trainerModuleScript.gameController.masterTrainer;

        trainer.ToggleRender();
        CheckActivationCriteria();
        UpdateUIElementStates();
    }
    public void SetTrainerDataFromUIApply()
    {
        DebugBot.DebugFunctionCall("TPlayersUI; SetTrainerDataFromUIApply(); ", debugFunctionCalls);
        Trainer trainer = trainerModuleScript.gameController.masterTrainer;

        trainer.NumPlayers = pendingNumPlayers;
        trainer.AddPlayer();
        InitializePanelWithTrainerData();
    }
Example #24
0
 public void SliderWeight(float sliderValue)       // On Slider Value Changed
 {
     DebugBot.DebugFunctionCall("TFitnessCompRowUI; SliderWeight(); ", debugFunctionCalls);
     pendingWeight = sliderValue;
     trainerFitnessScript.pendingFitnessManager.masterFitnessCompList[fitnessIndex].weight = pendingWeight;
     trainerFitnessScript.valuesChanged = true;
     trainerFitnessScript.UpdateUIWithCurrentData();
     UpdateUIWithCurrentData();
 }
Example #25
0
    public void UpdateUIWithCurrentData()
    {
        DebugBot.DebugFunctionCall("TMiniGameOutputRowUI; UpdateUIWithCurrentData(); ", debugFunctionCalls);

        toggleOutputSource.isOn = pendingChannelOn;

        CheckActivationCriteria();
        UpdateUIElementStates();
    }
 public void OpenTrainerModule()
 {
     DebugBot.DebugFunctionCall("GameController; OpenTrainerModule(); ", debugFunctionCalls);
     if (masterTrainer == null)           // first time running program
     {
         masterTrainer = new Trainer();
         masterTrainer.gameControllerRef = this;
     }
     trainerUI.InitializeModuleUI();          // Sets up all panel visibility, activa/inactive states, and UI element values when module is opened
 }
Example #27
0
    public void PrintBiases(string prefix)
    {
        string biases = "";

        for (int i = 0; i < genomeBiases.Length; i++)
        {
            biases += genomeBiases[i].ToString() + ", ";
        }
        DebugBot.DebugFunctionCall(prefix + biases, true);
    }
Example #28
0
    public void UpdateUIElementStates()
    {
        // Changing Button Displays !!
        Player currentPlayer = trainerModuleScript.gameController.masterTrainer.PlayerList[trainerModuleScript.gameController.masterTrainer.CurPlayer - 1];

        textOutputSourceName = toggleOutputSource.transform.GetComponentInChildren <Text>();        // Is this line needed?
        //textOutputSourceName.text = trainerMiniGameScript.pendingMiniGameManager.miniGameInstance.outputChannelsList[outputListIndex].channelName; // set display name

        DebugBot.DebugFunctionCall("TMiniGameOutputRowUI; UpdateUIElementStates(); " + textOutputSourceName.text.ToString(), debugFunctionCalls);
    }
    public void UpdateUIWithCurrentData()
    {
        //DebugBot.DebugFunctionCall("TMiniGameOptionsRowUI; UpdateUIWithCurrentData(); pend: " + pendingOptionValue.ToString() + ", val: " + sliderOptionChannel.value.ToString(), true);

        //sliderOptionChannel.value = pendingOptionValue;

        DebugBot.DebugFunctionCall("TMiniGameOptionsRowUI; UpdateUIWithCurrentData(); pend: " + pendingOptionValue.ToString() + ", val: " + sliderOptionChannel.value.ToString(), debugFunctionCalls);
        CheckActivationCriteria();
        UpdateUIElementStates();
    }
    public void InitializePanelWithTrainerData()
    {
        Player currentPlayer = trainerModuleScript.gameController.masterTrainer.PlayerList[trainerModuleScript.gameController.masterTrainer.CurPlayer - 1];

        populationRef = currentPlayer.masterPopulation;

        DebugBot.DebugFunctionCall("LoadPopulationUI; InitializePanelWithTrainerData(); ", debugFunctionCalls);

        UpdateUIWithCurrentData();
    }