Exemple #1
0
        static void Main(string[] args)
        {
            //Initialize Teams
            allValidPicks = new DraftTeam[NumberOfTeams];
            for (int teamIndex = 0; teamIndex < NumberOfTeams; teamIndex++)
            {
                allValidPicks[teamIndex] = new DraftTeam();
            }

            IEnumerable <Player> todaysPlayers = GetTodaysPlayers();

            RunPermuations(todaysPlayers);

            OutputTeams();
        }
Exemple #2
0
        /// <summary>
        /// For each center crunch the best teams
        /// </summary>
        static void PerformPermuation(Player p5, Tuple <Player, Player>[] p1s, Tuple <Player, Player>[] p2s, Tuple <Player, Player>[] p3s, Tuple <Player, Player>[] p4s)
        {
            int    oneCount   = p1s.Count();
            int    twoCount   = p2s.Count();
            int    threeCount = p3s.Count();
            int    fourCount  = p4s.Count();
            double teamTotal1 = 0;
            double teamTotal2 = 0;
            double teamTotal3 = 0;
            double teamTotal  = 0;

            for (int index1 = 0; index1 < oneCount; index1++)
            {
                Player p1a = p1s[index1].Item1;
                Player p1b = p1s[index1].Item2;
                teamTotal1 = p1a.Salary + p1b.Salary + p5.Salary;

                if ((teamTotal1 < Level1low || teamTotal1 > Level1high) && teamTotal1 != 0)
                {
                    continue;
                }
                for (int index2 = 0; index2 < twoCount; index2++)
                {
                    Player p2a = p2s[index2].Item1;
                    Player p2b = p2s[index2].Item2;
                    teamTotal2 = teamTotal1 + p2a.Salary + p2b.Salary;
                    if ((teamTotal2 < Level2low || teamTotal2 > Level2high) && teamTotal2 != 0)
                    {
                        continue;
                    }
                    for (int index3 = 0; index3 < threeCount; index3++)
                    {
                        Player p3a = p3s[index3].Item1;
                        Player p3b = p3s[index3].Item2;
                        teamTotal3 = teamTotal2 + p3a.Salary + p3b.Salary;

                        if ((teamTotal3 < Level3low || teamTotal3 > Level3high) && teamTotal3 != 0)
                        {
                            continue;
                        }

                        double totalPointsCheck = p1a.ModifiedMetric + p1b.ModifiedMetric + p2a.ModifiedMetric + p2b.ModifiedMetric + p3a.ModifiedMetric + p3b.ModifiedMetric + p5.ModifiedMetric;
                        if (totalPointsCheck + Level4MaxPoints < lowMan)
                        {
                            continue;
                        }

                        for (int index4 = 0; index4 < fourCount; index4++)
                        {
                            teamTotal = teamTotal3 + p4s[index4].Item1.Salary + p4s[index4].Item2.Salary;
                            if (teamTotal != 0 && (teamTotal > MaxSalary || teamTotal < MinSalary))
                            {
                                continue;
                            }

                            Player p4a         = p4s[index4].Item1;
                            Player p4b         = p4s[index4].Item2;
                            double totalPoints = totalPointsCheck + p4a.ModifiedMetric + p4b.ModifiedMetric;
                            if (totalPoints < lowMan && allValidPicks[NumberOfTeams - 1] != null)
                            {
                                continue;
                            }


                            for (int teamIndex = 0; teamIndex < NumberOfTeams; teamIndex++)
                            {
                                if (allValidPicks[teamIndex].TotalPoints < totalPoints)
                                {
                                    for (int shuffleIndex = NumberOfTeams - 2; shuffleIndex > teamIndex; shuffleIndex--)
                                    {
                                        allValidPicks[shuffleIndex + 1] = allValidPicks[shuffleIndex];
                                    }
                                    allValidPicks[teamIndex] = new DraftTeam
                                    {
                                        Team = new List <Player>
                                        {
                                            p1a, p1b, p2a, p2b, p3a, p3b, p4a, p4b, p5
                                        },
                                        TotalPoints = totalPoints
                                    };
                                    lowMan = allValidPicks[NumberOfTeams - 1] == null ? 0 : allValidPicks[NumberOfTeams - 1].TotalPoints;
                                    break;
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }
                    }
                }
            }
        }