コード例 #1
0
    public void PrepareMatchup(List <EnvironmentGenome> environmentGenomeList, List <AgentGenome> competitorGenomeList, AgentGenome playerGenome, int numEntrants, int maxTimeSteps)
    {
        winnerID        = -1;
        matchupFinished = false;
        //EnvironmentGenome loadedGenome1 = JsonUtility.FromJson<EnvironmentGenome>(dataAsJson);
        List <AgentGenome> agentGenomesList = new List <AgentGenome>();

        for (int i = 0; i < competitorIDs.Length; i++)
        {
            // -1 value is code to use player's genome here
            if (competitorIDs[i] == -1)
            {
                agentGenomesList.Add(playerGenome);
            }
            else
            {
                agentGenomesList.Add(competitorGenomeList[competitorIDs[i]]);
            }
        }

        evalTicket = new EvaluationTicket(environmentGenomeList[environmentID], agentGenomesList, 1, maxTimeSteps);


        contestantScoresArray = new float[1];  // ASSUMES ! PLAYER AT A TIME!!!!

        Debug.Log("contestantScoresArray.Length: " + contestantScoresArray.Length.ToString());
    }
コード例 #2
0
    public void ExhibitionNextGenome(TeamsConfig teamsConfig)
    {
        EvaluationTicket exhibitionTicket = exhibitionTicketList[exhibitionTicketCurrentIndex];
        int currentFocusPop = exhibitionTicket.focusPopIndex;

        // AGENT 0
        int currentGenomeIndex0 = exhibitionTicket.agentGenomesList[0].index;

        currentGenomeIndex0++;
        if (currentGenomeIndex0 >= (teamsConfig.playersList[0].agentGenomeList.Count))
        {
            currentGenomeIndex0 = 0;
        }
        exhibitionTicket.agentGenomesList[0] = teamsConfig.playersList[0].agentGenomeList[currentGenomeIndex0];

        // AGENT 1
        int currentGenomeIndex1 = exhibitionTicket.agentGenomesList[1].index;

        currentGenomeIndex1++;
        if (currentGenomeIndex1 >= (teamsConfig.playersList[1].agentGenomeList.Count))
        {
            currentGenomeIndex1 = 0;
        }
        exhibitionTicket.agentGenomesList[1] = teamsConfig.playersList[1].agentGenomeList[currentGenomeIndex1];

        ResetExhibitionInstance(teamsConfig);
    }
コード例 #3
0
 public void ClearInstance()
 {
     if (currentEvalTicket != null)
     {
         currentEvalTicket.status = EvaluationTicket.EvaluationStatus.Pending;
         currentEvalTicket        = null;
     }
     DeleteAllGameObjects();
 }
コード例 #4
0
    public TournamentMatchup(int id, EvaluationTicket evalTicket, int environmentID, int[] competitorIDs)
    {
        //contestantScoresList = new List<float>();
        this.id         = id;
        this.evalTicket = evalTicket;
        //contestantScoresArray = new float[evalTicket.agentGenomesList.Count]; // Incorrect!

        this.environmentID = environmentID;
        this.competitorIDs = competitorIDs;
    }
コード例 #5
0
    public void SetUpInstance(EvaluationTicket evalTicket, TeamsConfig teamsConfig)
    {
        this.teamsConfig  = teamsConfig;
        this.maxTimeSteps = evalTicket.maxTimeSteps;

        currentEvalTicket = evalTicket;

        BruteForceInit();

        currentEvalTicket.status = EvaluationTicket.EvaluationStatus.InProgress;
    }
コード例 #6
0
    public void InitializeExhibitionTickets(TeamsConfig teamsConfig)
    {
        int numPlayers = teamsConfig.playersList.Count;

        List <AgentGenome> agentGenomesList = new List <AgentGenome>();

        for (int i = 0; i < numPlayers; i++)
        {
            agentGenomesList.Add(teamsConfig.playersList[i].representativeGenomeList[0]);
        }
        EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.representativeGenomeList[0], agentGenomesList, 0, maxTimeStepsDefault);

        exhibitionTicketList.Add(evalTicket);
    }
