public void TestRankingMethod()
        {
            var ranklist = new Ranking<IPlayer>();
            var expect = 0;

            Assert.AreEqual(expect, ranklist.Count);
        }
    void Start()
    {
        DEF.Init();
        GameObject hand = GameObject.Find("Background");
    
        if (hand != null)
        {
    
            hand.transform.localScale = new Vector3(DEF.sx_ortho, DEF.sy_ortho, 1);
        }

    
       if (ScoreControl.UserName.Length >= 5)
       // if(true)
        {
            PostHightScore();
            getHightScore();
            loadRanking = true;
            NGUITools.SetActive(PanelBoard, true);
            NGUITools.SetActive(PanelInputName, false);
        }
        else
        {
            loadRanking = false;
            NGUITools.SetActive(PanelBoard, false);

        }
        DEF.ScaleAnchorGui();

        instance = this;
    }
        public void TestRankingMethodAdd()
        {
            var humanPlayer = new HumanPlayer("Ivan", "3456");
            var ranklist = new Ranking<IPlayer>();
            ranklist.Add(humanPlayer);
            var expect = 1;

            Assert.AreEqual(expect, ranklist.Count);
        }
        public void TestRankingMethodMoveNext()
        {
            var humanPlayer = new HumanPlayer("Ivan", "3456");
            var ranklist = new Ranking<IPlayer>();
            ranklist.Add(humanPlayer);
            var move = ranklist.MoveNext();

            Assert.IsTrue(move);
        }
        public void TestRankingMethodDispose()
        {
            var humanPlayer = new HumanPlayer("Ivan", "3456");
            var ranklist = new Ranking<IPlayer>();
            ranklist.Add(humanPlayer);

            ranklist.Dispose();

            ////TODO
        }
Exemplo n.º 6
0
    void Awake()
    {
        if (!mInstance)
            mInstance = this;
        else
        {
            Destroy(this.gameObject);
            return;
        }

        DontDestroyOnLoad(this.gameObject);

        loginManager = GetComponent<LoginManager>();
        userData = GetComponent<UserData>();
        ranking = GetComponent<Ranking>();
           // userData.Init();
    }
Exemplo n.º 7
0
    void Awake()
    {
        if (!mInstance)
            mInstance = this;
        else
        {
            Destroy(this.gameObject);
            return;
        }

        DontDestroyOnLoad(this.gameObject);

        loginManager = GetComponent<LoginManager>();
        facebookFriends = GetComponent<FacebookFriends>();
        userData = GetComponent<UserData>();
        userHiscore = GetComponent<UserHiscore>();
        ranking = GetComponent<Ranking>();
        challengesManager = GetComponent<ChallengersManager>();
        challengeData = GetComponent<ChallengeData>();
        userData.Init();
    }
Exemplo n.º 8
0
        public PreferenceSet(string distribution, string dimension, Trajectory track, int iter, 
            bool extended, int numFeat, int model, string stepwiseBias, Ranking rank, Features.Mode featMode, DirectoryInfo data)
            : base(distribution, dimension, track, iter, extended, numFeat, model, stepwiseBias, featMode, data)
        {
            FileInfo trainingFileInfo = new FileInfo(FileInfo.FullName);

            this.FileInfo =
                new FileInfo(string.Format(
                    @"{0}\Training\{1}.diff.{2}.csv", data.FullName,
                    FileInfo.Name.Substring(0, FileInfo.Name.Length - FileInfo.Extension.Length), (char) rank));

            Data.Columns.Add("Rank", typeof (int));

            var ranking = rank;
            switch (ranking)
            {
                case Ranking.All:
                    _rankingFunction = AllRankings;
                    break;
                case Ranking.Basic:
                    _rankingFunction = BasicRanking;
                    break;
                case Ranking.FullPareto:
                    _rankingFunction = FullParetoRanking;
                    break;
                case Ranking.PartialPareto:
                    _rankingFunction = PartialParetoRanking;
                    break;
            }

            if (FeatureMode == Features.Mode.Local)
                ApplyAll(Retrace, null, null);
            else
                Read(trainingFileInfo);

            _diffData = new List<Preference>[NumInstances, NumDimension];
            for (int pid = 1; pid <= AlreadySavedPID; pid++)
                for (int step = 0; step < NumDimension; step++)
                    _diffData[pid - 1, step] = new List<Preference>();
        }
Exemplo n.º 9
0
 public void Update(Ranking ranking)
 {
     _rankings.Update(ranking);
 }
Exemplo n.º 10
0
 public void Add(Ranking ranking)
 {
     _rankings.Add(ranking);
 }
Exemplo n.º 11
0
        public void GetScores_ValidClubAndTeam_ValidScores()
        {
            StandenMonitorScraper scraper = MockRepository.GeneratePartialMock<StandenMonitorScraper>();
            _standenDao.StandenMonitorScraper = scraper;
            Club someClub = new Club { Code = "HH11AS0" };
            Team someTeam = new Team { Code = "17303-42354", AgeClass = "001", Name = "AMVJ H2", Sex = "1"};
            //DateTime forDate = new DateTime(2009, 12, 20);
            DateTime startDatum = new DateTime(2009, 12, 13, 13, 55, 1);

            scraper.Stub(x => x.GetHtml("")).IgnoreArguments().Return(_dummyHtml);
            Ranking ranking = _standenDao.GetRanking(someClub, someTeam, startDatum);

            Ranking expectedRanking = new Ranking();
            expectedRanking.Scores = new List<Score>
                                     	{
                                     		new Score { Team = "AthenA H2", Points = 31 },
                                            new Score { Team = "Myra H3", Points = 27 },
                                            new Score { Team = "Pinoké H8", Points = 24 },
                                            new Score { Team = "Hurley H6", Points = 23 },
                                            new Score { Team = "Amsterdam H10", Points = 22 },
                                            new Score { Team = "Pinoké H11", Points = 19 },
                                            new Score { Team = "Xenios H3", Points = 17 },
                                            new Score { Team = "HIC H4", Points = 15 },
                                            new Score { Team = "AMVJ H2", Points = 10 },
                                            new Score { Team = "Amsterdam H11", Points = 9 },
                                            new Score { Team = "VVV H4", Points = 6 },
                                            new Score { Team = "Castricum H2", Points = 5 },
                                     	};
            Assert.That(ranking.Scores.Count, Is.EqualTo(expectedRanking.Scores.Count));

            for (int position = 0; position < expectedRanking.Scores.Count; position++)
            {
                Score expectedScore = expectedRanking.Scores[position];
                Score actualScore = ranking.Scores[position];

                Assert.That(actualScore.Team, Is.EqualTo(expectedScore.Team));
                Assert.That(actualScore.Points, Is.EqualTo(expectedScore.Points));
            }
        }
Exemplo n.º 12
0
 public GearInfo getGearInfo(Faction f, TroopType tt, Ranking rk)
 {
     return(getTroopInfo(f, tt, rk).gear);
 }
Exemplo n.º 13
0
 public int getBattleValue(Faction f, TroopType tt, Ranking rk)
 {
     return(getTroopInfo(f, tt, rk).battleValue);
 }
