Ejemplo n.º 1
0
        private List <Fight> ScheduleFights(WeightClass wc)
        {
            List <Fighter> fighters = Fighters.AllFighters().Where(fighter => fighter.Weight == wc.Weight).ToList();
            List <Fight>   schedule = new List <Fight>();

            //Sort in reverse order
            fighters.Sort((f1, f2) => Rating.Rating(f2).CompareTo(Rating.Rating(f1)));

            while (fighters.Count > 1)
            {
                int f1 = 0, f2 = 1;
                for (; f2 < fighters.Count - 1; ++f2)
                {
                    if (MathUtils.RangeUniform(0, 1) < 0.05)
                    {
                        break;
                    }
                }

                var judges = Agents.RandomBunch(PersonType.JUDGE, 3).Select(j => (Judge)j).ToArray();
                schedule.Add(new Fight(fighters[f1], fighters[f2], 12, judges));
                fighters.RemoveAt(f1); fighters.RemoveAt(f2 - 1);
            }

            return(schedule);
        }
Ejemplo n.º 2
0
        public override bool Equals(Object obj)
        {
            // Perform an equality check on two rectangles (Point object pairs).
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            WeightClass that = (WeightClass)obj;

            return(this.Weight == that.Weight);
        }
Ejemplo n.º 3
0
        public void StartNewGame()
        {
            //Create initial pool of fighters
            foreach (WeightClass wc in WeightClass.AllWeightClasses())
            {
                for (int f = 0; f < wc.Size; ++f)
                {
                    RegisterFighter(Fighters.CreateRandomFighter(wc.Weight));
                }
            }

            for (int j = 0; j < Constants.JUDGE_POOL_SIZE; ++j)
            {
                Agents.Add(Judge.RandomJudge(Utility.UniqueRandomName(true,
                                                                      name => !Agents.Contains(name))));
            }

            SimFights(50);
        }
Ejemplo n.º 4
0
        //TODO move eventually
        private void SimFights(int numFights)
        {
            for (int fightNight = 0; fightNight < numFights; ++fightNight)
            {
                LOGGER.Debug($"Fight Night {fightNight}");
                List <Fight> schedule = new List <Fight>();
                foreach (WeightClass wc in WeightClass.AllWeightClasses())
                {
                    schedule.AddRange(ScheduleFights(wc));
                }

                var outcomes = FightSim.SimulateManyFights(schedule);
                foreach (var outcome in outcomes)
                {
                    outcome.Fighters[0].UpdateRecord(outcome);
                    outcome.Fighters[1].UpdateRecord(outcome);
                    Rating.CalculateRatingChange(outcome);
                    //  FighterPopularity.UpdatePopularity(outcome);
                }
            }
        }