コード例 #1
0
        public TeamSimulationDetails(BasketballTeam t)
        {
            Team     = t;
            Players  = new BasketballPlayerList();
            Outcomes = new List <TeamSimulationOutcome>();
            double[] oppfg = t.OpponentFieldGoalsTakenByGame();
            double[] fg    = t.FieldGoalsTakenByGame();
            FieldGoalPercentage         = t.RemoveHomeAdvantage(t.FieldGoalPercentageByGame()).Average();
            FieldGoalsTaken             = t.RemoveHomeAdvantage(fg).Average();
            FreeThrowPercentage         = t.RemoveHomeAdvantage(t.FreeThrowPercentageByGame()).Average();
            ThreePointPercentage        = t.RemoveHomeAdvantage(t.ThreePointPercentageByGame()).Average();
            ThreePointsTakenPercentage  = t.RemoveHomeAdvantage(t.ThreePointersTakenByGame().Divide(fg)).Average();
            OffensiveReboundPercentage  = t.RemoveHomeAdvantage(t.OffensiveReboundPercentageByGame()).Average();
            DefensiveReboundPercentage  = t.RemoveHomeAdvantage(t.DefensiveReboundPercentageByGame()).Average();
            OffensiveTurnoverPercentage = t.RemoveHomeAdvantage(t.TurnoversByGame().Divide(fg)).Average();
            double[] b = t.StealsByGame();
            StealPercentage = t.RemoveHomeAdvantage(b.Divide(b.Add(oppfg))).Average();
            b = t.BlocksByGame();
            BlockPercentage               = t.RemoveHomeAdvantage(b.Divide(b.Add(oppfg))).Average();
            BlockedPercentage             = t.RemoveHomeAdvantage(t.OpponentBlocksByGame().Divide(fg)).Average();
            FoulPercentage                = t.RemoveHomeAdvantage(t.FoulsByGame().Divide(oppfg)).Average();
            FouledPercentage              = t.RemoveHomeAdvantage(t.OpponentFoulsByGame().Divide(fg)).Average();
            PlayerFreeThrowProbabilities  = new double[t.Players.Count];
            PlayerFreeThrowPercentages    = new double[t.Players.Count];
            PlayerFieldGoalProbabilities  = new double[t.Players.Count];
            PlayerFieldGoalPercentages    = new double[t.Players.Count];
            PlayerThreePointProbabilities = new double[t.Players.Count];
            PlayerThreePointPercentages   = new double[t.Players.Count];
            PlayerAssistPercentages       = new double[t.Players.Count];
            PlayerOnCourtProbabilities    = new double[t.Players.Count];
            PlayerStartProbabilities      = new double[t.Players.Count];
            PlayersOnCourt                = new double[t.Players.Count];
            double ft  = t.FreeThrowsTakenByGame().Sum();
            double fgs = fg.Sum();
            double ap  = t.AssistsByGame().Sum();

            for (int p = 0; p < t.Players.Count; p++)
            {
                Players.Add(t.Players[p]);
                PlayerFreeThrowProbabilities[p] = t.Players[p].FTA / ft;
                PlayerFreeThrowPercentages[p]   = t.Players[p].FTP;
                PlayerFieldGoalProbabilities[p] = t.Players[p].FTA / fgs;
                PlayerFieldGoalPercentages[p]   = t.Players[p].FGP;
                if (t.Players[p].FGA > 0)
                {
                    PlayerThreePointProbabilities[p] = t.Players[p].A3P / t.Players[p].FGA;
                }
                else
                {
                    PlayerThreePointProbabilities[p] = 0;
                }
                PlayerThreePointPercentages[p] = t.Players[p].P3P;
                PlayerAssistPercentages[p]     = t.Players[p].AST / (double)(t.Players[p].AST + t.Players[p].FGA);
                PlayerOnCourtProbabilities[p]  = t.Players[p].MIN_T * t.Matchups.Count / 48.0;
                PlayerStartProbabilities[p]    = t.Players[p].Starts / (double)t.Matchups.Count;
            }
        }