Exemplo n.º 14
0
    public TroopInfo imperialGetTroopInfoHelper(TroopType tt, Ranking rk)
    {
        TroopInfo result = new TroopInfo();

        switch (tt)
        {
        case TroopType.recruitType:
            result.battleValue = 10;
            result.model       = imperialRecruit;
            break;

        case TroopType.crossbowman:
            switch (rk)
            {
            case Ranking.militia:
                result.battleValue = 20;
                result.model       = imperialMilitiaCrossbowman;
                break;

            case Ranking.veteran:
                result.battleValue = 50;
                result.model       = imperialVeteranCrossbowman;
                break;

            case Ranking.elite:
                result.battleValue = 150;
                result.model       = imperialEliteCrossbowman;
                break;
            }
            break;

        case TroopType.musketeer:
            switch (rk)
            {
            case Ranking.militia:
                result.battleValue = 20;
                result.model       = imperialMilitiaMusketeer;
                break;

            case Ranking.veteran:
                result.battleValue = 50;
                result.model       = imperialVeteranMusketeer;
                break;

            case Ranking.elite:
                result.battleValue = 150;
                result.model       = imperialEliteMusketeer;
                break;
            }
            break;

        case TroopType.swordsman:
            switch (rk)
            {
            case Ranking.militia:
                result.battleValue = 20;
                result.model       = imperialMilitiaSwordsman;
                break;

            case Ranking.veteran:
                result.battleValue = 50;
                result.model       = imperialVeteranSwordsman;
                break;

            case Ranking.elite:
                result.battleValue = 150;
                result.model       = imperialEliteSwordsman;
                break;
            }
            break;

        case TroopType.halberdier:
            switch (rk)
            {
            case Ranking.militia:
                result.battleValue = 20;
                result.model       = imperialMilitiaHalberdier;
                break;

            case Ranking.veteran:
                result.battleValue = 50;
                result.model       = imperialVeteranHalberdier;
                break;

            case Ranking.elite:
                result.battleValue = 150;
                result.model       = imperialEliteHalberdier;
                break;
            }
            break;

        case TroopType.cavalry:
            switch (rk)
            {
            case Ranking.militia:
                result.battleValue = 20;
                result.model       = imperialMilitiaCavalry;
                break;

            case Ranking.veteran:
                result.battleValue = 50;
                result.model       = imperialVeteranCavalry;
                break;

            case Ranking.elite:
                result.battleValue = 150;
                result.model       = imperialEliteCavalry;
                break;
            }
            break;
        }
        result.gear = new GearInfo(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
        return(result);
    }
        public async Task <ActionResult> PostRanking(string strid, Ranking ranking)
        {
            AllCollegeCourseModel SingleCourse = await CoursesControllerUtl.ByIdWholeWorkForAll <AllCollegeCourseModel>(domain, "AllCollege", strid);

            return(PartialView(SingleCourse));
        }
Exemplo n.º 16
0
    private void MonitorRanking()
    {
        // if (HandleFirebase.instance != null)
        // {
        double xp = 1000;//HandleFirebase.instance.thisPlayer.XP;

        // will probably break this out further into color levels for each stage
        if (xp < 5000)
        {
            myRanking = Ranking.Noob;
        }
        if (xp >= 5000 && xp < 10000)
        {
            myRanking = Ranking.Pro;
        }
        if (xp >= 10000 && xp < 16000)
        {
            myRanking = Ranking.Master;
        }

        if (xp >= 16000 && xp < 24000)
        {
            myRanking = Ranking.Spotter;
        }
        if (xp >= 24000 && xp < 30000)
        {
            myRanking = Ranking.Pro_Spotter;
        }
        if (xp >= 30000 && xp < 37000)
        {
            myRanking = Ranking.Master_Spotter;
        }

        if (xp >= 37000 && xp < 44000)
        {
            myRanking = Ranking.Finder;
        }
        if (xp >= 44000 && xp < 53000)
        {
            myRanking = Ranking.Pro_Finder;
        }
        if (xp >= 53000 && xp < 62000)
        {
            myRanking = Ranking.Master_Finder;
        }

        if (xp >= 62000 && xp < 70000)
        {
            myRanking = Ranking.Gatherer;
        }
        if (xp >= 70000 && xp < 78000)
        {
            myRanking = Ranking.Pro_Gatherer;
        }
        if (xp >= 78000 && xp < 87000)
        {
            myRanking = Ranking.Master_Gatherer;
        }

        if (xp >= 87000 && xp < 100000)
        {
            myRanking = Ranking.Forager;
        }
        if (xp >= 100000 && xp < 110000)
        {
            myRanking = Ranking.Pro_Forager;
        }
        if (xp >= 110000 && xp < 130000)
        {
            myRanking = Ranking.Master_Forager;
        }

        if (xp >= 130000 && xp < 150000)
        {
            myRanking = Ranking.Discoverer;
        }
        if (xp >= 150000 && xp < 175000)
        {
            myRanking = Ranking.Pro_Discoverer;
        }
        if (xp >= 175000 && xp < 200000)
        {
            myRanking = Ranking.Master_Discoverer;
        }

        if (xp >= 200000 && xp < 250000)
        {
            myRanking = Ranking.Collector;
        }
        if (xp >= 250000 && xp < 300000)
        {
            myRanking = Ranking.Pro_Collector;
        }
        if (xp >= 300000 && xp < 400000)
        {
            myRanking = Ranking.Master_Collector;
        }

        if (xp >= 400000 && xp < 500000)
        {
            myRanking = Ranking.Hoarder;
        }
        if (xp >= 500000 && xp < 600000)
        {
            myRanking = Ranking.Pro_Hoarder;
        }
        if (xp >= 600000 && xp < 700000)
        {
            myRanking = Ranking.Master_Hoarder;
        }

        if (xp >= 700000 && xp < 820000)
        {
            myRanking = Ranking.Scrounge;
        }
        if (xp >= 820000 && xp < 1000000)
        {
            myRanking = Ranking.Pro_Scrounge;
        }
        if (xp >= 1000000 && xp < 1250000)
        {
            myRanking = Ranking.Master_Scrounge;
        }

        if (xp >= 1250000 && xp < 1500000)
        {
            myRanking = Ranking.Hunter;
        }
        if (xp >= 1500000 && xp < 1750000)
        {
            myRanking = Ranking.Pro_Hunter;
        }
        if (xp >= 1750000 && xp < 2000000)
        {
            myRanking = Ranking.Master_Hunter;
        }

        if (xp >= 2000000 && xp < 2500000)
        {
            myRanking = Ranking.Connoisseur;
        }
        if (xp >= 2500000 && xp < 3000000)
        {
            myRanking = Ranking.Pro_Connoisseur;
        }
        if (xp >= 3000000 && xp < 3750000)
        {
            myRanking = Ranking.Master_Connoisseur;
        }

        if (xp >= 3750000 && xp < 4500000)
        {
            myRanking = Ranking.Curator;
        }
        if (xp >= 4500000 && xp < 5250000)
        {
            myRanking = Ranking.Pro_Curator;
        }
        if (xp >= 5250000 && xp < 6200000)
        {
            myRanking = Ranking.Master_Curator;
        }

        if (xp >= 6200000 && xp < 7000000)
        {
            myRanking = Ranking.Adventurer;
        }
        if (xp >= 7000000 && xp < 7800000)
        {
            myRanking = Ranking.Pro_Adventurer;
        }
        if (xp >= 7800000 && xp < 10000000)
        {
            myRanking = Ranking.Master_Adventurer;
        }

        if (xp >= 10000000 && xp < 12000000)
        {
            myRanking = Ranking.Scavenger;
        }
        if (xp >= 12000000 && xp < 17000000)
        {
            myRanking = Ranking.Pro_Scavenger;
        }
        if (xp >= 17000000 && xp < 20000000)
        {
            myRanking = Ranking.Master_Scavenger;
        }

        if (xp >= 20000000 && xp < 30000000)
        {
            myRanking = Ranking.Mega_Master;
        }
        if (xp >= 30000000 && xp < 40000000)
        {
            myRanking = Ranking.Elite_Master;
        }
        if (xp >= 40000000 && xp < 50000000)
        {
            myRanking = Ranking.Ultra_Master;
        }
        if (xp >= 50000000 && xp < 100000000)
        {
            myRanking = Ranking.Divine_Master;
        }
        if (xp >= 100000000)
        {
            myRanking = Ranking.Infinite_Master;
        }
        // }
        // else
        // {//testing in dev mode
        //     myRanking = Ranking.DEV;
        // }
    }
        public async Task InsertRankingAsync(Ranking entry)
        {
            await _db.AddAsync(entry);

            await _db.SaveChangesAsync();
        }
Exemplo n.º 18
0
        public void ReadFromStream(SerializationReader r)
        {
            Artist = r.ReadString();
            if (_version >= OsuVersions.FirstOsz2)
            {
                ArtistUnicode = r.ReadString();
            }
            Title = r.ReadString();
            if (_version >= OsuVersions.FirstOsz2)
            {
                TitleUnicode = r.ReadString();
            }
            Creator         = r.ReadString();
            Version         = r.ReadString();
            AudioFileName   = r.ReadString();
            BeatmapChecksum = r.ReadString();   //always 32 in length, so the 2 preceding bytes in the file are practically wasting space
            BeatmapFileName = r.ReadString();

            RankedStatus     = (SubmissionStatus)r.ReadByte();
            CountHitCircles  = r.ReadUInt16();
            CountSliders     = r.ReadUInt16();
            CountSpinners    = r.ReadUInt16();
            LastModifiedTime = r.ReadDateTime();

            if (_version >= OsuVersions.FloatDifficultyValues)
            {
                ApproachRate     = r.ReadSingle();
                CircleSize       = r.ReadSingle();
                HPDrainRate      = r.ReadSingle();
                OveralDifficulty = r.ReadSingle();
            }
            else
            {
                ApproachRate     = r.ReadByte();
                CircleSize       = r.ReadByte();
                HPDrainRate      = r.ReadByte();
                OveralDifficulty = r.ReadByte();
            }

            SliderVelocity = r.ReadDouble();

            if (_version >= OsuVersions.FloatDifficultyValues)
            {
                DiffStarRatingStandard = r.ReadDictionary <Mods, double>();
                DiffStarRatingTaiko    = r.ReadDictionary <Mods, double>();
                DiffStarRatingCtB      = r.ReadDictionary <Mods, double>();
                DiffStarRatingMania    = r.ReadDictionary <Mods, double>();

                // TODO: there may be different reading behavior for versions before 20190204, 20200916, 20200504 and 20191024 here.
            }

            DrainTimeSeconds = r.ReadInt32();
            TotalTime        = r.ReadInt32();
            AudioPreviewTime = r.ReadInt32();

            TimingPoints = r.ReadSerializableList <TimingPoint>();
            BeatmapId    = r.ReadInt32();
            BeatmapSetId = r.ReadInt32();
            ThreadId     = r.ReadInt32();

            GradeStandard = (Ranking)r.ReadByte();
            GradeTaiko    = (Ranking)r.ReadByte();
            GradeCtB      = (Ranking)r.ReadByte();
            GradeMania    = (Ranking)r.ReadByte();

            OffsetLocal   = r.ReadInt16();
            StackLeniency = r.ReadSingle();
            GameMode      = (GameMode)r.ReadByte();

            SongSource   = r.ReadString();
            SongTags     = r.ReadString();
            OffsetOnline = r.ReadInt16();
            TitleFont    = r.ReadString();
            Unplayed     = r.ReadBoolean();
            LastPlayed   = r.ReadDateTime();

            IsOsz2     = r.ReadBoolean();
            FolderName = r.ReadString();
            LastCheckAgainstOsuRepo = r.ReadDateTime();

            IgnoreBeatmapSounds = r.ReadBoolean();
            IgnoreBeatmapSkin   = r.ReadBoolean();
            DisableStoryBoard   = r.ReadBoolean();
            DisableVideo        = r.ReadBoolean();
            VisualOverride      = r.ReadBoolean();
            if (_version < OsuVersions.FloatDifficultyValues)
            {
                OldUnknown1 = r.ReadInt16();
            }
            LastEditTime     = r.ReadInt32();
            ManiaScrollSpeed = r.ReadByte();
        }
Exemplo n.º 19
0
 public void ResetRanking()
 {
     ranking = RankingManager.LoadRanking();
     writeRanking();
 }
Exemplo n.º 20
0
 // Use this for initialization
 void Start()
 {
     ranking = RankingManager.LoadRanking();
     writeRanking();
 }
Exemplo n.º 21
0
        public Task GenerarRanking(int surveyCompletionId)
        {
            var parentSurveyCompletionByDemanda = this.modelContext
                                                  .SurveyCompletionParent
                                                  .Include("SurveyCompletions.Questions.QuestionObj.AnswerType")
                                                  .Include("SurveyCompletions.Questions.QuestionObj.Answers")
                                                  .Include("SurveyCompletions.Questions.Answers")
                                                  .Include("Category")
                                                  .Single(x => x.Id == surveyCompletionId);

            var parentSurveysCompletionsByOferta = this.modelContext
                                                   .SurveyCompletionParent
                                                   .Include("SurveyCompletions.Questions")
                                                   .Include("SurveyCompletions.Questions.Answers")
                                                   .Where(x =>
                                                          //x.SurveyId == surveyCompletionByDemand.SurveyId &&
                                                          x.Role.Name == "Oferta" &&
                                                          x.Category.Id == parentSurveyCompletionByDemanda.Category.Id &&
                                                          x.Status == "Aprobado" &&
                                                          x.DeletedAt == null &&
                                                          x.Company != null &&
                                                          x.Product != null)
                                                   .ToList();

            var rankings = new List <Ranking>();

            foreach (var parentSurveyCompletionByOferta in parentSurveysCompletionsByOferta)
            {
                var ranking = new Ranking()
                {
                    SurveyCompletionParentByDemanda = parentSurveyCompletionByDemanda,
                    SurveyCompletionParentByOferta  = parentSurveyCompletionByOferta,
                    Rank = 0
                };

                foreach (var surveyCompletionByDemanda in parentSurveyCompletionByDemanda.SurveyCompletions)
                {
                    foreach (var demandaQuestion in surveyCompletionByDemanda.Questions)
                    {
                        /*SurveyCompletionQuestion supplyQuestion = null;
                         * int answersCountTotal = 0;
                         * foreach (var surveyCompletionBySupplySingle in surveyCompletionBySupply.SurveyCompletions)
                         * {
                         *  supplyQuestion = surveyCompletionByDemandSingle
                         *      .Questions
                         *      .Where(x => x.QuestionId == surveyCompletionDemandQuestion.QuestionId)
                         *      .FirstOrDefault();
                         *
                         *  answersCountTotal = this.modelContext
                         *      .Surveys
                         *      .Include("Questions")
                         *      .Include("Questions.Answers")
                         *      .FirstOrDefault(x => x.Id == surveyCompletionByDemandSingle.SurveyId)
                         *      .Questions
                         *      .FirstOrDefault(x => x.Id == surveyCompletionDemandQuestion.QuestionId)
                         *      .Answers
                         *      .Count();
                         * }*/

                        var surveyCompletion = parentSurveyCompletionByOferta
                                               .SurveyCompletions
                                               .Where(s =>
                                                      s.Questions.Where(q =>
                                                                        q.QuestionId == demandaQuestion.QuestionId
                                                                        ).Count() == 1
                                                      )
                                               .FirstOrDefault();

                        if (surveyCompletion != null)
                        {
                            SurveyCompletionQuestion supplyQuestion = surveyCompletion.Questions.FirstOrDefault(q => q.QuestionObj.Old == false);

                            int answersCountTotal         = demandaQuestion.Answers.Count();
                            int possibleAnswersCountTotal = demandaQuestion.QuestionObj.Answers.Count();
                            int possibleAnswersSumTotal   = demandaQuestion.QuestionObj.Answers.Sum(x => x.Value);

                            if (supplyQuestion != null)
                            {
                                var answerTypeName = demandaQuestion.QuestionObj.AnswerType.Name;

                                if (answerTypeName != "Multiple")
                                {
                                    foreach (var supplyAnswer in supplyQuestion.Answers)
                                    {
                                        var rakingValue  = 0;
                                        var demandAnswer = demandaQuestion.Answers.FirstOrDefault();
                                        int result       = 0;
                                        if (demandAnswer != null)
                                        {
                                            if (possibleAnswersCountTotal == possibleAnswersSumTotal)
                                            {
                                                //Comparando respuestas excluyentes entre si
                                                result = demandAnswer.Answer == supplyAnswer.Answer ? 10 : 0;
                                            }
                                            else
                                            {
                                                //Comparando respuestas que incluyen la funcionalidad de la anterior

                                                result = this.getRankingValue(
                                                    this.getAnswerValueInScale(answersCountTotal, demandAnswer.AnswerValue),
                                                    this.getAnswerValueInScale(answersCountTotal, supplyAnswer.AnswerValue));
                                            }
                                        }
                                        rakingValue  = result;
                                        ranking.Rank = ranking.Rank + rakingValue;
                                    }
                                }
                                else
                                {
                                    if (answersCountTotal > 0)
                                    {
                                        int supportedAnswers = supplyQuestion.Answers.Select(x => x.Answer).Intersect(demandaQuestion.Answers.Select(x => x.Answer)).Count();
                                        ranking.Rank += (MaxValuePerAnswer * supportedAnswers) / answersCountTotal;
                                    }
                                }
                            }
                        }
                    }
                }

                rankings.Add(ranking);
            }

            this.modelContext.Rankings.AddRange(rankings);
            this.modelContext.SaveChanges();

            return(Task.FromResult(true));
        }
Exemplo n.º 22
0
        private List <Individual <Element, Tuple <double, double> > > Elitism <Element>(List <Individual <Element, Tuple <double, double> > > population,
                                                                                        Ranking <Element> ranking)
        {
            List <Individual <Element,
                              Tuple <double, double> > > modifiedPopulation = modifyPopulation ? population :
                                                                              new List <Individual <Element,
                                                                                                    Tuple <double, double> > >(population);

            foreach (Individual <Element, Tuple <double, double> > individual in modifiedPopulation)
            {
                ranking.Add(individual);
            }

            ranking.Update();
            ranking.RemoveFrom(population.Count);

            modifiedPopulation.Clear();
            modifiedPopulation.AddRange(ranking.RankingList);

            return(modifiedPopulation);
        }
Exemplo n.º 23
0
        public void TestCalcRank()
        {
            double result = Ranking.CalculateNewRank(0.5, 150, 20);

            Assert.AreEqual(0.0012465, result, 0.01, "Rank was not calculated.");
        }
Exemplo n.º 24
0
    private static void ksubset_colex_check_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    KSUBSET_COLEX_CHECK_TEST tests KSUBSET_COLEX_CHECK.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    14 January 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int k = 0;
        int n = 0;

        int[] s  = new int[1];
        int[] s2 =
        {
            5, 3, 2
        }

        ;
        int[] s3 =
        {
            5, 2, 3
        }

        ;
        int[] s4 =
        {
            7, 3, 2
        }

        ;
        int[] s5 =
        {
            5, 3, 2
        }

        ;
        int test;

        Console.WriteLine("");
        Console.WriteLine("KSUBSET_COLEX_CHECK TEST");
        Console.WriteLine("  KSUBSET_COLEX_CHECK checks a K subset of an N set.");

        for (test = 1; test <= 7; test++)
        {
            switch (test)
            {
            case 1:
                k = -1;
                n = 5;
                s = null;
                break;

            case 2:
                k = 3;
                n = 0;
                s = typeMethods.i4vec_copy_new(k, s2);
                break;

            case 3:
                k = 3;
                n = 5;
                s = typeMethods.i4vec_copy_new(k, s3);
                break;

            case 4:
                k = 3;
                n = 5;
                s = typeMethods.i4vec_copy_new(k, s4);
                break;

            case 5:
                k = 3;
                n = 5;
                s = typeMethods.i4vec_copy_new(k, s5);
                break;

            case 6:
                k = 0;
                n = 5;
                s = null;
                break;

            case 7:
                k = 0;
                n = 0;
                s = null;
                break;
            }

            bool check = Ranking.ksubset_colex_check(k, n, s);
            typeMethods.i4vec_transpose_print(k, s, "  Subset:");
            Console.WriteLine("  N = " + n + ", K = " + k + "");
            Console.WriteLine("  Check = " + check + "");
        }
    }