コード例 #7
0
    public void SetActiveParticle(EvaluationTicket ticket)
    {
        if (ticket.environmentGenome.index == 0)   // if this instance is testing an agent vs. the Top Environment, record its curves:
        {
            singleTrajectoryCurvesPS.gameObject.layer = LayerMask.NameToLayer("Default");
        }

        /*
         * foreach (KeyValuePair<string, ParticleSystem> particle in particleDictionary) {
         *  //Now you can access the key and value both separately from this attachStat as:
         *  //Debug.Log(particle.Key);
         *  //particle.Value.gameObject.SetActive(false);
         *  particle.Value.gameObject.layer = LayerMask.NameToLayer("Hidden");
         * }
         *
         * int[] indices = new int[ticket.agentGenomesList.Count + 2];
         * indices[0] = ticket.focusPopIndex;
         * for(int i = 0; i < ticket.agentGenomesList.Count + 1; i++) {
         *  if(i == 0) {
         *      indices[i + 1] = ticket.environmentGenome.index;
         *  }
         *  else {
         *      indices[i + 1] = ticket.agentGenomesList[i - 1].index;
         *  }
         *  //indices[i + 1] = ticket.genomeIndices[i];
         * }
         * indices[ticket.focusPopIndex + 1] = 0;
         * string txt = "";
         * for (int x = 0; x < indices.Length; x++) {
         *  txt += indices[x].ToString();
         * }
         * //Debug.Log("particle: " + txt);
         * //string test = "";
         * //for(int j = 0; j < ticket.genomeIndices.Length; j++) {
         * //    test += ticket.genomeIndices[j].ToString();
         * //}
         * ParticleSystem focusParticle;
         * if(particleDictionary.TryGetValue(txt, out focusParticle)) {
         *  //Debug.Log("Found it! " + txt + ", " + test + ", " + ticket.focusPopIndex.ToString());
         *  focusParticle.gameObject.layer = LayerMask.NameToLayer("Default");
         * }
         * else {
         *  //Debug.Log("FAILED! " + txt);
         * }
         */
    }
