Exemple #1
0
        private void BuildInitialPositionLists(List <FootballPlayer> players)
        {
            foreach (var player in players)
            {
                switch (player.Position)
                {
                case "qb":
                    Quarterbacks.Add(player);
                    break;

                case "rb":
                    RunningBacks.Add(player);
                    TopRunningBacks.Add(player);
                    FLEX.Add(player);
                    break;

                case "wr":
                    WideReceivers.Add(player);
                    TopWideReceivers.Add(player);
                    FLEX.Add(player);
                    break;

                case "te":
                    TightEnds.Add(player);
                    FLEX.Add(player);
                    break;
                }
            }
        }
Exemple #2
0
        public void Init()
        {
            allPositions.Add(Quarterback);
            offensivePositions.Add(Quarterback);
            for (int i = 1; i <= Max; i++)
            {
                Receivers.Add(new Position("WR" + i.ToString()));
            }
            allPositions.AddRange(Receivers);
            offensivePositions.AddRange(Receivers);
            for (int i = 1; i <= Max; i++)
            {
                Runningbacks.Add(new Position("RB" + i.ToString()));
            }
            allPositions.AddRange(Runningbacks);
            offensivePositions.AddRange(Runningbacks);
            for (int i = 1; i <= Max; i++)
            {
                OffensiveLinemen.Add(new Position("OL" + i.ToString()));
            }
            OffensiveLinemen[0].HasBall = true;
            allPositions.AddRange(OffensiveLinemen);
            offensivePositions.AddRange(OffensiveLinemen);
            for (int i = 1; i <= Max; i++)
            {
                TightEnds.Add(new Position("TE" + i.ToString()));
            }
            allPositions.AddRange(TightEnds);
            offensivePositions.AddRange(TightEnds);


            for (int i = 1; i <= Max; i++)
            {
                Cornerbacks.Add(new Position("CB" + i.ToString()));
            }
            allPositions.AddRange(Cornerbacks);
            defensivePositions.AddRange(Cornerbacks);
            for (int i = 1; i <= Max; i++)
            {
                Linebackers.Add(new Position("LB" + i.ToString()));
            }
            allPositions.AddRange(Linebackers);
            defensivePositions.AddRange(Linebackers);
            for (int i = 1; i <= Max; i++)
            {
                DefensiveLinemen.Add(new Position("DL" + i.ToString()));
            }
            DefensiveLinemen[0].HasBall = true;
            allPositions.AddRange(DefensiveLinemen);
            defensivePositions.AddRange(DefensiveLinemen);
            for (int i = 1; i <= Max; i++)
            {
                Safeties.Add(new Position("S" + i.ToString()));
            }
            allPositions.AddRange(Safeties);
            defensivePositions.AddRange(Safeties);
        }
Exemple #3
0
        public void Init()
        {
            Quarterback.Add(new Lineup("QB"));
            for (int i = 1; i <= Max; i++)
            {
                Receivers.Add(new Lineup("WR" + i.ToString()));
            }

            for (int i = 1; i <= Max; i++)
            {
                Runningbacks.Add(new Lineup("RB" + i.ToString()));
            }

            for (int i = 1; i <= Max; i++)
            {
                OffensiveLinemen.Add(new Lineup("OL" + i.ToString()));
            }

            for (int i = 1; i <= Max; i++)
            {
                TightEnds.Add(new Lineup("TE" + i.ToString()));
            }

            for (int i = 1; i <= Max; i++)
            {
                Cornerbacks.Add(new Lineup("CB" + i.ToString()));
            }

            for (int i = 1; i <= Max; i++)
            {
                Linebackers.Add(new Lineup("LB" + i.ToString()));
            }

            for (int i = 1; i <= Max; i++)
            {
                DefensiveLinemen.Add(new Lineup("DL" + i.ToString()));
            }

            for (int i = 1; i <= Max; i++)
            {
                Safeties.Add(new Lineup("S" + i.ToString()));
            }
        }
Exemple #4
0
        public void OptimizeCombinations(List <NFLLineup> lineups)
        {
            Console.WriteLine("Before Optimiaztion");
            DisplayCombinations();

            Quarterbacks.Clear();
            TopRunningBacks.Clear();
            TopWideReceivers.Clear();
            TightEnds.Clear();

            foreach (var lineup in lineups)
            {
                if (!Quarterbacks.Contains(lineup.Quarterback))
                {
                    Quarterbacks.Add(lineup.Quarterback);
                }
                if (!TightEnds.Contains(lineup.TightEnd))
                {
                    TightEnds.Add(lineup.TightEnd);
                }

                foreach (var player in lineup.WideReceivers)
                {
                    if (!TopWideReceivers.Contains(player))
                    {
                        TopWideReceivers.Add(player);
                    }
                }

                foreach (var player in lineup.RunningBacks)
                {
                    if (!TopRunningBacks.Contains(player))
                    {
                        TopRunningBacks.Add(player);
                    }
                }
            }

            Console.WriteLine("After Optimaztion");
            BuildCombinations();
        }