Exemplo n.º 25
0
        public RankingViewModel GetRankingOfWin(int?cycle, int num, string userID, bool isAdmin)
        {
            int maxRanking               = 500;
            RankingViewModel vr          = new RankingViewModel();
            List <Ranking>   rankinglist = new List <Ranking>();

            cycle = (cycle.HasValue ? cycle : 1);
            DateTime sdate, edate;

            sdate = DateTime.Today;
            edate = DateTime.Today.AddDays(1);

            switch (cycle)
            {
            case 1:
                sdate = DateTime.Today;
                edate = DateTime.Today.AddDays(1);
                break;

            case 2:
                sdate = DateTime.Now.AddDays(((int)DateTime.Now.DayOfWeek - 1) * -1);
                edate = DateTime.Today.AddDays(1);
                break;

            case 3:
                sdate = DateTime.Parse(DateTime.Now.ToString("yyyy/MM/") + "01");
                edate = DateTime.Today.AddDays(1);
                break;

            case 4:
                string fmonth = "";
                switch (DateTime.Today.Month)
                {
                case 1:
                case 2:
                case 3:
                    fmonth = "01";
                    break;

                case 4:
                case 5:
                case 6:
                    fmonth = "04";
                    break;

                case 7:
                case 8:
                case 9:
                    fmonth = "07";
                    break;

                case 10:
                case 11:
                case 12:
                    fmonth = "10";
                    break;
                }
                sdate = DateTime.Parse(DateTime.Now.ToString("yyyy/") + fmonth + "/01");
                edate = DateTime.Today.AddDays(1);
                break;

            case 10:
                Seasons s = new SeasonsRepository().GetNowSeason();
                sdate = s.sdate;
                edate = s.edate;
                break;
            }

            //舊
            string sqlquery = @"
select rank() over(order by ars.assets desc) ord,u.Id, u.UserName, u.Email, u.Name,ars.assets
from (
	SELECT top {num} ar.UserId, sum(ar.assets) as assets
	FROM AssetsRecord ar
	where ar.type in (1,-4) 
	and ar.UserId <>{userID}
	and ar.inpdate between {sdate} and {edate}
	and exists(
		select *
		from Users
		where Id=ar.UserId
		and (isnull(LockoutEndDateUtc,'19110101')<GETUTCDATE() or LockoutEnabled=0)
	)
	group by ar.UserId
	having sum(ar.assets)>0
	order by sum(ar.assets) desc
	union
	SELECT u.Id as UserId, isnull(sum(ar.assets),0) as assets
	FROM Users u
	left join AssetsRecord ar on u.Id=ar.UserId
	and ar.type in (1,-4) 
	and ar.inpdate between {sdate} and {edate}
	where u.Id={userID}
	and (isnull(LockoutEndDateUtc,'19110101')<GETUTCDATE() or LockoutEnabled=0)
	group by u.Id
) as ars
join Users u on u.Id=ars.UserId
order by ars.assets desc
";

            /* string sqlquery = @"
             * select rank() over(order by ars.assets desc) ord,u.Id, u.UserName, u.Email, u.Name,ars.assets
             * from (
             * SELECT top {num} ar.UserId, sum(ar.assets) as assets
             * FROM AssetsRecord ar
             * where ar.type = 1
             * and ar.UserId <>{userID}
             * and ar.inpdate between {sdate} and {edate}
             * and exists(
             *   select *
             *   from Users
             *   where Id=ar.UserId
             *   and (isnull(LockoutEndDateUtc,'19110101')<GETUTCDATE() or LockoutEnabled=0)
             * )
             * group by ar.UserId
             * having sum(ar.assets)>0
             * order by sum(ar.assets) desc
             * union
             * SELECT u.Id as UserId, isnull(sum(ar.assets),0) as assets
             * FROM Users u
             * left join AssetsRecord ar on u.Id=ar.UserId
             * and ar.type in (1,-4)
             * and ar.inpdate between {sdate} and {edate}
             * where u.Id={userID}
             * and (isnull(LockoutEndDateUtc,'19110101')<GETUTCDATE() or LockoutEnabled=0)
             * group by u.Id
             * ) as ars
             * join Users u on u.Id=ars.UserId
             * order by ars.assets desc
             * ";*/


            vr.rankinglist = new List <Ranking>();
            using (IDbConnection cn = new SqlConnection(WebConfigurationManager.ConnectionStrings["SQLData"].ConnectionString.ToString()))
            {
                sqlquery = sqlquery.Replace("{sdate}", "'" + sdate.ToString("yyyy-MM-dd HH:mm:ss") + "'");
                sqlquery = sqlquery.Replace("{edate}", "'" + edate.ToString("yyyy-MM-dd HH:mm:ss") + "'");
                sqlquery = sqlquery.Replace("{num}", maxRanking.ToString());
                sqlquery = sqlquery.Replace("{userID}", "'" + userID + "'");
                using (var multi = cn.QueryMultiple(sqlquery))
                {
                    rankinglist = multi.Read <Ranking>().ToList();
                }

                int     userBeforOrd = 0;
                Ranking rk           = rankinglist.Where(p => p.ID == userID).FirstOrDefault();
                if (rk != null)
                {
                    userBeforOrd = int.Parse(rk.ord);

                    userBeforOrd = (int)Math.Round(((double)userBeforOrd - 1) / 10) * 10;
                }

                //隱藏username
                foreach (var r in rankinglist)
                {
                    if (int.Parse(r.ord) <= num || r.ID == userID || int.Parse(r.ord) == userBeforOrd)
                    {
                        if (!r.ID.Equals(userID) && !isAdmin)
                        {
                            int subl = (r.UserName.Length / 2);
                            subl       = (subl >= 3 ? 3 : subl);
                            r.UserName = r.UserName.Substring(0, subl) + "*****";
                            r.isUser   = false;
                        }
                        else
                        {
                            if (r.ID.Equals(userID))
                            {
                                r.isUser = true;
                            }
                        }
                        int iord;
                        if (int.TryParse(r.ord, out iord) && iord > maxRanking)
                        {
                            r.ord = maxRanking + "+";
                        }


                        vr.rankinglist.Add(r);
                    }
                }
            }
            vr.sdate = sdate;
            vr.edate = edate;
            return(vr);
        }
