Esempio n. 1
0
        public override bool Beats(Player[] teamA, Player[] teamB, out double winChance)
        {
            int individualWins = 0;
            int teamSize       = teamA.Length;

            for (int p = 0; p < teamSize; p++)
            {
                double chance = teamA[p].trueskill - teamB[p].trueskill > Program.beatBound ? 1 : (teamA[p].trueskill - teamB[p].trueskill < -Program.beatBound ? 0 : ELO.WinChance(teamA[p].trueskill, teamB[p].trueskill));
                if (Wins(chance))
                {
                    individualWins++;
                    //Console.WriteLine($"allied player {p} beat enemy player {p}");
                }
                else
                {
                    //Console.WriteLine($"allied player {p} lost to enemy player {p}");
                }
            }

            double relativeWins = (double)individualWins / (double)teamSize;
            //Console.WriteLine($"relativeWins: {relativeWins}");
            double averageSkillA = ELO.AverageSkill(teamA);
            double averageSkillB = ELO.AverageSkill(teamB);

            winChance = ELO.WinChance(averageSkillA, averageSkillB);
            //Console.WriteLine($"average Skill team A: {averageSkillA}");
            //Console.WriteLine($"average Skill team B: {averageSkillB}");
            //Console.WriteLine($"winChance: {winChance}");
            double averageChance = (relativeWins + winChance) / 2;

            //Console.WriteLine($"averageChance: {averageChance}");

            return(Wins(averageChance));
        }
Esempio n. 2
0
        static void StartGame(int teamSize, ref Player p)
        {
            games++;
            ELO.recentGames.Add(p.rating);
            Player[] enemies = new Player[teamSize];
            Player[] allies  = new Player[teamSize];

            //Console.WriteLine($"Enemies:");
            for (int i = 0; i < teamSize; i++)
            {
                enemies[i] = ELO.randomPlayer(p, lowerBound, upperBound, offset);
                //Console.WriteLine($"- player {i} => rating: {enemies[i].rating}; trueskill: {enemies[i].trueskill}");
            }

            //Console.WriteLine("Allies:");
            //Console.WriteLine($"- you => rating: {p.rating}; trueskill: {p.trueskill}");
            allies[0] = p;
            for (int j = 1; j < teamSize; j++)
            {
                allies[j] = ELO.randomPlayer(p, lowerBound, upperBound, offset);
                //Console.WriteLine($"- player {j} => rating: {allies[j].rating}; trueskill: {allies[j].trueskill}");
            }


            double winchance;
            bool   win = winMethod.Beats(allies, enemies, out winchance);

            //Console.WriteLine($"win: {win}");

            p.rating = Clamp(NewRating(p.rating, win, winchance), lowerBound, upperBound);
            elos.Add(p.rating);
        }
Esempio n. 3
0
        public override bool Beats(Player[] teamA, Player[] teamB, out double winChance)
        {
            double totalChance = 0;
            int    teamSize    = teamA.Length;

            for (int p = 0; p < teamSize; p++)
            {
                totalChance += ELO.WinChance(teamA[p].trueskill, teamB[p].trueskill);
            }

            double averageChance = totalChance / (double)teamSize;

            winChance = averageChance;

            return(Wins(averageChance));
        }
Esempio n. 4
0
 public override bool Beats(Player[] teamA, Player[] teamB, out double winChance)
 {
     winChance = ELO.WinChance(ELO.AverageSkill(teamA), ELO.AverageSkill(teamB));
     return(Wins(winChance));
 }