Exemple #5
0
        public void Load(string strFile)
        {
            this.Clear();

            if (System.IO.File.Exists(strFile))
            {
                XDocument doc = XDocument.Load(strFile);

                XElement elem = doc.Descendants("Position").First(f => f.Attribute("Name").Value == "QB");
                Quarterback.Load(elem);
                allPositions.Add(Quarterback);
                offensivePositions.Add(Quarterback);

                IEnumerable <XElement> elems = doc.Descendants("Positions");

                IEnumerable <XElement> posElems = elems.First(f => f.Attribute("Name").Value == "Receivers").Elements();
                foreach (XElement e in posElems)
                {
                    Position pos = new Position();
                    pos.Load(e);
                    Receivers.Add(pos);
                }
                allPositions.AddRange(Receivers);
                offensivePositions.AddRange(receivers);

                posElems = elems.First(f => f.Attribute("Name").Value == "Runningbacks").Elements();
                foreach (XElement e in posElems)
                {
                    Position pos = new Position();
                    pos.Load(e);
                    Runningbacks.Add(pos);
                }
                allPositions.AddRange(Runningbacks);
                offensivePositions.AddRange(Runningbacks);

                posElems = elems.First(f => f.Attribute("Name").Value == "OffensiveLinemen").Elements();
                foreach (XElement e in posElems)
                {
                    Position pos = new Position();
                    pos.Load(e);
                    OffensiveLinemen.Add(pos);
                }
                allPositions.AddRange(OffensiveLinemen);
                offensivePositions.AddRange(OffensiveLinemen);

                posElems = elems.First(f => f.Attribute("Name").Value == "TightEnds").Elements();
                foreach (XElement e in posElems)
                {
                    Position pos = new Position();
                    pos.Load(e);
                    TightEnds.Add(pos);
                }
                allPositions.AddRange(TightEnds);
                offensivePositions.AddRange(TightEnds);

                posElems = elems.First(f => f.Attribute("Name").Value == "Cornerbacks").Elements();
                foreach (XElement e in posElems)
                {
                    Position pos = new Position();
                    pos.Load(e);
                    Cornerbacks.Add(pos);
                }
                allPositions.AddRange(Cornerbacks);
                defensivePositions.AddRange(Cornerbacks);

                posElems = elems.First(f => f.Attribute("Name").Value == "Linebackers").Elements();
                foreach (XElement e in posElems)
                {
                    Position pos = new Position();
                    pos.Load(e);
                    Linebackers.Add(pos);
                }
                allPositions.AddRange(Linebackers);
                defensivePositions.AddRange(Linebackers);

                posElems = elems.First(f => f.Attribute("Name").Value == "DefensiveLinemen").Elements();
                foreach (XElement e in posElems)
                {
                    Position pos = new Position();
                    pos.Load(e);
                    DefensiveLinemen.Add(pos);
                }
                allPositions.AddRange(DefensiveLinemen);
                defensivePositions.AddRange(DefensiveLinemen);

                posElems = elems.First(f => f.Attribute("Name").Value == "Safeties").Elements();
                foreach (XElement e in posElems)
                {
                    Position pos = new Position();
                    pos.Load(e);
                    Safeties.Add(pos);
                }
                allPositions.AddRange(Safeties);
                defensivePositions.AddRange(Safeties);
            }
            else
            {
                this.Init();
            }
        }
Exemple #6
0
        public void LoadLineup(string strFile)
        {
            this.Clear();
            if (System.IO.File.Exists(strFile))
            {
                XDocument doc = XDocument.Load(strFile);
                IEnumerable <XElement> elem     = doc.Descendants("Position");
                IEnumerable <XElement> posElems = elem.First(f => f.Attribute("Name").Value == "Quarterback").Elements();
                foreach (XElement e in posElems)
                {
                    Lineup pos = new Lineup();
                    pos.Load(e);
                    pos.LoadLineup(e);
                    Quarterback.Add(pos);
                }

                IEnumerable <XElement> elems = doc.Descendants("Positions");

                posElems = elems.First(f => f.Attribute("Name").Value == "Receivers").Elements();
                foreach (XElement e in posElems)
                {
                    Lineup pos = new Lineup();
                    pos.LoadLineup(e);
                    Receivers.Add(pos);
                }

                posElems = elems.First(f => f.Attribute("Name").Value == "Runningbacks").Elements();
                foreach (XElement e in posElems)
                {
                    Lineup pos = new Lineup();
                    pos.LoadLineup(e);
                    Runningbacks.Add(pos);
                }

                posElems = elems.First(f => f.Attribute("Name").Value == "OffensiveLinemen").Elements();
                foreach (XElement e in posElems)
                {
                    Lineup pos = new Lineup();
                    pos.LoadLineup(e);
                    OffensiveLinemen.Add(pos);
                }

                posElems = elems.First(f => f.Attribute("Name").Value == "TightEnds").Elements();
                foreach (XElement e in posElems)
                {
                    Lineup pos = new Lineup();
                    pos.LoadLineup(e);
                    TightEnds.Add(pos);
                }

                posElems = elems.First(f => f.Attribute("Name").Value == "Cornerbacks").Elements();
                foreach (XElement e in posElems)
                {
                    Lineup pos = new Lineup();
                    pos.LoadLineup(e);
                    Cornerbacks.Add(pos);
                }

                posElems = elems.First(f => f.Attribute("Name").Value == "Linebackers").Elements();
                foreach (XElement e in posElems)
                {
                    Lineup pos = new Lineup();
                    pos.LoadLineup(e);
                    Linebackers.Add(pos);
                }

                posElems = elems.First(f => f.Attribute("Name").Value == "DefensiveLinemen").Elements();
                foreach (XElement e in posElems)
                {
                    Lineup pos = new Lineup();
                    pos.LoadLineup(e);
                    DefensiveLinemen.Add(pos);
                }

                posElems = elems.First(f => f.Attribute("Name").Value == "Safeties").Elements();
                foreach (XElement e in posElems)
                {
                    Lineup pos = new Lineup();
                    pos.LoadLineup(e);
                    Safeties.Add(pos);
                }
            }
            else
            {
                this.Init();
            }
        }