Exemplo n.º 26
0
    private static void cycle_to_perm_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    CYCLE_TO_PERM_TEST tests CYCLE_TO_PERM.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    28 July 2011
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int i;

        int[] index =
        {
            5, 1, 1
        }

        ;
        int[] t =
        {
            4, 2, 5, 3, 1, 6, 7
        }

        ;

        Console.WriteLine("");
        Console.WriteLine("CYCLE_TO_PERM_TEST");
        Console.WriteLine("  CYCLE_TO_PERM converts a permutation from");
        Console.WriteLine("  cycle to array form;");

        const int n      = 7;
        const int ncycle = 3;

        Console.WriteLine("");
        Console.WriteLine("  Cycle form:");
        Console.WriteLine("  Number of cycles is " + ncycle + "");
        Console.WriteLine("");
        int jlo = 0;

        for (i = 1; i <= ncycle; i++)
        {
            string cout = "";
            int    j;
            for (j = jlo + 1; j <= jlo + index[i - 1]; j++)
            {
                cout += "  " + t[j - 1].ToString().PadLeft(4);
            }

            Console.WriteLine(cout);
            jlo += index[i - 1];
        }

        int[] p = Ranking.cycle_to_perm(n, ncycle, t, index);

        Permutation.perm_print(n, p, "  Corresponding permutation:");
    }
Exemplo n.º 27
0
 public GameObject getTroopObject(Faction f, TroopType tt, Ranking rk)
 {
     return(getTroopInfo(f, tt, rk).model);
 }
Exemplo n.º 28
0
    private static void cycle_check_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    CYCLE_CHECK_TEST tests CYCLE_CHECK.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    16 January 2016
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int[] index  = new int[1];
        int[] index1 =
        {
            1, 4, 3
        }

        ;
        int[] index3 =
        {
            1, 4, 2
        }

        ;
        int[] index4 =
        {
            1, 4, 3
        }

        ;
        int[] index5 =
        {
            1, 4, 3
        }

        ;
        int[] index6 =
        {
            1, 4, 3
        }

        ;
        int n      = 0;
        int ncycle = 0;

        int[] t  = new int[1];
        int[] t1 =
        {
            5, 1, 3, 8, 6, 2, 4, 7
        }

        ;
        int[] t3 =
        {
            5, 1, 3, 8, 6, 2, 4, 7
        }

        ;
        int[] t4 =
        {
            5, 1, 3, 12, 6, 2, 4, 7
        }

        ;
        int[] t5 =
        {
            5, 1, 3, 8, 5, 2, 4, 7
        }

        ;
        int[] t6 =
        {
            5, 1, 3, 8, 6, 2, 4, 7
        }

        ;
        int test;

        Console.WriteLine("");
        Console.WriteLine("CYCLE_CHECK TEST");
        Console.WriteLine("  CYCLE_CHECK checks a permutation in cycle form.");

        for (test = 1; test <= 6; test++)
        {
            switch (test)
            {
            case 1:
                n      = 0;
                ncycle = 3;
                t      = typeMethods.i4vec_copy_new(8, t1);
                index  = typeMethods.i4vec_copy_new(ncycle, index1);
                break;

            case 2:
                n      = 8;
                ncycle = 0;
                t      = typeMethods.i4vec_copy_new(n, t1);
                index  = typeMethods.i4vec_copy_new(3, index1);
                break;

            case 3:
                n      = 8;
                ncycle = 3;
                t      = typeMethods.i4vec_copy_new(n, t3);
                index  = typeMethods.i4vec_copy_new(ncycle, index3);
                break;

            case 4:
                n      = 8;
                ncycle = 3;
                t      = typeMethods.i4vec_copy_new(n, t4);
                index  = typeMethods.i4vec_copy_new(ncycle, index4);
                break;

            case 5:
                n      = 8;
                ncycle = 3;
                t      = typeMethods.i4vec_copy_new(n, t5);
                index  = typeMethods.i4vec_copy_new(ncycle, index5);
                break;

            case 6:
                n      = 8;
                ncycle = 3;
                t      = typeMethods.i4vec_copy_new(n, t6);
                index  = typeMethods.i4vec_copy_new(ncycle, index6);
                break;
            }

            Console.WriteLine("");
            Console.WriteLine("  Permutation in cycle form:");
            Console.WriteLine("  Number of cycles is " + ncycle + "");
            Console.WriteLine("");
            int jlo = 0;
            int i;
            for (i = 0; i < ncycle; i++)
            {
                string cout = "    ";
                int    j;
                for (j = jlo; j < jlo + index[i]; j++)
                {
                    cout += "  " + t[j];
                }

                Console.WriteLine(cout);
                jlo += index[i];
            }

            bool check = Ranking.cycle_check(n, ncycle, t, index);
            Console.WriteLine("  Check = " + check + "");
        }
    }
Exemplo n.º 29
0
    public TroopInfo mercGetTroopInfoHelper(TroopType tt, Ranking rk)
    {
        TroopInfo result = new TroopInfo();

        if (rk == Ranking.mainChar)
        {
            if (tt == TroopType.mainCharType)
            {
                result.battleValue = 0;
                result.model       = mainCharacter;
                result.gear        = new GearInfo(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
            }
            else
            {
                result.battleValue = 0;
                result.model       = secCharacter;
                result.gear        = new GearInfo(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
            }
            return(result);
        }
        switch (tt)
        {
        case TroopType.recruitType:
            result.battleValue = 10;
            result.model       = mercenaryRecruit;
            result.gear        = new GearInfo(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f);

            break;

        case TroopType.crossbowman:
            switch (rk)
            {
            case Ranking.militia:
                result.battleValue = 20;
                result.model       = mercenaryMilitiaCrossbowman;
                result.gear        = new GearInfo(2.0f, 1.0f, 3.0f, 4.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f);
                break;

            case Ranking.veteran:
                result.battleValue = 50;
                result.model       = mercenaryVeteranCrossbowman;
                result.gear        = new GearInfo(4.0f, 2.0f, 5.0f, 6.0f, 6.0f, 7.0f, 2.0f, 4.0f, 6.0f);
                break;

            case Ranking.elite:
                result.battleValue = 150;
                result.model       = mercenaryEliteCrossbowman;
                result.gear        = new GearInfo(7.0f, 4.0f, 8.0f, 8.0f, 8.0f, 9.0f, 4.0f, 7.0f, 8.0f);
                break;
            }
            break;

        case TroopType.musketeer:
            switch (rk)
            {
            case Ranking.militia:
                result.battleValue = 40;
                result.model       = mercenaryMilitiaMusketeer;
                result.gear        = new GearInfo(2.0f, 1.0f, 3.0f, 4.0f, 1.0f, 2.0f, 1.0f, 3.0f, 2.0f);
                break;

            case Ranking.veteran:
                result.battleValue = 80;
                result.model       = mercenaryVeteranMusketeer;
                result.gear        = new GearInfo(4.0f, 2.0f, 3.0f, 4.0f, 4.0f, 5.0f, 3.0f, 7.0f, 5.0f);
                break;

            case Ranking.elite:
                result.battleValue = 150;
                result.model       = mercenaryEliteMusketeer;
                result.gear        = new GearInfo(7.0f, 5.0f, 8.0f, 7.0f, 7.0f, 7.0f, 5.0f, 9.0f, 7.0f);
                break;
            }
            break;

        case TroopType.swordsman:
            switch (rk)
            {
            case Ranking.militia:
                result.battleValue = 20;
                result.model       = mercenaryMilitiaSwordsman;
                result.gear        = new GearInfo(3.0f, 2.0f, 3.0f, 1.0f, 3.0f, 0.0f, 4.0f, 0.0f, 3.0f);
                break;

            case Ranking.veteran:
                result.battleValue = 50;
                result.model       = mercenaryVeteranSwordsman;
                result.gear        = new GearInfo(5.0f, 5.0f, 6.0f, 2.0f, 7.0f, 0.0f, 7.0f, 0.0f, 7.0f);
                break;

            case Ranking.elite:
                result.battleValue = 150;
                result.model       = mercenaryEliteSwordsman;
                result.gear        = new GearInfo(8.0f, 7.0f, 8.0f, 5.0f, 9.0f, 0.0f, 9.0f, 0.0f, 9.0f);
                break;
            }
            break;

        case TroopType.halberdier:
            switch (rk)
            {
            case Ranking.militia:
                result.battleValue = 20;
                result.model       = mercenaryMilitiaHalberdier;
                result.gear        = new GearInfo(4.0f, 4.0f, 1.0f, 2.0f, 1.0f, 0.0f, 4.0f, 0.0f, 1.0f);
                break;

            case Ranking.veteran:
                result.battleValue = 50;
                result.model       = mercenaryVeteranHalberdier;
                result.gear        = new GearInfo(7.0f, 7.0f, 2.0f, 3.0f, 2.0f, 0.0f, 7.0f, 0.0f, 4.0f);
                break;

            case Ranking.elite:
                result.battleValue = 150;
                result.model       = mercenaryEliteHalberdier;
                result.gear        = new GearInfo(9.0f, 9.0f, 4.0f, 6.0f, 5.0f, 0.0f, 9.0f, 0.0f, 6.0f);
                break;
            }
            break;

        case TroopType.cavalry:
            switch (rk)
            {
            case Ranking.militia:
                result.battleValue = 40;
                result.model       = mercenaryMilitiaCavalry;
                result.gear        = new GearInfo(4.0f, 4.0f, 1.0f, 2.0f, 1.0f, 0.0f, 4.0f, 0.0f, 3.0f);
                break;

            case Ranking.veteran:
                result.battleValue = 80;
                result.model       = mercenaryVeteranCavalry;
                result.gear        = new GearInfo(6.0f, 6.0f, 4.0f, 5.0f, 3.0f, 0.0f, 7.0f, 0.0f, 6.0f);
                break;

            case Ranking.elite:
                result.battleValue = 150;
                result.model       = mercenaryEliteCavalry;
                result.gear        = new GearInfo(9.0f, 9.0f, 6.0f, 7.0f, 7.0f, 0.0f, 10.0f, 0.0f, 9.0f);
                break;
            }
            break;
        }
        return(result);
    }
        /// <summary>
        /// Runs the SSNSGA-II algorithm.
        /// </summary>
        /// <returns>a <code>SolutionSet</code> that is a set of non dominated solutions as a result of the algorithm execution</returns>
        public override SolutionSet Execute()
        {
            int populationSize = -1;
            int maxEvaluations = -1;
            int evaluations;

            JMetalCSharp.QualityIndicator.QualityIndicator indicators = null; // QualityIndicator object
            int requiredEvaluations;                                          // Use in the example of use of the
            // indicators object (see below)

            SolutionSet population;
            SolutionSet offspringPopulation;
            SolutionSet union;

            Operator mutationOperator;
            Operator crossoverOperator;
            Operator selectionOperator;

            Distance distance = new Distance();

            //Read the parameters
            JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "maxEvaluations", ref maxEvaluations);
            JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "populationSize", ref populationSize);
            JMetalCSharp.Utils.Utils.GetIndicatorsFromParameters(this.InputParameters, "indicators", ref indicators);

            //Initialize the variables
            population  = new SolutionSet(populationSize);
            evaluations = 0;

            requiredEvaluations = 0;

            //Read the operators
            mutationOperator  = Operators["mutation"];
            crossoverOperator = Operators["crossover"];
            selectionOperator = Operators["selection"];

            // Create the initial solutionSet
            Solution newSolution;

            for (int i = 0; i < populationSize; i++)
            {
                newSolution = new Solution(Problem);
                Problem.Evaluate(newSolution);
                Problem.EvaluateConstraints(newSolution);
                evaluations++;
                population.Add(newSolution);
            }

            // Generations ...
            while (evaluations < maxEvaluations)
            {
                // Create the offSpring solutionSet
                offspringPopulation = new SolutionSet(populationSize);
                Solution[] parents = new Solution[2];

                //obtain parents
                parents[0] = (Solution)selectionOperator.Execute(population);
                parents[1] = (Solution)selectionOperator.Execute(population);

                // crossover
                Solution[] offSpring = (Solution[])crossoverOperator.Execute(parents);

                // mutation
                mutationOperator.Execute(offSpring[0]);

                // evaluation
                Problem.Evaluate(offSpring[0]);
                Problem.EvaluateConstraints(offSpring[0]);

                // insert child into the offspring population
                offspringPopulation.Add(offSpring[0]);

                evaluations++;

                // Create the solutionSet union of solutionSet and offSpring
                union = ((SolutionSet)population).Union(offspringPopulation);

                // Ranking the union
                Ranking ranking = new Ranking(union);

                int         remain = populationSize;
                int         index  = 0;
                SolutionSet front  = null;
                population.Clear();

                // Obtain the next front
                front = ranking.GetSubfront(index);

                while ((remain > 0) && (remain >= front.Size()))
                {
                    //Assign crowding distance to individuals
                    distance.CrowdingDistanceAssignment(front, Problem.NumberOfObjectives);
                    //Add the individuals of this front
                    for (int k = 0; k < front.Size(); k++)
                    {
                        population.Add(front.Get(k));
                    }

                    //Decrement remain
                    remain = remain - front.Size();

                    //Obtain the next front
                    index++;
                    if (remain > 0)
                    {
                        front = ranking.GetSubfront(index);
                    }
                }

                // Remain is less than front(index).size, insert only the best one
                if (remain > 0)
                {                  // front contains individuals to insert
                    distance.CrowdingDistanceAssignment(front, Problem.NumberOfObjectives);
                    front.Sort(new CrowdingComparator());
                    for (int k = 0; k < remain; k++)
                    {
                        population.Add(front.Get(k));
                    }

                    remain = 0;
                }

                // This piece of code shows how to use the indicator object into the code
                // of NSGA-II. In particular, it finds the number of evaluations required
                // by the algorithm to obtain a Pareto front with a hypervolume higher
                // than the hypervolume of the true Pareto front.
                if ((indicators != null) &&
                    (requiredEvaluations == 0))
                {
                    double HV = indicators.GetHypervolume(population);
                    if (HV >= (0.98 * indicators.TrueParetoFrontHypervolume))
                    {
                        requiredEvaluations = evaluations;
                    }
                }
            }

            // Return as output parameter the required evaluations
            SetOutputParameter("evaluations", requiredEvaluations);

            // Return the first non-dominated front
            Ranking rank = new Ranking(population);

            Result = rank.GetSubfront(0);
            return(Result);
        }
