Beispiel #1
0
 public void computeMatchmaking(Constants.MatchPolicy policy)
 {
     Matchmaker matchMaker = new Matchmaker(this);
     checkMatch();
     CurrentTeams = matchMaker.computeMatch(policy);
     CurrentScore = matchMaker.Score;
 }
Beispiel #2
0
 public List<Team> computeMatch(Constants.MatchPolicy policy)
 {
     List<Team> teams = new List<Team>();
     teams = computeTeams(core.getExpectedTeamPlayerNumber(), core.getExpectedTeamNumber(), policy);
     return teams;
 }
Beispiel #3
0
 public bool policyScore(Constants.MatchPolicy policy, double newScore, double oldScore, double newEloGlobal, double oldEloGlobal)
 {
     switch (policy)
     {
         case Constants.MatchPolicy.Balanced:
             return newScore < oldScore;
         case Constants.MatchPolicy.Min:
             return ((newScore < oldScore) || ((newScore == oldScore) && (newEloGlobal < oldEloGlobal)));
         case Constants.MatchPolicy.Max:
             return ((newScore < oldScore) || ((newScore == oldScore) && (newEloGlobal > oldEloGlobal)));
         case Constants.MatchPolicy.Random:
             return true;
     }
     return false;
 }
Beispiel #4
0
        private List<Team> computeTeams(int teamMemberNumber, int teamNumber, Constants.MatchPolicy policy)
        {
            Random rnd = new Random();
            List<Team> teams = new List<Team>();
            List<Team> tempTeams = new List<Team>();
            PlayerSelecter playerSelecter = new PlayerSelecter(core.CheckedHumanPlayers.Values.ToList());
            score = 0;
            double avgElo = 0;
            int[] scores = new int[teamNumber];
            for (int i = 0; i < Constants.Iterations; i++)
            {
                tempTeams.Clear();
                playerSelecter.reset();
                for (int j = 0; j < teamNumber; j++)
                {
                    tempTeams.Add(new Team());
                }
                for (int j = 0; j < teamMemberNumber; j++)
                {
                    for (int k = 0; k < teamNumber; k++)
                    {
                        Player player;
                        if (teamMemberNumber == 1)
                        {
                            player = playerSelecter.getNextPlayer();
                        }
                        else
                        {
                            player = playerSelecter.getRandomPlayer();

                        }
                        tempTeams[k].addMember(player, player.selectRaceRandomly(rnd));
                    }
                }
                for (int j = 0; j < teamNumber; j++)
                {
                    scores[j] = tempTeams[j].computeEloTeam();
                }
                double tempScore = Statistics.StdDev(scores);
                double tempAvgElo = Statistics.Mean(scores);
                if (policyScore(policy, tempScore, score, tempAvgElo, avgElo) || (i==0))//TODO
                {
                    score = tempScore;
                    avgElo = tempAvgElo;
                    teams.Clear();
                    for (int j = 0; j < teamNumber; j++)
                    {
                        tempTeams[j].EloAdv = (scores.Sum()-tempTeams[j].EloTeam)/(teamNumber-1);
                        teams.Add(tempTeams[j].getCopy());
                    }
                }
            }
            return teams;
        }