Esempio n. 1
0
        public static Dictionary <String, OffensivePlay> GetIFormTwoWRPassPlays()
        {
            Dictionary <String, OffensivePlay> retVal = new Dictionary <string, OffensivePlay>();

            RouteTypes[]  routes = new RouteTypes[] { RouteTypes.SLANT, RouteTypes.OUT, RouteTypes.GO, RouteTypes.PASS_BLOCK, RouteTypes.DRAG };
            OffensivePlay play   = new OffensivePlay(OffensivePlayType.PASS, null, routes);

            retVal.Add("Deep Pass", play);
            return(retVal);
        }
Esempio n. 2
0
        private void DoDrive(bool endIfTimeExpires)
        {
            Random r = Random.GetInstance();

            while (true)
            {
                OffensivePlay offensivePlay = ChoosePlay();
                DefensivePlay defensivePlay = ChooseDefensivePlay(offensivePlay.GetFormation());

                PlayResult result = Field.GetInstance().RunPlay(ball, lineToGain, offensivePlay, defensivePlay, teamOnePossession);

                if (result == null)
                {
                    quarterTime -= 100000;
                    return;
                }

                if (result.turnover)
                {
                    teamOnePossession = !teamOnePossession;
                    if (result.touchdown)
                    {
                        if (teamOnePossession)
                        {
                            teamOneScore[quarter - 1] += 6;
                            DoExtraPoint();
                        }
                        else
                        {
                            teamTwoScore[quarter - 1] += 6;
                            DoExtraPoint();
                        }
                    }
                    return;
                }
                else if (result.touchdown)
                {
                    if (teamOnePossession)
                    {
                        teamOneScore[quarter - 1] += 6;
                        DoExtraPoint();
                    }
                    else
                    {
                        teamTwoScore[quarter - 1] += 6;
                        DoExtraPoint();
                    }
                }
            }
        }
Esempio n. 3
0
        private PlayResult DoPass(OffensivePlay offense, DefensivePlay defense)
        {
            routes = new RouteTypes[5];
            bool playOver = false, first = true;

            while (!playOver)
            {
                for (int i = 0; i < 5; i++)
                {
                    routes[i] = RunRoute(offensivePlayers[i + 6], first ? offense.GetRoute(i, offensivePlayerLocations[i + 6].Item1, offensivePlayerLocations[i + 6].Item2) : routes[i]);
                }
                first = false;
            }
            return(null);
        }
Esempio n. 4
0
        public PlayResult RunPlay(BallLocation ball, int lineToGain, OffensivePlay offensivePlay, DefensivePlay defensivePlay, bool teamOnePossesion)
        {
            field     = new FieldObject(this);
            this.ball = ball;
            SetUpPlay(lineToGain, offensivePlay, defensivePlay, teamOnePossesion);


            if (offensivePlay.GetPlayType() != OffensivePlayType.PASS)
            {
                return(DoRun(offensivePlay, defensivePlay));
            }
            else
            {
                return(DoPass(offensivePlay, defensivePlay));
            }
        }