Exemplo n.º 31
0
        /// <summary>
        /// 玩家荣誉值升级
        /// </summary>
        /// <param name="user"></param>
        /// <param name="honourNum"></param>
        public static void AddUserLv(GameUser user, int honourNum)
        {
            short generalMaxLv = GameConfigSet.CurrMaxLv.ToShort();

            if (user.UserLv >= generalMaxLv)
            {
                CheckFun(user);
                return;
            }
            short rankLv = user.UserLv;

            user.HonourNum = MathUtils.Addition(user.HonourNum, honourNum);
            short nextLv = MathUtils.Addition(user.UserLv, 1.ToShort());

            while (nextLv <= generalMaxLv)
            {
                GeneralEscalateInfo generalEscalate = new ConfigCacheSet <GeneralEscalateInfo>().FindKey(nextLv, GeneralType.YongHu);
                if (generalEscalate != null && user.HonourNum >= generalEscalate.UpExperience)
                {
                    user.UserLv = nextLv;
                    user.IsLv   = true;
                    UserHelper.OpenMagic(user.UserID, user.UserLv);
                    user.HonourNum = MathUtils.Subtraction(user.HonourNum, generalEscalate.UpExperience);

                    if (generalEscalate.FunctionEnum != null && generalEscalate.FunctionEnum != "")
                    {
                        var feArray = generalEscalate.FunctionEnum.Split(',');
                        foreach (var fun in feArray)
                        {
                            var userFun = _cacheSetUserFun.FindKey(user.UserID, fun);
                            if (userFun == null)
                            {
                                userFun            = new UserFunction();
                                userFun.UserID     = user.UserID;
                                userFun.FunEnum    = fun.ToEnum <FunctionEnum>();
                                userFun.CreateDate = DateTime.Now;
                                _cacheSetUserFun.Add(userFun);
                                _cacheSetUserFun.Update();
                                user.OpenFun.Add(userFun);
                            }
                        }
                    }
                    FestivalHelper.GetUpgradeGiveGift(user.UserID, nextLv);
                    nextLv = MathUtils.Addition(user.UserLv, 1.ToShort());
                }
                else
                {
                    break;
                }
            }
            if (user.UserLv > rankLv)
            {
                Ranking <UserRank> ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);
                UserRank           rankInfo;
                int rankID;
                if (ranking.TryGetRankNo(m => m.UserID == user.UserID, out rankID))
                {
                    rankInfo = ranking.Find(s => s.UserID == user.UserID);
                    if (rankInfo != null)
                    {
                        rankInfo.UserLv         = user.UserLv;
                        rankInfo.TotalCombatNum = user.CombatNum;
                        rankInfo.ObtainNum      = user.ObtainNum;
                    }
                }
            }
            CheckFun(user);
        }
        public ActionResult Index(LoadRankingsModel loadRankingsModel)
        {
            using (tennisContext db = new tennisContext())
            {
                if (Request.Method == "POST")
                {
                    if (loadRankingsModel.RankingsToUpdate == "ATP")
                    {
                        using (WebClient wc = new WebClient())
                        {
                            string Gender = "M";
                            var    sJson  = wc.DownloadString("https://vbarbaresi.opendatasoft.com/explore/dataset/atp-rankings/download/?format=json&timezone=Europe/London");
                            JArray json   = JsonConvert.DeserializeObject <JArray>(sJson);
                            JEnumerable <JToken> records = json.Children();
                            JToken Timestamp             = records.First().SelectToken("record_timestamp");
                            int    year  = Timestamp.ToObject <DateTime>().Year;
                            int    count = 0;
                            db.Ranking.RemoveRange(db.Ranking.Select(r => r).Where(r => r.Player.Gender == Gender && r.Year == year));
                            foreach (var record in records)
                            {
                                JToken Fields      = record.SelectToken("fields");
                                string PlayerName  = Fields.Value <string>("player_name");
                                string CountryName = Fields.Value <string>("player_country");
                                int    Points      = Fields.Value <int>("player_points");
                                if (CountryName == "United Kingdom")
                                {
                                    CountryName = "Great Britain";
                                }
                                else if (CountryName.Equals("usa", StringComparison.InvariantCultureIgnoreCase) || CountryName == "United States")
                                {
                                    CountryName = "USA";
                                }
                                else if (CountryName == "Bosnia")
                                {
                                    CountryName = "Bosnia And Herzegovina";
                                }
                                else if (CountryName == "Slovak Republic")
                                {
                                    CountryName = "Slovakia";
                                }
                                else if (CountryName == "Chinese Taipei")
                                {
                                    CountryName = "Taiwan";
                                }
                                PlayerName = PlayerName.Trim();
                                PlayerName = Regex.Replace(PlayerName, " +", " ");

                                Ranking Ranking = new Ranking();
                                Ranking.Points = Points;
                                Ranking.Year   = year;
                                if (db.Player.Select(p => p).Where(p => p.Name == PlayerName && p.Country.Name == CountryName).SingleOrDefault() == null)
                                {
                                    Player Player = new Player();
                                    Player.Name   = PlayerName;
                                    Player.Gender = Gender;
                                    if (db.Country.Select(c => c).Where(c => c.Name == CountryName).SingleOrDefault() == null)
                                    {
                                        Country Country = new Country();
                                        Country.Name = CountryName;
                                        db.Country.Add(Country);
                                        db.SaveChanges();
                                    }
                                    Player.CountryId = db.Country.Select(c => c).Where(c => c.Name == CountryName).Single().Id;
                                    db.Player.Add(Player);
                                    db.SaveChanges();
                                }
                                Ranking.PlayerId = db.Player.Select(p => p).Where(p => p.Name == PlayerName && p.Country.Name == CountryName).Single().Id;
                                db.Ranking.Add(Ranking);
                                db.SaveChanges();
                                count++;
                            }
                            RankingsUpdate.ResetRank(year, Gender, db);
                            db.SaveChanges();
                            loadRankingsModel.Message = "Loaded " + count + " rankings.";
                        }
                    }
                    if (loadRankingsModel.RankingsToUpdate == "WTA")
                    {
                        using (WebClient wc = new WebClient())
                        {
                            string Gender = "F";
                            var    sJson  = wc.DownloadString("https://data.opendatasoft.com/explore/dataset/wta-rankings@vbarbaresi/download/?format=json&timezone=Europe/London");
                            JArray json   = JsonConvert.DeserializeObject <JArray>(sJson);
                            JEnumerable <JToken> records = json.Children();
                            JToken Timestamp             = records.First().SelectToken("record_timestamp");
                            int    year  = Timestamp.ToObject <DateTime>().Year;
                            int    count = 0;
                            db.Ranking.RemoveRange(db.Ranking.Select(r => r).Where(r => r.Player.Gender == Gender && r.Year == year));
                            foreach (var record in records)
                            {
                                JToken Fields      = record.SelectToken("fields");
                                string PlayerName  = Fields.Value <string>("player_name");
                                string CountryName = Fields.Value <string>("player_country");
                                int    Points      = Fields.Value <int>("player_points");
                                if (CountryName == "United Kingdom")
                                {
                                    CountryName = "Great Britain";
                                }
                                else if (CountryName.Equals("usa", StringComparison.InvariantCultureIgnoreCase) || CountryName == "United States")
                                {
                                    CountryName = "USA";
                                }
                                else if (CountryName == "Bosnia")
                                {
                                    CountryName = "Bosnia And Herzegovina";
                                }
                                else if (CountryName == "Slovak Republic")
                                {
                                    CountryName = "Slovakia";
                                }
                                else if (CountryName == "Chinese Taipei")
                                {
                                    CountryName = "Taiwan";
                                }
                                PlayerName = PlayerName.Trim();
                                PlayerName = Regex.Replace(PlayerName, " +", " ");

                                Ranking Ranking = new Ranking();
                                Ranking.Points = Points;
                                Ranking.Year   = year;
                                if (db.Player.Select(p => p).Where(p => p.Name == PlayerName && p.Country.Name == CountryName).SingleOrDefault() == null)
                                {
                                    Player Player = new Player();
                                    Player.Name   = PlayerName;
                                    Player.Gender = Gender;
                                    if (db.Country.Select(c => c).Where(c => c.Name == CountryName).SingleOrDefault() == null)
                                    {
                                        Country Country = new Country();
                                        Country.Name = CountryName;
                                        db.Country.Add(Country);
                                        db.SaveChanges();
                                    }
                                    Player.CountryId = db.Country.Select(c => c).Where(c => c.Name == CountryName).Single().Id;
                                    db.Player.Add(Player);
                                    db.SaveChanges();
                                }
                                Ranking.PlayerId = db.Player.Select(p => p).Where(p => p.Name == PlayerName && p.Country.Name == CountryName).Single().Id;
                                db.Ranking.Add(Ranking);
                                db.SaveChanges();
                                count++;
                            }
                            RankingsUpdate.ResetRank(year, Gender, db);
                            db.SaveChanges();
                            loadRankingsModel.Message = "Loaded " + count + " rankings.";
                        }
                    }
                }
            }
            return(View(loadRankingsModel));
        }
