Example #1
0
        // 해당일의 분석을 가져온다.
        public List <AnalyzerData> GetAnalyzeData(DateTime datetime)
        {
            // 경기를 가져온다.
            DatabaseManager dbMgr     = new DatabaseManager();
            var             players   = dbMgr.SelectAll <Player>();
            var             matches   = dbMgr.SelectAll <Match>();
            var             schedules = dbMgr.SelectAll <Schedule>();
            var             ths       = dbMgr.SelectAll <Th>();
            var             bats      = dbMgr.SelectAll <Bat>();

            // 경기를 가져온다.
            var tMatches = from m in matches
                           where m.GameId.StartsWith(datetime.ToString("yyyyMMdd"))
                           select m;


            List <AnalyzerData> analyzerDatas = new List <AnalyzerData>();

            // 해당일의 경기별로 돌면서 작업
            foreach (var match in tMatches)
            {
                // 홈팀가져오기
                String teamInitial  = match.GameId.Substring(10, 2);
                var    analyzerData = GetAnalyzerData(match, AttackType.Home, teamInitial, datetime);
                analyzerDatas.Add(analyzerData);

                // 어웨이팀 가져오기
                teamInitial  = match.GameId.Substring(8, 2);
                analyzerData = GetAnalyzerData(match, AttackType.Away, teamInitial, datetime);
                analyzerDatas.Add(analyzerData);
            }

            // 지난 데이터의 분석기 생성
            BeThe.DataAnalyzer.Manager analyzer = new BeThe.DataAnalyzer.Manager();
            analyzer.MaxDateTime = datetime;

            // 상대전분석
            foreach (var analyzerData in analyzerDatas)
            {
                foreach (var hitData in analyzerData.HitterInfos)
                {
                    hitData.AgainstRatio =
                        analyzer.GetAgainstHitRatio(analyzerData.PitcherInfo.PlayerId, hitData.PlayerId);
                }
            }

            return(analyzerDatas);
        }
Example #2
0
        public List <HitterInfo> Pick(DateTime datetime)
        {
            // 경기를 가져온다.
            DatabaseManager dbMgr     = new DatabaseManager();
            var             players   = dbMgr.SelectAll <Player>();
            var             matches   = dbMgr.SelectAll <Match>();
            var             schedules = dbMgr.SelectAll <Schedule>();
            var             ths       = dbMgr.SelectAll <Th>();
            var             bats      = dbMgr.SelectAll <Bat>();

            // 경기를 가져온다.
            var tMatches = from m in matches
                           where m.GameId.StartsWith(datetime.ToString("yyyyMMdd"))
                           select m;


            List <AnalyzerData> analyzerDatas = new List <AnalyzerData>();

            // 해당일의 경기별로 돌면서 작업
            foreach (var match in tMatches)
            {
                // 홈팀가져오기
                String teamInitial  = match.GameId.Substring(10, 2);
                var    analyzerData = GetAnalyzerData(match, AttackType.Home, teamInitial, datetime);
                analyzerDatas.Add(analyzerData);

                // 어웨이팀 가져오기
                teamInitial  = match.GameId.Substring(8, 2);
                analyzerData = GetAnalyzerData(match, AttackType.Away, teamInitial, datetime);
                analyzerDatas.Add(analyzerData);
            }

            // 지난 데이터의 분석기 생성
            BeThe.DataAnalyzer.Manager analyzer = new BeThe.DataAnalyzer.Manager();
            analyzer.MaxDateTime = datetime;

            // 상대전분석
            foreach (var analyzerData in analyzerDatas)
            {
                foreach (var hitData in analyzerData.HitterInfos)
                {
                    hitData.AgainstRatio =
                        analyzer.GetAgainstHitRatio(analyzerData.PitcherInfo.PlayerId, hitData.PlayerId);
                }
            }

            // 픽을 결정한다.
            List <HitterInfo> hitInfosLevel1 = GetHitInfos(1, analyzerDatas);
            List <HitterInfo> hitInfosLevel2 = GetHitInfos(2, analyzerDatas);
            List <HitterInfo> hitInfosLevel3 = GetHitInfos(3, analyzerDatas);

            Int32 maxCount = 5;
            Dictionary <Int32, HitterInfo> dicPicks = new Dictionary <Int32, HitterInfo>();

            Sort(hitInfosLevel1);
            Sort(hitInfosLevel2);
            Sort(hitInfosLevel3);

            foreach (var hitterInfo in hitInfosLevel1)
            {
                if (dicPicks.Count >= maxCount)
                {
                    break;
                }
                if (dicPicks.ContainsKey(hitterInfo.PlayerId))
                {
                    continue;
                }
                else
                {
                    dicPicks.Add(hitterInfo.PlayerId, hitterInfo);
                }
            }
            if (dicPicks.Count > 2)
            {
                return(dicPicks.Values.ToList());
            }

            foreach (var hitterInfo in hitInfosLevel2)
            {
                if (dicPicks.Count >= maxCount)
                {
                    break;
                }
                if (dicPicks.ContainsKey(hitterInfo.PlayerId))
                {
                    continue;
                }
                else
                {
                    dicPicks.Add(hitterInfo.PlayerId, hitterInfo);
                }
            }
            if (dicPicks.Count > 2)
            {
                return(dicPicks.Values.ToList());
            }

            foreach (var hitterInfo in hitInfosLevel3)
            {
                if (dicPicks.Count >= maxCount)
                {
                    break;
                }
                if (dicPicks.ContainsKey(hitterInfo.PlayerId))
                {
                    continue;
                }
                else
                {
                    dicPicks.Add(hitterInfo.PlayerId, hitterInfo);
                }
            }

            return(dicPicks.Values.ToList());
        }