예제 #1
0
    public void SetWinnerObjectData(TournamentWinner winner)
    {
        txtWinnerName.text        = winner.Winner_Name;
        txtWinningAmount.text     = Utility.GetCurrencyPrefix() + winner.Winning_Amount.RoundTo2DigitFloatingPoint();
        txtWinningPercentage.text = winner.WinningPercentage.RoundTo2DigitFloatingPoint() + "%";

        imgWinnerProfile.sprite = spInitialSprite;

        profilePicURL = winner.Profile_Pic;
    }
    public void SetTournamentWinnerDetails(string winnerInfo)
    {
        isTournamentWinnersDeclared = true;

        JSONArray arr = new JSONArray(winnerInfo);

        if (arr.Count() > 0)
        {
            DestroyAllObjects();
        }

        winnerObjectList = new List <GameObject> ();

        List <TournamentWinner> tournamentWinnerList = new List <TournamentWinner> ();

        for (int i = 0; i < arr.Count(); i++)
        {
            TournamentWinner winner = JsonUtility.FromJson <TournamentWinner> (arr.getString(i));
            tournamentWinnerList.Add(winner);

            GameObject obj = Instantiate(winnerObjPrefab) as GameObject;
            obj.transform.SetParent(scrollViewContent.transform);
            obj.transform.localScale = Vector3.one;

            obj.GetComponent <TournamentWinnerObject> ().SetWinnerObjectData(winner);

            winnerObjectList.Add(obj);
        }

        SetContentHeight(arr.Count());

        if (Time.time - gameWinnerDeclaredAt <= 5)
        {
            Invoke("DisplayTournamentWinnerObject", Constants.RESET_GAME_DATA_AFTER);
        }
        else
        {
            Invoke("DisplayTournamentWinnerObject", 2);
        }
    }
예제 #3
0
        public void CalcWinner_PythonWonMostRounds_TeamWithMostPointsWins()
        {
            List <List <string> > competitions = new List <List <string> >();
            List <int>            results      = new List <int> {
                0, 0, 1
            };

            competitions.Add(new List <string> {
                "HTML", "C#"
            });
            competitions.Add(new List <string> {
                "C#", "Python"
            });
            competitions.Add(new List <string> {
                "Python", "HTML"
            });
            string expected = "python";

            string answer = TournamentWinner.CalcWinner(competitions, results);

            Assert.That(answer, Is.EqualTo(expected).IgnoreCase);
        }
예제 #4
0
        protected override void AddToNewPopulation <Element>(List <Individual <Element, Tuple <double, double> > > population,
                                                             List <Individual <Element, Tuple <double, double> > > newPopulation)
        {
            List <int> indices = Utils.CreateIndexList(population.Count);

            if (axes == 1)
            {
                for (int i = 0; i < population.Count; ++i)
                {
                    shuffler.Shuffle(indices);

                    newPopulation.Add(new Individual <Element, Tuple <double, double> >(TournamentWinner(population, indices, (0.5, 0.5))));
                }
            }
            else
            {
                for (int i = 0; i < axes; i++)
                {
                    double angle = ((double)i / (axes - 1)) * Math.PI / 2;
                    (double, double)weights = (Math.Cos(angle), Math.Sin(angle));
                    for (int j = newPopulation.Count; j < (double)i / axes * population.Count; j++)
                    {
                        newPopulation.Add(new Individual <Element, Tuple <double, double> >(TournamentWinner(population, indices, weights)));
                    }
                }
            }
        }