Exemplo n.º 33
0
        public void SetPlayer(SimplifiedPlayerInfo info)
        {
            _info = info;
            infoList.Clear();
            textName.SetText((string.IsNullOrWhiteSpace(info.CustomChatPrefix) ? "" : ("【" + info.CustomChatPrefix + "】")) + info.Name);
            var type  = Ranking.GetRankType(info.Rank);
            var range = Ranking.GetRankRange(type);

            rankLabel.SetText($"{info.Rank} / {range.Item2}");

            gucoinText.SetText(info.GuCoin.ToString());

            var percent = (info.Rank - range.Item1) / (float)(range.Item2 - range.Item1);

            rankBar.Value = percent;

            rankimage.SetImage(ServerSideCharacter2.ModTexturesTable[type.ToString()]);
            rankimage.Left.Set(center.X - rankimage.Width.Pixels / 2, 0);
            rankimage.Top.Set(center.Y - rankimage.Height.Pixels / 2, 0);
            rankimage.Tooltip = Ranking.GetName(type);

            var stateText = new UIText("");

            infoList.Add(stateText);
            if (!_info.IsLogin)
            {
                stateText.SetText($"状态:{addColor("离线", Color.Gray)}");
            }
            else if (_info.CurrentMatch == "")
            {
                stateText.SetText($"状态:{addColor("在线", Color.LimeGreen)}");
            }
            else
            {
                stateText.SetText($"状态:{addColor(_info.CurrentMatch + " 游戏中", Color.Yellow)}");
            }

            if (Main.netMode == 0 || ServerSideCharacter2.MainPlayerGroup.IsSuperAdmin)
            {
                var guidText = new UIText($"GUID:{_info.GUID}");
                infoList.Add(guidText);
                var qqNumberText = new UIText($"QQ:{_info.QQNumber}");
                infoList.Add(qqNumberText);
            }
            var playerIDText = new UIText($"玩家ID:{_info.PlayerID}");

            infoList.Add(playerIDText);

            var unionText = new UIText($"所属公会:{_info.UnionName}");

            infoList.Add(unionText);

            var killcountText = new UIText($"击杀数:{_info.KillCount}");

            infoList.Add(killcountText);

            var grouptext = new UIText($"权限组:[c/{_info.ChatColor.Hex3()}:{_info.ChatPrefix}]");

            infoList.Add(grouptext);

            if (_info.PlayerID >= 0)
            {
                var sexText = new UIText($"性别:{((Main.player[_info.PlayerID].Male) ? "男" : "女")}");
                infoList.Add(sexText);
            }

            var regTimeText = new UIText($"注册时间:{_info.RegistedTime:g}");

            infoList.Add(regTimeText);
        }
Exemplo n.º 34
0
 void Awake()
 {
     instance = this;
 }
Exemplo n.º 35
0
 public void Delete(Ranking ranking)
 {
     _rankings.Remove(ranking);
 }
Exemplo n.º 36
0
    private IEnumerator GetRanking(string token)
    {
        string url = user.host + "/user/v1/games/" + gameName;

        using (UnityWebRequest w = UnityWebRequest.Get(url))
        {
            w.SetRequestHeader("Authorization", "Bearer " + token);
            yield return(w.SendWebRequest());

            if (w.isHttpError || w.isNetworkError)
            {
                //TODO handle error
            }
            else
            {
                Debug.Log(w.downloadHandler.text);
                //success
                Ranking r = JsonUtility.FromJson <Ranking>(w.downloadHandler.text);

                MyRank          = r.my;
                MyRank.nickname = r.my.user.nickname;
                MyRank.level    = r.my.user.badges.winner.level;

                Debug.Log("my rank=" + MyRank.rank);

                int size = Math.Min(r.ranking.Count, 5);
                int i    = 0;
                for (i = 0; i < size; i++)
                {
                    Top5[i]          = r.ranking[i];
                    Top5[i].nickname = r.ranking[i].user.nickname;
                    Top5[i].level    = r.ranking[i].user.badges.winner.level;

                    Debug.Log(i + ": rank=" + Top5[i].rank + ", score=" + Top5[i].score);
                }
                if (i < 5)
                {
                    for (int j = i; j < 5; j++)
                    {
                        //TODO don't show empty data
                        Top5[j] = new RankData();
                    }
                }
                for (i = 0; i < 5; i++)
                {
                    RankBoxTop5[i].GetComponent <RankBox>().SetRankBox(Top5[i].rank, Top5[i].score, Top5[i].time, Top5[i].nickname, Top5[i].level, false);
                }

                if (MyRank.rank <= 5)
                {
                    MyRankBoxWithTop5.SetActive(false);
                }
                else
                {
                    MyRankBoxWithTop5.GetComponent <RankBox>().SetRankBox(MyRank.rank, MyRank.score, MyRank.time, MyRank.nickname, MyRank.level, false);
                    MyRankBoxWithTop5.SetActive(true);
                }
                GameOverRankBox.GetComponent <RankBox>().SetRankBox(MyRank.rank, MyRank.score, MyRank.time, MyRank.nickname, MyRank.level, false);
            }
        }
    }
Exemplo n.º 37
0
        public SolutionSet Mix()
        {
            QualityIndicator indicators = new QualityIndicator(problem, fileRead.Qi); // QualityIndicator object
            int requiredEvaluations     = 0;                                          // Use in the example of use of the

            // indicators object (see below)

            evaluations = 0;

            iteration        = 0;
            populationSize   = int.Parse(fileRead.Ps);
            iterationsNumber = int.Parse(fileRead.Itn);
            dataDirectory    = "Data/Parameters/Weight";


            Logger.Log.Info("POPSIZE: " + populationSize);
            Console.WriteLine("POPSIZE: " + populationSize);

            population = new SolutionSet(populationSize);
            indArray   = new Solution[problem.NumberOfObjectives];

            t     = int.Parse(fileRead.T);
            nr    = int.Parse(fileRead.Nr);
            delta = double.Parse(fileRead.Delta);
            gamma = double.Parse(fileRead.Gamma);

            neighborhood = new int[populationSize][];
            for (int i = 0; i < populationSize; i++)
            {
                neighborhood[i] = new int[t];
            }

            z = new double[problem.NumberOfObjectives];
            //znad = new double[Problem.NumberOfObjectives];

            lambda = new double[populationSize][];
            for (int i = 0; i < populationSize; i++)
            {
                lambda[i] = new double[problem.NumberOfObjectives];
            }

            /*string dir = "Result/" + fileRead.Al + "_" + fileRead.Co + "_" + fileRead.Co2 + "/" + fileRead.Pb + "_" + fileRead.St + "/Record/SBX(" + double.Parse(fileRead.Ra).ToString("#0.00") + ")+ACOR(" + (1-double.Parse(fileRead.Ra)).ToString("#0.00") + ")";
             * if (Directory.Exists(dir))
             * {
             *  Console.WriteLine("The directory {0} already exists.", dir);
             * }
             * else
             * {
             *  Directory.CreateDirectory(dir);
             *  Console.WriteLine("The directory {0} was created.", dir);
             * }*/

            //Step 1. Initialization
            //Step 1.1 Compute euclidean distances between weight vectors and find T
            InitUniformWeight();

            InitNeighborhood();

            //Step 1.2 Initialize population
            InitPoputalion();

            //Step 1.3 Initizlize z
            InitIdealPoint();

            //Step 2 Update
            for (int a = 0; a < iterationsNumber; a++)
            {
                int[] permutation = new int[populationSize];
                JMetalCSharp.Metaheuristics.MOEAD.Utils.RandomPermutation(permutation, populationSize);

                Solution[] parents = new Solution[2];
                int        t       = 0;

                if (a >= double.Parse(fileRead.Ra) * iterationsNumber)
                {
                    for (int i = 0; i < populationSize; i++)
                    {
                        int n = permutation[i];
                        // or int n = i;


                        int    type;
                        double rnd = JMetalRandom.NextDouble();

                        // STEP 2.1. ACOR selection based on probability
                        if (rnd < gamma) // if (rnd < realb)
                        {
                            type = 1;    // minmum
                            //parents[0] = population.Get(ACOrSelection2(n, type, pro_T));
                        }
                        else
                        {
                            type = 2;   // whole neighborhood probability
                            //parents[0] = population.Get(ACOrSelection2(n, type, pro_A));
                        }
                        GetStdDev(neighborhood);
                        //GetStdDev1(neighborhood, type);

                        //List<int> p = new List<int>();
                        //MatingSelection(p, n, 1, type);

                        // STEP 2.2. Reproduction
                        Solution child;

                        parents[0] = population.Get(ACOrSelection(n, type));
                        parents[1] = population.Get(n);
                        //parents[0] = population.Get(p[0]);

                        // Apply ACOR crossover
                        child = (Solution)crossover2.Execute(parents);

                        child.NumberofReplace = t;

                        // // Apply mutation
                        mutation.Execute(child);

                        // Evaluation
                        problem.Evaluate(child);

                        evaluations++;

                        // STEP 2.3. Repair. Not necessary

                        // STEP 2.4. Update z_
                        UpdateReference(child);

                        // STEP 2.5. Update of solutions
                        t = UpdateProblemWithReplace(child, n, 1);
                    }
                }
                else
                {
                    // Create the offSpring solutionSet
                    SolutionSet offspringPopulation = new SolutionSet(populationSize);
                    for (int i = 0; i < (populationSize / 2); i++)
                    {
                        int n = permutation[i]; // or int n = i;

                        int    type;
                        double rnd = JMetalRandom.NextDouble();

                        // STEP 2.1. Mating selection based on probability
                        if (rnd < delta) // if (rnd < realb)
                        {
                            type = 1;    // neighborhood
                        }
                        else
                        {
                            type = 2;   // whole population
                        }
                        List <int> p = new List <int>();
                        MatingSelection(p, n, 2, type);

                        parents[0] = population.Get(p[0]);
                        parents[1] = population.Get(p[1]);

                        //obtain parents
                        Solution[] offSpring = (Solution[])crossover1.Execute(parents);
                        //Solution child;
                        mutation.Execute(offSpring[0]);
                        mutation.Execute(offSpring[1]);

                        /*if(rnd < 0.5)
                         * {
                         *  child = offSpring[0];
                         * }
                         * else
                         * {
                         *  child = offSpring[1];
                         * }*/
                        problem.Evaluate(offSpring[0]);
                        problem.Evaluate(offSpring[1]);
                        problem.EvaluateConstraints(offSpring[0]);
                        problem.EvaluateConstraints(offSpring[1]);
                        offspringPopulation.Add(offSpring[0]);
                        offspringPopulation.Add(offSpring[1]);
                        evaluations += 2;

                        // STEP 2.3. Repair. Not necessary

                        // STEP 2.4. Update z_
                        UpdateReference(offSpring[0]);
                        UpdateReference(offSpring[1]);

                        // STEP 2.5. Update of solutions
                        UpdateProblem(offSpring[0], n, type);
                        UpdateProblem(offSpring[1], n, type);
                    }

                    //for (int i = 0; i < populationSize; i++)
                    //{
                    //    int n = permutation[i]; // or int n = i;

                    //    int type;
                    //    double rnd = JMetalRandom.NextDouble();

                    //    // STEP 2.1. Mating selection based on probability
                    //    if (rnd < delta) // if (rnd < realb)
                    //    {
                    //        type = 1;   // neighborhood
                    //    }
                    //    else
                    //    {
                    //        type = 2;   // whole population
                    //    }
                    //    List<int> p = new List<int>();
                    //    MatingSelection(p, n, 2, type);

                    //    // STEP 2.2. Reproduction
                    //    Solution child;
                    //    Solution[] parent = new Solution[3];

                    //    parent[0] = population.Get(p[0]);
                    //    parent[1] = population.Get(p[1]);

                    //    parent[2] = population.Get(n);

                    //    // Apply DE crossover
                    //    child = (Solution)crossover1.Execute(new object[] { population.Get(n), parent });

                    //    // Apply mutation
                    //    mutation.Execute(child);

                    //    // Evaluation
                    //    problem.Evaluate(child);

                    //    evaluations++;

                    //    // STEP 2.3. Repair. Not necessary

                    //    // STEP 2.4. Update z_
                    //    UpdateReference(child);

                    //    // STEP 2.5. Update of solutions
                    //    UpdateProblem(child, n, type);
                    //}
                }

                /*string filevar = dir + "/VAR" + iteration;
                *  string filefun = dir + "/FUN" + iteration;
                *  population.PrintVariablesToFile(filevar);
                *  population.PrintObjectivesToFile(filefun);*/

                iteration++;

                if ((indicators != null) && (requiredEvaluations == 0))
                {
                    double HV = indicators.GetHypervolume(population);
                    if (HV >= (0.98 * indicators.TrueParetoFrontHypervolume))
                    {
                        requiredEvaluations = evaluations;
                    }
                }
            }

            Logger.Log.Info("ITERATION: " + iteration);
            Console.WriteLine("ITERATION: " + iteration);

            SolutionSet Result = population;

            //return population;

            // Return the first non-dominated front
            Ranking rank = new Ranking(population);

            //SolutionSet Result = rank.GetSubfront(0);

            return(Result);
        }