コード例 #8
0
    public void CreateDefaultEvaluationTickets(TeamsConfig teamsConfig)
    {
        allEvalsComplete = false;

        // TEMPORARY!!! BRUTE FORCE SOLUTION -- MAX 4 Players!!!:
        int numPlayers = teamsConfig.playersList.Count;

        if (numPlayers > 4)
        {
            Debug.Assert(true, "More than 4 Players not currently supported! NumPlayers: " + numPlayers.ToString());
        }
        else
        {
            // Environment First:
            for (int e = 0; e < teamsConfig.environmentPopulation.environmentGenomeList.Count; e++)
            {
                // 1+ Player:
                for (int i = 0; i < teamsConfig.playersList[0].representativeGenomeList.Count; i++)
                {
                    if (numPlayers > 1)
                    {
                        // 2+ Players:
                        for (int j = 0; j < teamsConfig.playersList[1].representativeGenomeList.Count; j++)
                        {
                            if (numPlayers > 2)
                            {
                                // 3+ Players:
                                for (int k = 0; k < teamsConfig.playersList[2].representativeGenomeList.Count; k++)
                                {
                                    if (numPlayers > 3)
                                    {
                                        // 4 Players
                                        for (int m = 0; m < teamsConfig.playersList[3].representativeGenomeList.Count; m++)
                                        {
                                            // 4 Players
                                            //string text = "envIndex: *" + e.ToString() + "*, agentIndices: [" + teamsConfig.playersList[0].representativeGenomeList[i].index.ToString() + "," + teamsConfig.playersList[1].representativeGenomeList[j].index.ToString() + "," + teamsConfig.playersList[2].representativeGenomeList[k].index.ToString() + "," + teamsConfig.playersList[3].representativeGenomeList[m].index.ToString() + "]";
                                            //Debug.Log(text);
                                            //int[] indices = new int[5];
                                            //indices[0] = e;
                                            //indices[1] = i; // teamsConfig.playersList[0].representativeGenomeList[i].index;
                                            //indices[2] = j; // teamsConfig.playersList[1].representativeGenomeList[j].index;
                                            //indices[3] = k; // teamsConfig.playersList[2].representativeGenomeList[k].index;
                                            //indices[4] = m; // teamsConfig.playersList[3].representativeGenomeList[m].index;
                                            List <AgentGenome> agentGenomesList = new List <AgentGenome>();
                                            agentGenomesList.Add(teamsConfig.playersList[0].representativeGenomeList[i]);
                                            agentGenomesList.Add(teamsConfig.playersList[1].representativeGenomeList[j]);
                                            agentGenomesList.Add(teamsConfig.playersList[2].representativeGenomeList[k]);
                                            agentGenomesList.Add(teamsConfig.playersList[3].representativeGenomeList[m]);
                                            EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.environmentGenomeList[e], agentGenomesList, 0, maxTimeStepsDefault);
                                            evaluationTicketList.Add(evalTicket);
                                        }
                                    }
                                    else   // 3 Players
                                           //string text = "envIndex: *" + e.ToString() + "*, agentIndices: [" + teamsConfig.playersList[0].representativeGenomeList[i].index.ToString() + "," + teamsConfig.playersList[1].representativeGenomeList[j].index.ToString() + "," + teamsConfig.playersList[2].representativeGenomeList[k].index.ToString() + "]";
                                           //Debug.Log(text);
                                           //int[] indices = new int[4];
                                           //indices[0] = e;
                                           //indices[1] = i; // teamsConfig.playersList[0].representativeGenomeList[i].index;
                                           //indices[2] = j; // teamsConfig.playersList[1].representativeGenomeList[j].index;
                                           //indices[3] = k; // teamsConfig.playersList[2].representativeGenomeList[k].index;
                                           //EvaluationTicket evalTicket = new EvaluationTicket(indices, 0, maxTimeStepsDefault);

                                    {
                                        List <AgentGenome> agentGenomesList = new List <AgentGenome>();
                                        agentGenomesList.Add(teamsConfig.playersList[0].representativeGenomeList[i]);
                                        agentGenomesList.Add(teamsConfig.playersList[1].representativeGenomeList[j]);
                                        agentGenomesList.Add(teamsConfig.playersList[2].representativeGenomeList[k]);
                                        EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.environmentGenomeList[e], agentGenomesList, 0, maxTimeStepsDefault);
                                        evaluationTicketList.Add(evalTicket);
                                    }
                                }
                            }
                            else    // 2 Players:
                            //string text = "envIndex: *" + e.ToString() + "*, agentIndices: [" + teamsConfig.playersList[0].representativeGenomeList[i].index.ToString() + "," + teamsConfig.playersList[1].representativeGenomeList[j].index.ToString() + "]";
                            //Debug.Log(text);
                            //int[] indices = new int[3];
                            //indices[0] = e;
                            //indices[1] = i; // teamsConfig.playersList[0].representativeGenomeList[i].index;
                            //indices[2] = j; // teamsConfig.playersList[1].representativeGenomeList[j].index;
                            //EvaluationTicket evalTicket = new EvaluationTicket(indices, 0, maxTimeStepsDefault);

                            {
                                List <AgentGenome> agentGenomesList = new List <AgentGenome>();
                                agentGenomesList.Add(teamsConfig.playersList[0].representativeGenomeList[i]);
                                agentGenomesList.Add(teamsConfig.playersList[1].representativeGenomeList[j]);
                                EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.environmentGenomeList[e], agentGenomesList, 0, maxTimeStepsDefault);
                                evaluationTicketList.Add(evalTicket);
                            }
                        }
                    }
                    else   // 1 Player:
                           //string text = "envIndex: *" + e.ToString() + "*, agentIndex: [" + teamsConfig.playersList[0].representativeGenomeList[i].index.ToString() + "]";
                           //Debug.Log(text);
                           //int[] indices = new int[2];
                           //indices[0] = e;
                           //indices[1] = i; // teamsConfig.playersList[0].representativeGenomeList[i].index;
                           //EvaluationTicket evalTicket = new EvaluationTicket(indices, 0, maxTimeStepsDefault);

                    {
                        List <AgentGenome> agentGenomesList = new List <AgentGenome>();
                        agentGenomesList.Add(teamsConfig.playersList[0].representativeGenomeList[i]);
                        //Debug.Log(e.ToString() + ", " + teamsConfig.environmentPopulation.environmentGenomeList[e].index.ToString());
                        EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.environmentGenomeList[e], agentGenomesList, 0, maxTimeStepsDefault);
                        evaluationTicketList.Add(evalTicket);
                    }
                }
            }
            if (numPlayers > 0)
            {
                // Player 1:
                for (int i = 0; i < teamsConfig.playersList[0].agentGenomeList.Count; i++)
                {
                    for (int e = 0; e < teamsConfig.environmentPopulation.representativeGenomeList.Count; e++)
                    {
                        if (numPlayers > 1)
                        {
                            for (int j = 0; j < teamsConfig.playersList[1].representativeGenomeList.Count; j++)
                            {
                                if (numPlayers > 2)
                                {
                                    for (int k = 0; k < teamsConfig.playersList[2].representativeGenomeList.Count; k++)
                                    {
                                        if (numPlayers > 3)
                                        {
                                            // 4 Players:
                                            for (int m = 0; m < teamsConfig.playersList[3].representativeGenomeList.Count; m++)
                                            {
                                                //string text = "envIndex: " + teamsConfig.environmentPopulation.representativeGenomeList[e].index.ToString() + ", agentIndex: [*" + i.ToString() + "*," + teamsConfig.playersList[1].representativeGenomeList[j].index.ToString() + "," + teamsConfig.playersList[2].representativeGenomeList[k].index.ToString() + "," + teamsConfig.playersList[3].representativeGenomeList[m].index.ToString() + "]";
                                                //Debug.Log(text);
                                                //int[] indices = new int[5];
                                                //indices[0] = e; // teamsConfig.environmentPopulation.representativeGenomeList[e].index;
                                                //indices[1] = i;
                                                //indices[2] = j; //teamsConfig.playersList[1].representativeGenomeList[j].index;
                                                //indices[3] = k; // teamsConfig.playersList[2].representativeGenomeList[k].index;
                                                //indices[4] = m; // teamsConfig.playersList[3].representativeGenomeList[m].index;
                                                //EvaluationTicket evalTicket = new EvaluationTicket(indices, 1, maxTimeStepsDefault);

                                                List <AgentGenome> agentGenomesList = new List <AgentGenome>();
                                                agentGenomesList.Add(teamsConfig.playersList[0].agentGenomeList[i]);
                                                agentGenomesList.Add(teamsConfig.playersList[1].representativeGenomeList[j]);
                                                agentGenomesList.Add(teamsConfig.playersList[2].representativeGenomeList[k]);
                                                agentGenomesList.Add(teamsConfig.playersList[3].representativeGenomeList[m]);
                                                EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.representativeGenomeList[e], agentGenomesList, 1, maxTimeStepsDefault);
                                                //EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.environmentGenomeList[j], agentGenomesList, 1, maxTimeStepsDefault);
                                                evaluationTicketList.Add(evalTicket);
                                            }
                                        }
                                        else
                                        {
                                            // 3 Players:
                                            //string text = "envIndex: " + teamsConfig.environmentPopulation.representativeGenomeList[e].index.ToString() + ", agentIndex: [*" + i.ToString() + "*," + teamsConfig.playersList[1].representativeGenomeList[j].index.ToString() + "," + teamsConfig.playersList[2].representativeGenomeList[k].index.ToString() + "]";
                                            //Debug.Log(text);
                                            //int[] indices = new int[4];
                                            //indices[0] = e; // teamsConfig.environmentPopulation.representativeGenomeList[e].index;
                                            //indices[1] = i;
                                            //indices[2] = j; // teamsConfig.playersList[1].representativeGenomeList[j].index;
                                            //indices[3] = k; // teamsConfig.playersList[2].representativeGenomeList[k].index;
                                            //EvaluationTicket evalTicket = new EvaluationTicket(indices, 1, maxTimeStepsDefault);

                                            List <AgentGenome> agentGenomesList = new List <AgentGenome>();
                                            agentGenomesList.Add(teamsConfig.playersList[0].agentGenomeList[i]);
                                            agentGenomesList.Add(teamsConfig.playersList[1].representativeGenomeList[j]);
                                            agentGenomesList.Add(teamsConfig.playersList[2].representativeGenomeList[k]);
                                            EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.representativeGenomeList[e], agentGenomesList, 1, maxTimeStepsDefault);
                                            evaluationTicketList.Add(evalTicket);
                                        }
                                    }
                                }
                                else
                                {
                                    // 2 Players:
                                    //string text = "envIndex: " + teamsConfig.environmentPopulation.representativeGenomeList[e].index.ToString() + ", agentIndex: [*" + i.ToString() + "*," + teamsConfig.playersList[1].representativeGenomeList[j].index.ToString() + "]";
                                    //Debug.Log(text);
                                    //int[] indices = new int[3];
                                    //indices[0] = e; // teamsConfig.environmentPopulation.representativeGenomeList[e].index;
                                    //indices[1] = i;
                                    //indices[2] = j; // teamsConfig.playersList[1].representativeGenomeList[j].index;
                                    //EvaluationTicket evalTicket = new EvaluationTicket(indices, 1, maxTimeStepsDefault);

                                    List <AgentGenome> agentGenomesList = new List <AgentGenome>();
                                    agentGenomesList.Add(teamsConfig.playersList[0].agentGenomeList[i]);
                                    agentGenomesList.Add(teamsConfig.playersList[1].representativeGenomeList[j]);
                                    //EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.representativeGenomeList[e], agentGenomesList, 1, maxTimeStepsDefault);
                                    EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.environmentGenomeList[j], agentGenomesList, 1, maxTimeStepsDefault);
                                    evaluationTicketList.Add(evalTicket);
                                }
                            }
                        }
                        else
                        {
                            // 1 Player:
                            //string text = "envIndex: " + teamsConfig.environmentPopulation.representativeGenomeList[e].index.ToString() + ", agentIndex: [*" + i.ToString() + "*]";
                            //Debug.Log(text);
                            //int[] indices = new int[2];
                            //indices[0] = e; // teamsConfig.environmentPopulation.representativeGenomeList[e].index;
                            //indices[1] = i;
                            //EvaluationTicket evalTicket = new EvaluationTicket(indices, 1, maxTimeStepsDefault);

                            List <AgentGenome> agentGenomesList = new List <AgentGenome>();
                            agentGenomesList.Add(teamsConfig.playersList[0].agentGenomeList[i]);
                            EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.representativeGenomeList[e], agentGenomesList, 1, maxTimeStepsDefault);
                            evaluationTicketList.Add(evalTicket);
                        }
                    }
                }

                if (numPlayers > 1)
                {
                    // more than 1 player -- do player 2:
                    // 2 Players:
                    for (int j = 0; j < teamsConfig.playersList[1].agentGenomeList.Count; j++)   // Player 2 focus
                    {
                        for (int e = 0; e < teamsConfig.environmentPopulation.representativeGenomeList.Count; e++)
                        {
                            for (int i = 0; i < teamsConfig.playersList[0].representativeGenomeList.Count; i++)
                            {
                                if (numPlayers > 2)
                                {
                                    for (int k = 0; k < teamsConfig.playersList[2].representativeGenomeList.Count; k++)
                                    {
                                        if (numPlayers > 3)
                                        {
                                            // 4 Players:
                                            for (int m = 0; m < teamsConfig.playersList[3].representativeGenomeList.Count; m++)
                                            {
                                                //string text = "envIndex: " + teamsConfig.environmentPopulation.representativeGenomeList[e].index.ToString() + ", agentIndex: [" + teamsConfig.playersList[0].representativeGenomeList[i].index.ToString() + ",*" + j.ToString() + "*," + teamsConfig.playersList[2].representativeGenomeList[k].index.ToString() + "," + teamsConfig.playersList[3].representativeGenomeList[m].index.ToString() + "]";
                                                //Debug.Log(text);
                                                //int[] indices = new int[5];
                                                //indices[0] = e; // teamsConfig.environmentPopulation.representativeGenomeList[e].index;
                                                //indices[1] = i; // teamsConfig.playersList[0].representativeGenomeList[i].index;
                                                //indices[2] = j;
                                                //indices[3] = k; // teamsConfig.playersList[2].representativeGenomeList[k].index;
                                                //indices[4] = m; // teamsConfig.playersList[3].representativeGenomeList[m].index;
                                                //EvaluationTicket evalTicket = new EvaluationTicket(indices, 2, maxTimeStepsDefault);

                                                List <AgentGenome> agentGenomesList = new List <AgentGenome>();
                                                agentGenomesList.Add(teamsConfig.playersList[0].representativeGenomeList[i]);
                                                agentGenomesList.Add(teamsConfig.playersList[1].agentGenomeList[j]);
                                                agentGenomesList.Add(teamsConfig.playersList[2].representativeGenomeList[k]);
                                                agentGenomesList.Add(teamsConfig.playersList[3].representativeGenomeList[m]);
                                                EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.representativeGenomeList[e], agentGenomesList, 2, maxTimeStepsDefault);
                                                evaluationTicketList.Add(evalTicket);
                                            }
                                        }
                                        else
                                        {
                                            // 3 Players:
                                            //string text = "envIndex: " + teamsConfig.environmentPopulation.representativeGenomeList[e].index.ToString() + ", agentIndex: [" + teamsConfig.playersList[0].representativeGenomeList[i].index.ToString() + ",*" + j.ToString() + "*," + teamsConfig.playersList[2].representativeGenomeList[k].index.ToString() + "]";
                                            //Debug.Log(text);
                                            //int[] indices = new int[4];
                                            //indices[0] = e; // teamsConfig.environmentPopulation.representativeGenomeList[e].index;
                                            //indices[1] = i; // teamsConfig.playersList[0].representativeGenomeList[i].index;
                                            //indices[2] = j;
                                            //indices[3] = k; // teamsConfig.playersList[2].representativeGenomeList[k].index;
                                            //EvaluationTicket evalTicket = new EvaluationTicket(indices, 2, maxTimeStepsDefault);

                                            List <AgentGenome> agentGenomesList = new List <AgentGenome>();
                                            agentGenomesList.Add(teamsConfig.playersList[0].representativeGenomeList[i]);
                                            agentGenomesList.Add(teamsConfig.playersList[1].agentGenomeList[j]);
                                            agentGenomesList.Add(teamsConfig.playersList[2].representativeGenomeList[k]);
                                            EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.representativeGenomeList[e], agentGenomesList, 2, maxTimeStepsDefault);
                                            evaluationTicketList.Add(evalTicket);
                                        }
                                    }
                                }
                                else
                                {
                                    // 2 Players:
                                    //string text = "envIndex: " + teamsConfig.environmentPopulation.representativeGenomeList[e].index.ToString() + ", agentIndex: [" + teamsConfig.playersList[0].representativeGenomeList[i].index.ToString() + ",*" + j.ToString() + "*]";
                                    //Debug.Log(text);
                                    //int[] indices = new int[3];
                                    //indices[0] = e; // teamsConfig.environmentPopulation.representativeGenomeList[e].index;
                                    //indices[1] = i; // teamsConfig.playersList[0].representativeGenomeList[i].index;
                                    //indices[2] = j;
                                    //EvaluationTicket evalTicket = new EvaluationTicket(indices, 2, maxTimeStepsDefault);

                                    List <AgentGenome> agentGenomesList = new List <AgentGenome>();
                                    agentGenomesList.Add(teamsConfig.playersList[0].representativeGenomeList[i]);
                                    agentGenomesList.Add(teamsConfig.playersList[1].agentGenomeList[j]);
                                    //EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.representativeGenomeList[e], agentGenomesList, 2, maxTimeStepsDefault);
                                    EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.environmentGenomeList[i], agentGenomesList, 2, maxTimeStepsDefault);
                                    evaluationTicketList.Add(evalTicket);
                                }
                            }
                        }
                    }
                    if (numPlayers > 2)
                    {
                        // more than 2 players: do player 3:
                        // 3 Players:
                        for (int k = 0; k < teamsConfig.playersList[2].agentGenomeList.Count; k++)   // Player 2 focus
                        {
                            for (int e = 0; e < teamsConfig.environmentPopulation.representativeGenomeList.Count; e++)
                            {
                                for (int i = 0; i < teamsConfig.playersList[0].representativeGenomeList.Count; i++)
                                {
                                    for (int j = 0; j < teamsConfig.playersList[1].representativeGenomeList.Count; j++)
                                    {
                                        if (numPlayers > 3)
                                        {
                                            // 4 Players:
                                            for (int m = 0; m < teamsConfig.playersList[3].representativeGenomeList.Count; m++)
                                            {
                                                //string text = "envIndex: " + teamsConfig.environmentPopulation.representativeGenomeList[e].index.ToString() + ", agentIndex: [" + teamsConfig.playersList[0].representativeGenomeList[i].index.ToString() + "," + teamsConfig.playersList[1].representativeGenomeList[j].index.ToString() + ",*" + k.ToString() + "*," + teamsConfig.playersList[3].representativeGenomeList[m].index.ToString() + "]";
                                                //Debug.Log(text);
                                                //int[] indices = new int[5];
                                                //indices[0] = e; // teamsConfig.environmentPopulation.representativeGenomeList[e].index;
                                                //indices[1] = i; // teamsConfig.playersList[0].representativeGenomeList[i].index;
                                                //indices[2] = j; // teamsConfig.playersList[1].representativeGenomeList[j].index;
                                                //indices[3] = k;
                                                //indices[4] = m; // teamsConfig.playersList[3].representativeGenomeList[m].index;
                                                //EvaluationTicket evalTicket = new EvaluationTicket(indices, 3, maxTimeStepsDefault);

                                                List <AgentGenome> agentGenomesList = new List <AgentGenome>();
                                                agentGenomesList.Add(teamsConfig.playersList[0].representativeGenomeList[i]);
                                                agentGenomesList.Add(teamsConfig.playersList[1].representativeGenomeList[j]);
                                                agentGenomesList.Add(teamsConfig.playersList[2].agentGenomeList[k]);
                                                agentGenomesList.Add(teamsConfig.playersList[3].representativeGenomeList[m]);
                                                EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.representativeGenomeList[e], agentGenomesList, 3, maxTimeStepsDefault);
                                                evaluationTicketList.Add(evalTicket);
                                            }
                                        }
                                        else
                                        {
                                            // 3 Players:
                                            //string text = "envIndex: " + teamsConfig.environmentPopulation.representativeGenomeList[e].index.ToString() + ", agentIndex: [" + teamsConfig.playersList[0].representativeGenomeList[i].index.ToString() + "," + teamsConfig.playersList[1].representativeGenomeList[j].index.ToString() + ",*" + k.ToString() + "*]";
                                            //Debug.Log(text);
                                            //int[] indices = new int[4];
                                            //indices[0] = e; // teamsConfig.environmentPopulation.representativeGenomeList[e].index;
                                            //indices[1] = i; // teamsConfig.playersList[0].representativeGenomeList[i].index;
                                            //indices[2] = j; // teamsConfig.playersList[1].representativeGenomeList[j].index;
                                            //indices[3] = k;
                                            //EvaluationTicket evalTicket = new EvaluationTicket(indices, 3, maxTimeStepsDefault);

                                            List <AgentGenome> agentGenomesList = new List <AgentGenome>();
                                            agentGenomesList.Add(teamsConfig.playersList[0].representativeGenomeList[i]);
                                            agentGenomesList.Add(teamsConfig.playersList[1].representativeGenomeList[j]);
                                            agentGenomesList.Add(teamsConfig.playersList[2].agentGenomeList[k]);
                                            EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.representativeGenomeList[e], agentGenomesList, 3, maxTimeStepsDefault);
                                            evaluationTicketList.Add(evalTicket);
                                        }
                                    }
                                }
                            }
                        }
                        if (numPlayers > 3)
                        {
                            // 4 Players:
                            for (int m = 0; m < teamsConfig.playersList[3].agentGenomeList.Count; m++)   // Player 2 focus
                            {
                                for (int e = 0; e < teamsConfig.environmentPopulation.representativeGenomeList.Count; e++)
                                {
                                    for (int i = 0; i < teamsConfig.playersList[0].representativeGenomeList.Count; i++)
                                    {
                                        for (int j = 0; j < teamsConfig.playersList[1].representativeGenomeList.Count; j++)
                                        {
                                            for (int k = 0; k < teamsConfig.playersList[2].representativeGenomeList.Count; k++)
                                            {
                                                // 4 Players:
                                                //string text = "envIndex: " + teamsConfig.environmentPopulation.representativeGenomeList[e].index.ToString() + ", agentIndex: [" + teamsConfig.playersList[0].representativeGenomeList[i].index.ToString() + "," + teamsConfig.playersList[1].representativeGenomeList[j].index.ToString() + "," + teamsConfig.playersList[1].representativeGenomeList[k].index.ToString() + ",*" + m.ToString() + "*]";
                                                //Debug.Log(text);
                                                //int[] indices = new int[5];
                                                //indices[0] = e; // teamsConfig.environmentPopulation.representativeGenomeList[e].index;
                                                //indices[1] = i; // teamsConfig.playersList[0].representativeGenomeList[i].index;
                                                //indices[2] = j; // teamsConfig.playersList[1].representativeGenomeList[j].index;
                                                //indices[3] = k; // teamsConfig.playersList[2].representativeGenomeList[k].index;
                                                //indices[4] = m;
                                                //EvaluationTicket evalTicket = new EvaluationTicket(indices, 4, maxTimeStepsDefault);

                                                List <AgentGenome> agentGenomesList = new List <AgentGenome>();
                                                agentGenomesList.Add(teamsConfig.playersList[0].representativeGenomeList[i]);
                                                agentGenomesList.Add(teamsConfig.playersList[1].representativeGenomeList[j]);
                                                agentGenomesList.Add(teamsConfig.playersList[2].representativeGenomeList[k]);
                                                agentGenomesList.Add(teamsConfig.playersList[3].agentGenomeList[m]);
                                                EvaluationTicket evalTicket = new EvaluationTicket(teamsConfig.environmentPopulation.representativeGenomeList[e], agentGenomesList, 4, maxTimeStepsDefault);
                                                evaluationTicketList.Add(evalTicket);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        /*string evalText = "";
         * for(int i = 0; i < evaluationTicketList.Count; i++) {
         *  evalText += "(";
         *  for (int j = 0; j < evaluationTicketList[i].genomeIndices.Length; j++) {
         *      evalText += evaluationTicketList[i].genomeIndices[j].ToString() + ",";
         *  }
         *  evalText += ")\n";
         * }
         * Debug.Log(evalText);*/
    }
コード例 #9
0
    public void SetUpInstance(EvaluationTicket evalTicket, TeamsConfig teamsConfig, ExhibitionParticleCurves exhibitionParticleCurves)
    {
        this.teamsConfig   = teamsConfig;
        this.challengeType = teamsConfig.challengeType;
        this.maxTimeSteps  = evalTicket.maxTimeSteps;

        /*string debugname = "";
         * for( int i = 0; i < evalTicket.genomeIndices.Length; i++) {
         *  debugname += evalTicket.genomeIndices[i].ToString() + ",";
         * }
         * debugname += evalTicket.focusPopIndex.ToString();
         * gameObject.name = debugname;*/

        // create particle key:

        /*int[] indices = new int[teamsConfig.playersList.Count + 2];
         * indices[0] = evalTicket.focusPopIndex;
         * for(int i = 0; i < evalTicket.genomeIndices.Length; i++) {
         *  indices[i + 1] = evalTicket.genomeIndices[i];
         * }
         * indices[indices[0] + 1] = 0; // focusPop is 0
         */
        /*int[] indices = new int[teamsConfig.playersList.Count + 2];
         * indices[0] = evalTicket.focusPopIndex;
         * for (int i = 0; i < evalTicket.agentGenomesList.Count + 1; i++) {
         *  if (i == 0) {
         *      indices[i + 1] = evalTicket.environmentGenome.index;
         *  }
         *  else {
         *      indices[i + 1] = evalTicket.agentGenomesList[i - 1].index;
         *  }
         *  //indices[i + 1] = ticket.genomeIndices[i];
         * }
         *
         * string txt = "";
         * for(int i = 0; i < indices.Length; i++) {
         *  txt += indices[i].ToString();
         * }*/
        //Debug.Log(txt);

        /*if (exhibitionParticleRef.particleDictionary != null) {
         *  if (exhibitionParticleRef.particleDictionary.TryGetValue(txt, out particleCurves)) {
         *      // particleCurves
         *      //Debug.Log("FOUND IT! set up " + txt);
         *
         *      emit = true;
         *      if (isExhibition)
         *          emit = false;
         *  }
         *  else {
         *      //if (!isExhibition)
         *      //Debug.Log("Eval Instance Setup FAIL " + txt);
         *      emit = false;
         *  }
         * }*/
        if (evalTicket.environmentGenome.index == 0)  // if this instance is testing an agent vs. the Top Environment, record its curves:

        {
            if (isExhibition)
            {
                //emit = false;
                particleCurves = exhibitionParticleCurves.singleTrajectoryCurvesPS;
                emit           = true;
            }
            else
            {
                particleCurves = exhibitionParticleCurves.singleTrajectoryCurvesPS;
                emit           = true;
            }
        }
        else
        {
            emit = false;
        }


        currentEvalTicket = evalTicket;

        BruteForceInit();

        currentEvalTicket.status = EvaluationTicket.EvaluationStatus.InProgress;


        //emitterParamsDefault.startSize = 0.12f;
        //emitterParamsDefault.startColor = new Color(1f, 1f, 1f, 0.1f);

        emitterParamsWin.startSize  = 1.2f;
        emitterParamsWin.startColor = new Color(0.1f, 1f, 0.1f, 1f);

        emitterParamsLose.startSize  = 1.2f;
        emitterParamsLose.startColor = new Color(1f, 0.1f, 0.1f, 1f);

        emitterParamsDraw.startSize  = 1.0f;
        emitterParamsDraw.startColor = new Color(0.4f, 0.4f, 0.4f, 1f);
    }
コード例 #10
0
    public void Init1(TeamsConfig teamsConfig)
    {
        challengeType = teamsConfig.challengeType;

        // Temp hardcoded!!!!!
        competitionType   = CompetitionType.Independent;
        competitionFormat = CompetitionFormat.HighScore;
        numOpponents      = 1;

        tournamentRoundList = new List <TournamentRound>();

        TournamentRound round1 = new TournamentRound(0);

        // MOCKUP:
        int[] competitorIDs = new int[1];
        competitorIDs[0] = -1;
        // Match1
        string savename = "env1";
        string path     = Application.dataPath + "/IndividualSaves/Environments/" + savename + ".json";
        // Read the json from the file into a string
        string             dataAsJson        = File.ReadAllText(path);
        EnvironmentGenome  loadedGenome1     = JsonUtility.FromJson <EnvironmentGenome>(dataAsJson);
        List <AgentGenome> agentGenomesList1 = new List <AgentGenome>();

        agentGenomesList1.Add(teamsConfig.playersList[0].agentGenomeList[0]);
        EvaluationTicket ticket1 = new EvaluationTicket(loadedGenome1, agentGenomesList1, 1, 1000);

        TournamentMatchup matchup1 = new TournamentMatchup(0, ticket1, 0, competitorIDs);

        round1.matchupList.Add(matchup1);

        // Match2
        savename = "env2";
        path     = Application.dataPath + "/IndividualSaves/Environments/" + savename + ".json";
        // Read the json from the file into a string
        dataAsJson = File.ReadAllText(path);
        EnvironmentGenome  loadedGenome2     = JsonUtility.FromJson <EnvironmentGenome>(dataAsJson);
        List <AgentGenome> agentGenomesList2 = new List <AgentGenome>();

        agentGenomesList2.Add(teamsConfig.playersList[0].agentGenomeList[0]);
        EvaluationTicket  ticket2  = new EvaluationTicket(loadedGenome2, agentGenomesList2, 1, 1000);
        TournamentMatchup matchup2 = new TournamentMatchup(1, ticket2, 1, competitorIDs);

        round1.matchupList.Add(matchup2);

        // Matchup3:
        savename = "env3";
        path     = Application.dataPath + "/IndividualSaves/Environments/" + savename + ".json";
        // Read the json from the file into a string
        dataAsJson = File.ReadAllText(path);
        EnvironmentGenome  loadedGenome3     = JsonUtility.FromJson <EnvironmentGenome>(dataAsJson);
        List <AgentGenome> agentGenomesList3 = new List <AgentGenome>();

        agentGenomesList3.Add(teamsConfig.playersList[0].agentGenomeList[0]);
        EvaluationTicket  ticket3  = new EvaluationTicket(loadedGenome3, agentGenomesList3, 1, 1000);
        TournamentMatchup matchup3 = new TournamentMatchup(2, ticket3, 2, competitorIDs);

        round1.matchupList.Add(matchup3);


        tournamentRoundList.Add(round1);
    }