Esempio n. 5
0
        private void SetUpPlay(int lineToGain, OffensivePlay offense, DefensivePlay defense, bool teamOnePossesion)
        {
            OffensiveFormation offensiveFormation = offense.GetFormation() as OffensiveFormation;

            offensivePlayers = offensiveFormation.GetPlayers(teamOnePossesion ? teamOne.GetDepthChart() : teamTwo.GetDepthChart());
            DefensiveFormation defensiveFormation = defense.GetFormation() as DefensiveFormation;

            defensivePlayers = defensiveFormation.GetPlayers(teamOnePossesion ? teamTwo.GetDepthChart() : teamOne.GetDepthChart());

            offensivePlayerLocations = new Tuple <int, int> [11];
            defensivePlayerLocations = new Tuple <int, int> [11];
            for (int i = 0; i < offensivePlayerLocations.Length; i++)
            {
                offensivePlayerLocations[i] = new Tuple <int, int>(-1, -1);
                defensivePlayerLocations[i] = new Tuple <int, int>(-1, -1);
            }

            int midPoint        = ball.GetWidth();
            int lineOfScrimmage = ball.GetLength();

            field[lineOfScrimmage, midPoint]     = 4;
            offensivePlayerLocations[3]          = new Tuple <int, int>(lineOfScrimmage, midPoint);
            field[lineOfScrimmage, midPoint - 3] = 3;
            field[lineOfScrimmage, midPoint - 6] = 2;
            field[lineOfScrimmage, midPoint + 3] = 5;
            field[lineOfScrimmage, midPoint + 6] = 6;

            EligibleRecieverLayout[] locations = offensiveFormation.GetLocations();

            List <int> leftTEs = new List <int>(), rightTEs = new List <int>(), leftWRs = new List <int>(), rightWRs = new List <int>();

            if (offensiveFormation.GetShotGun())
            {
                field[lineOfScrimmage - 15, midPoint] = 1;
                for (int i = 0; i < locations.Length; i++)
                {
                    if (locations[i].GetLocation() == EligibleLocation.BACKFIELD)
                    {
                        if (locations[i].GetLeft())
                        {
                            field[lineOfScrimmage - 15, midPoint - 3] = 7 + i;
                        }
                        else
                        {
                            field[lineOfScrimmage - 15, midPoint + 3] = 7 + i;
                        }
                    }
                    else
                    {
                        if (locations[i].GetPosition() == (int)Constants.WR)
                        {
                            if (locations[i].GetLeft())
                            {
                                leftWRs.Add(i);
                            }
                            else
                            {
                                rightWRs.Add(i);
                            }
                        }
                        else
                        {
                            if (locations[i].GetLeft())
                            {
                                leftTEs.Add(i);
                            }
                            else
                            {
                                rightTEs.Add(i);
                            }
                        }
                    }
                }
            }
            else
            {
                field[lineOfScrimmage - 3, midPoint] = 1;
                for (int i = 0; i < locations.Length; i++)
                {
                    if (locations[i].GetLocation() == EligibleLocation.BACKFIELD || locations[i].GetLocation() == EligibleLocation.CENTER_BACKFIELD)
                    {
                        int playerMidPoint;
                        if (locations[i].GetLocation() == EligibleLocation.CENTER_BACKFIELD)
                        {
                            playerMidPoint = midPoint;
                        }
                        else if (locations[i].GetLeft())
                        {
                            playerMidPoint = midPoint - 3;
                        }
                        else
                        {
                            playerMidPoint = midPoint + 3;
                        }

                        int playerLine;

                        if (locations[i].GetPosition() == 1)
                        {
                            playerLine = lineOfScrimmage - 15;
                        }
                        else
                        {
                            playerLine = lineOfScrimmage - 9;
                        }

                        field[playerLine, playerMidPoint] = 7 + i;
                    }
                    else
                    {
                        if (locations[i].GetPosition() == (int)Constants.WR)
                        {
                            if (locations[i].GetLeft())
                            {
                                leftWRs.Add(i);
                            }
                            else
                            {
                                rightWRs.Add(i);
                            }
                        }
                        else
                        {
                            if (locations[i].GetLeft())
                            {
                                leftTEs.Add(i);
                            }
                            else
                            {
                                rightTEs.Add(i);
                            }
                        }
                    }
                }
            }
            for (int i = 0; i < leftTEs.Count; i++)
            {
                int playerMidPoint = midPoint - (i * 3 + 9);
                int playerLine;

                if (locations[leftTEs[i]].GetLocation() == EligibleLocation.ON_LINE)
                {
                    playerLine = lineOfScrimmage;
                }
                else
                {
                    playerLine = lineOfScrimmage - 2;
                }

                field[playerLine, playerMidPoint] = 7 + leftTEs[i];
            }
            for (int i = 0; i < rightTEs.Count; i++)
            {
                int playerMidPoint = midPoint + (i * 3 + 9);
                int playerLine;

                if (locations[rightTEs[i]].GetLocation() == EligibleLocation.ON_LINE)
                {
                    playerLine = lineOfScrimmage;
                }
                else
                {
                    playerLine = lineOfScrimmage - 2;
                }

                field[playerLine, playerMidPoint] = 7 + rightTEs[i];
            }
            for (int i = 0; i < leftWRs.Count; i++)
            {
                int num            = i + 1;
                int playerMidPoint = (num * midPoint) / (leftWRs.Count + 1);//(num * midPoint) / (leftWRs.Count + num);

                int playerLine;

                if (locations[leftWRs[i]].GetLocation() == EligibleLocation.ON_LINE)
                {
                    playerLine = lineOfScrimmage;
                }
                else
                {
                    playerLine = lineOfScrimmage - 2;
                }

                field[playerLine, playerMidPoint] = 7 + leftWRs[i];
            }
            for (int i = 0; i < rightWRs.Count; i++)
            {
                int num            = i + 1;
                int playerMidPoint = midPoint + (num * ((160 - midPoint)) / (rightWRs.Count + 1));

                int playerLine;

                if (locations[rightWRs[i]].GetLocation() == EligibleLocation.ON_LINE)
                {
                    playerLine = lineOfScrimmage;
                }
                else
                {
                    playerLine = lineOfScrimmage - 2;
                }

                field[playerLine, playerMidPoint] = 7 + rightWRs[i];
            }



            File.WriteAllText(fileName + ".txt", field.ToString());
            fileName++;
        }
Esempio n. 6
0
 private PlayResult DoRun(OffensivePlay offense, DefensivePlay defense)
 {
     return(null);
 }