Exemplo n.º 38
0
 // Use this for initialization
 void Start()
 {
     rankingScript = GetComponent<Ranking> ();
     retryScript = GetComponent<RetryScript> ();
     stage = GameObject.Find ("Stage");
 }
Exemplo n.º 39
0
    void StartRanking()
    {
        m_newRecord.transform.position = new Vector2(100, 100);
        string fileName = "Score_Ranking";

        m_rankIn = false;
        Ranking.GetInstance().WriteRanking(m_score, fileName, m_playerName);
        int rankingMaxNum = Ranking.GetInstance().GetRankingMaxNum();

        string[] rankingScore = new string[rankingMaxNum];
        string[] rankingName  = new string[rankingMaxNum];
        for (int i = 0; i < rankingMaxNum; i++)
        {
            rankingScore[i] = Ranking.GetInstance().GetScore()[i].ToString();
            if (int.Parse(rankingScore[i]) < 1000)
            {
                rankingScore[i] = "  " + rankingScore[i];
            }
            rankingName[i] = Ranking.GetInstance().GetName()[i].ToString();
        }
        string[] rankingNum = new string[rankingMaxNum];
        rankingNum[0] = "  1位 ";
        rankingNum[1] = "  2位 ";
        rankingNum[2] = "  3位 ";
        rankingNum[3] = "  4位 ";
        rankingNum[4] = "  5位 ";
        rankingNum[5] = "  6位 ";
        rankingNum[6] = "  7位 ";
        rankingNum[7] = "  8位 ";
        rankingNum[8] = "  9位 ";
        rankingNum[9] = " 10位 ";

        string[] rankingPoint = new string[rankingMaxNum];
        rankingPoint[0] = "点 ";
        rankingPoint[1] = "点 ";
        rankingPoint[2] = "点 ";
        rankingPoint[3] = "点 ";
        rankingPoint[4] = "点 ";
        rankingPoint[5] = "点 ";
        rankingPoint[6] = "点 ";
        rankingPoint[7] = "点 ";
        rankingPoint[8] = "点 ";
        rankingPoint[9] = "点 ";

        // ランクインした自分の順位を赤色で表示
        for (int i = 0; i < rankingMaxNum; i++)
        {
            if (m_score == Ranking.GetInstance().GetScore()[i])
            {
                myScoreText.text = rankingNum[i] + rankingScore[i] + "点 " + rankingName[i];
                myScoreText.transform.position = new Vector2(0.1f, 0.797f - (0.077f * i));
                myScoreText.color = Color.red;
                rankingScore[i]   = "";
                rankingPoint[i]   = "";
                rankingName[i]    = "";
                rankingNum[i]     = "";
                break;
            }
        }

        // ランキングを表示
        rankingText.text =
            "     ランキング\n\n" +
            rankingNum [0] + rankingScore [0] + rankingPoint[0] + rankingName [0] + "\n" +
            rankingNum [1] + rankingScore [1] + rankingPoint[1] + rankingName [1] + "\n" +
            rankingNum [2] + rankingScore [2] + rankingPoint[2] + rankingName [2] + "\n" +
            rankingNum [3] + rankingScore [3] + rankingPoint[3] + rankingName [3] + "\n" +
            rankingNum [4] + rankingScore [4] + rankingPoint[4] + rankingName [4] + "\n" +
            rankingNum [5] + rankingScore [5] + rankingPoint[5] + rankingName [5] + "\n" +
            rankingNum [6] + rankingScore [6] + rankingPoint[6] + rankingName [6] + "\n" +
            rankingNum [7] + rankingScore [7] + rankingPoint[7] + rankingName [7] + "\n" +
            rankingNum [8] + rankingScore [8] + rankingPoint[8] + rankingName [8] + "\n" +
            rankingNum [9] + rankingScore [9] + rankingPoint[9] + rankingName [9] + "\n";
    }
Exemplo n.º 40
0
 public void Onclick()
 {
     rank = GetComponent<Ranking> ();
     rank.loadRankingData (int.Parse(this.GetComponentInChildren<Text>().text));
     rank.rankingDisp ();
 }
Exemplo n.º 41
0
    public static int SaveNewRanking(string username, string rankingName, int ruleSetId)
    {
        // Create new ranking.
        Ranking newRanking = new Ranking
        {
            RankingName = rankingName,
            RuleSetId = ruleSetId,
            User = username
        };

        using (var db = new DatabaseContext())
        {
            db.Rankings.Add(newRanking);
            db.SaveChanges();
        }

        return newRanking.RankingId;
    }
Exemplo n.º 42
0
        public RankingViewModel(Ranking rank)
        {
            if (rank == null)
                return;

            this.Id         = rank.Id;
            this.NickName   = rank.NickName;
            this.Comment    = rank.Comment;
            this.Rate       = rank.Rate;
            this.Rank       = rank.Rank;
            this.Level      = rank.Level;
            this.Experience = rank.Experience;
            this.Flag       = rank.Flag;
        }
Exemplo n.º 43
0
    public List<Ranking> getRanking()
    {
        using (SqlConnection conn = new SqlConnection(connectionString))
        {
            conn.Open();
            //SqlTransaction transaction = conn.BeginTransaction("RankingTransaction");

            try
            {
                String cmdRanking = " Select top 10 USU_Nome, COUNT(DOC_IdDoacao) as CountDoacao " +
                                    " from TB_Usuarios " +
                                    " inner join TB_Doacoes on (USU_IdUsuario = DOC_IdUsuarioDoador) " +
                                    " where DOC_StatusDoacao = 2 " +
                                    " group by USU_Nome " +
                                    " order by CountDoacao desc ";

                SqlCommand queryRanking = new SqlCommand(cmdRanking, conn);

                List<Ranking> ranking = new List<Ranking>();

                SqlDataReader recordsRanking = queryRanking.ExecuteReader();
                int Count = 0;

                while (recordsRanking.Read())
                {
                    Ranking data = new Ranking();
                    data.nome = recordsRanking.GetString(0);
                    data.numDoacoes = recordsRanking.GetInt32(1);
                    ranking.Insert(Count, data);
                    Count++;
                }
                //transaction.Commit();
                return ranking;
            }
            catch (Exception ex)
            {
                //transaction.Rollback();
                throw new Exception(ex.ToString());
            }
            finally
            {
                conn.Close();
            }
        }
    }
Exemplo n.º 44
0
        public override bool TakeAction()
        {
            UserStatus status = ContextUser.UserStatus;

            if (status == UserStatus.FengJin)
            {
                return(false);
            }
            UserGeneral        general = UserGeneral.GetMainGeneral(ContextUser.UserID);
            Ranking <UserRank> ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);
            UserRank           rankInfo;

            if (ranking.TryGetRankNo(m => m.UserID == ContextUser.UserID, out rankID))
            {
                rankInfo = ranking.Find(s => s.UserID == ContextUser.UserID);
                //ContextUser.RankID = rankID;
            }
            else
            {
                rankInfo = new UserRank()
                {
                    UserID         = ContextUser.UserID,
                    HeadID         = general.HeadID,
                    GameCoin       = ContextUser.GameCoin,
                    NickName       = ContextUser.NickName,
                    ObtainNum      = ContextUser.ObtainNum,
                    UserLv         = ContextUser.UserLv,
                    RankId         = int.MaxValue,
                    RankDate       = DateTime.Now,
                    SportsIntegral = 0
                };
                ranking.TryAppend(rankInfo);
            }

            sportsName = UserHelper.SportTitleName(ContextUser.ObtainNum);

            sportNum       = GetChallGeNum(ContextUser.UserID);
            sportsIntegral = ContextUser.SportsIntegral.ToInt();
            sportsReward   = new ShareCacheStruct <SportsRewardInfo>().FindKey(rankInfo.RankId);
            receiveDate    = (int)(RankingHelper.GetNextReceiveDate() - DateTime.Now).TotalSeconds;

            CombatRanking combatrank = (CombatRanking)ranking;

            _userRankArray = combatrank.GetRanking(ContextUser);
            _userRankArray.Add(rankInfo);
            _userRankArray.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                return(x.RankId.CompareTo(y.RankId));
            });

            _userCombatArray = ContextUser.GetSportsCombat();
            _userCombatArray.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                return(y.CombatDate.CompareTo(x.CombatDate));
            });

            if (rankInfo != null && rankID > 0)
            {
                victoryNum = rankInfo.VictoryNum;
            }

            //NoviceHelper.SportVictoryNum(ContextUser, 2001, victoryNum); //竞技场奖励
            if (victoryNum >= 7)
            {
                ActivitiesAward.HolidayFestival(ContextUser.UserID);
            }
            rankID = ContextUser.RankID;



            int count     = 10;
            int pagecount = 0;

            userRankArray = ranking.GetRange(1, count, out pagecount);
            return(true);
        }
Exemplo n.º 45
0
        private static void Main(string[] arguments)
        {
            string menuNavigation = string.Empty;
            char[,] gameField = CreateGameField();
            char[,] bombs = SetBombs();
            int movesCounter = 0;
            bool mineField = false;
            List<Ranking> championsList = new List<Ranking>(6);
            int fieldRow = 0;
            int fieldColumn = 0;
            bool flagNewGame = true;
            const int MaksimumGameMoves = 35;
            bool flagEndGame = false;

            do
            {
                if (flagNewGame)
                {
                    Console.WriteLine(
                        "Hajde da igraem na “Mini4KI”. Probvaj si kasmeta da otkriesh poleteta bez mini4ki."
                        + " Komanda 'top' pokazva klasiraneto, 'restart' po4va nova igra, 'exit' izliza i hajde 4ao!");
                    FillGameField(gameField);
                    flagNewGame = false;
                }

                Console.Write("Daj red i kolona : ");
                menuNavigation = Console.ReadLine().Trim();
                if (menuNavigation.Length >= 3)
                {
                    if (int.TryParse(menuNavigation[0].ToString(), out fieldRow) && int.TryParse(menuNavigation[2].ToString(), out fieldColumn)
                        && fieldRow <= gameField.GetLength(0) && fieldColumn <= gameField.GetLength(1))
                    {
                        menuNavigation = "turn";
                    }
                }

                switch (menuNavigation)
                {
                    case "top":
                        Rating(championsList);
                        break;
                    case "restart":
                        gameField = CreateGameField();
                        bombs = SetBombs();
                        FillGameField(gameField);
                        mineField = false;
                        flagNewGame = false;
                        break;
                    case "exit":
                        Console.WriteLine("4a0, 4a0, 4a0!");
                        break;
                    case "turn":
                        if (bombs[fieldRow, fieldColumn] != '*')
                        {
                            if (bombs[fieldRow, fieldColumn] == '-')
                            {
                                PlayerMoveChanging(gameField, bombs, fieldRow, fieldColumn);
                                movesCounter++;
                            }

                            if (MaksimumGameMoves == movesCounter)
                            {
                                flagEndGame = true;
                            }
                            else
                            {
                                FillGameField(gameField);
                            }
                        }
                        else
                        {
                            mineField = true;
                        }

                        break;
                    default:
                        Console.WriteLine("\nGreshka! nevalidna Komanda\n");
                        break;
                }

                if (mineField)
                {
                    FillGameField(bombs);
                    Console.Write("\nHrrrrrr! Umria gerojski s {0} to4ki. " + "Daj si niknejm: ", movesCounter);
                    string nickName = Console.ReadLine();
                    Ranking playerRanking = new Ranking(nickName, movesCounter);
                    if (championsList.Count < 5)
                    {
                        championsList.Add(playerRanking);
                    }
                    else
                    {
                        for (int i = 0; i < championsList.Count; i++)
                        {
                            if (championsList[i].Points < playerRanking.Points)
                            {
                                championsList.Insert(i, playerRanking);
                                championsList.RemoveAt(championsList.Count - 1);
                                break;
                            }
                        }
                    }

                    championsList.Sort((Ranking r1, Ranking r2) => r2.Player.CompareTo(r1.Player));
                    championsList.Sort((Ranking r1, Ranking r2) => r2.Points.CompareTo(r1.Points));
                    Rating(championsList);

                    gameField = CreateGameField();
                    bombs = SetBombs();
                    movesCounter = 0;
                    mineField = false;
                    flagNewGame = true;
                }

                if (flagEndGame)
                {
                    Console.WriteLine("\nBRAVOOOS! Otvri 35 kletki bez kapka kryv.");
                    FillGameField(bombs);
                    Console.WriteLine("Daj si imeto, batka: ");
                    string playerName = Console.ReadLine();
                    Ranking to4kii = new Ranking(playerName, movesCounter);
                    championsList.Add(to4kii);
                    Rating(championsList);
                    gameField = CreateGameField();
                    bombs = SetBombs();
                    movesCounter = 0;
                    flagEndGame = false;
                    flagNewGame = true;
                }
            }
            while (menuNavigation != "exit");
            Console.WriteLine("Made in Bulgaria - Uauahahahahaha!");
            Console.WriteLine("AREEEEEEeeeeeee.");
            Console.Read();
        }
Exemplo n.º 46
0
        private async Task UpdateRankingAsync(CancellationToken cancellationToken)
        {
            var roundIds = new HashSet <long>();

            if (TournamentId == null && RoundId == null)
            {
                _logger.LogError($"Both {nameof(TournamentId)} and {nameof(RoundId)} are null. Cannot update ranking.");
                return;
            }

            if (TenantContext == null)
            {
                _logger.LogError($"{nameof(TenantContext)} is null. Cannot update ranking.");
                return;
            }
#if DEBUG
            var stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
#endif
            try
            {
                var matchesPlayed = await TenantContext.DbContext.AppDb.MatchRepository.GetMatchesCompleteAsync(
                    new PredicateExpression(TournamentId != null
                        ? MatchCompleteRawFields.TournamentId == TournamentId
                        : MatchCompleteRawFields.RoundId == RoundId), cancellationToken);

                var matchesToPlay = await TenantContext.DbContext.AppDb.MatchRepository.GetMatchesToPlayAsync(
                    new PredicateExpression(TournamentId != null
                        ? MatchToPlayRawFields.TournamentId == TournamentId
                        : MatchToPlayRawFields.RoundId == RoundId), cancellationToken);

                // Get round id and date of creation for the ranking entry
                var rankingCreatedOnTable = await TenantContext.DbContext.AppDb.RankingRepository.GetRoundRanksCreatedOn(
                    new PredicateExpression(TournamentId != null
                        ? RankingFields.TournamentId == TournamentId
                        : RankingFields.RoundId == RoundId), cancellationToken);

                #region * Identify rounds for which the ranking table must be updated *

                matchesPlayed.ForEach(m =>
                {
                    // Was the match updated after the ranking entry was created?
                    if (EnforceUpdate || rankingCreatedOnTable.Exists(rt => rt.RoundId == m.RoundId && rt.CreatedOn < m.ModifiedOn))
                    {
                        roundIds.Add(m.RoundId);
                    }
                });
                // matches to play is required for generation of ranking chart files (remaining match days)
                matchesToPlay.ForEach(m =>
                {
                    // Was the match updated after the ranking entry was created?
                    if (EnforceUpdate || rankingCreatedOnTable.Exists(rt => rt.RoundId == m.RoundId && rt.CreatedOn < m.ModifiedOn))
                    {
                        roundIds.Add(m.RoundId);
                    }
                });

                // No rounds which require an update
                if (!roundIds.Any())
                {
                    return;
                }

                #endregion

                var teamsInRound =
                    await TenantContext.DbContext.AppDb.TeamInRoundRepository.GetTeamInRoundAsync(
                        new PredicateExpression(TeamInRoundFields.RoundId.In(roundIds)), cancellationToken);

                foreach (var roundId in roundIds)
                {
                    /***** Ranking table update *****/

                    // rules can be different for every round
                    var matchRule =
                        await TenantContext.DbContext.AppDb.RoundRepository.GetMatchRuleAsync(roundId, cancellationToken);

                    // filter matches to only contain a single round
                    var ranking = new Ranking(matchesPlayed.Where(mp => mp.RoundId == roundId),
                                              matchesToPlay.Where(mtp => mtp.RoundId == roundId), (RankComparerEnum)matchRule.RankComparer);
                    // Update the ranking table
                    await TenantContext.DbContext.AppDb.RankingRepository.SaveAsync(ranking.GetList(out var lastUpdated),
                                                                                    roundId, cancellationToken);

                    /***** Chart file generation *****/

                    // without played matches, no chart can be generated
                    if (ranking.MatchesPlayed.Count == 0)
                    {
                        break;
                    }

                    var chart = new RankingChart(ranking,
                                                 teamsInRound.Select(tir => (tir.TeamId, tir.TeamNameForRound)).ToList(),
                                                 new RankingChart.ChartSettings
                    {
                        Title = null, XTitle = "MD", YTitle = "R", Width = 700, Height = 400,
                        GraphBackgroundColorArgb = "#FFEFFFEF", PlotAreaBackgroundColorArgb = "#FFFFFFFF",
                        FontName = "Arial, Helvetica, sans-serif", ShowLegend = false
                    })
                    {
                        UseMatchDayMarker = true
                    };

                    await using var chartStream = chart.GetPng();
                    await using var fileStream  = File.Create(Path.Combine(_webHostEnvironment.WebRootPath, RankingImageFolder,
                                                                           string.Format(RankingChartFilenameTemplate, TenantContext.Identifier, roundId,
                                                                                         DateTime.UtcNow.Ticks)));
                    chartStream.Seek(0, SeekOrigin.Begin);
                    await chartStream.CopyToAsync(fileStream, cancellationToken);
                }
            }
            catch (Exception e)
            {
                _logger.LogCritical(e, "Could not update ranking table and/or chart files");
            }

            DeleteObsoleteChartImageFiles(roundIds);
#if DEBUG
            stopWatch.Stop();
            _logger.LogInformation("{0} completed in {1}ms", nameof(RankingUpdateTask), stopWatch.ElapsedMilliseconds);
#endif
        }
Exemplo n.º 47
0
 public RankingDto selectRankingById(String RankingId)
 {
     RankingManager mgr = new RankingManager();
     Ranking obj = new Ranking();
     obj.RankingId = RankingId;
     obj = mgr.selectRankingById(obj);
     if (obj != null)
     {
         return RankingDto.createRankingDTO(obj);
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 48
0
 public void EditSchedule(DayOfWeek dayToChange, Ranking newRank)
 {
     this.PreferedDays[dayToChange] = newRank;
 }