Beispiel #1
0
        // 투수정보를 가지고 온다.
        private PitcherInfo GetFirstPitchers(Match match, AttackType attckType,
                                             String teamInitial, 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>();

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

            ThType tyType = attckType == AttackType.Home ? ThType.말 : ThType.초;

            var pitcherId = (from t in ths
                             join b in bats
                             on t.Id equals b.ThId
                             where t.MatchId == match.Id &&
                             t.Number == 1 && t.ThType == tyType
                             select b).First().PitcherId;

            // 투수 정보 가져오기
            var pitcherInfo = analyzer.GetPitcherInfo(pitcherId, 4);

            return(pitcherInfo);
        }
Beispiel #2
0
        // 타자의 분석정보를 가져온다.
        private HitterInfoDetail GetDetailHitterInfo(Int32 playerId,
                                                     BeThe.DataAnalyzer.Manager analyzer, String teamInitial)
        {
            // 연속안타일수를 구한다.
            Int32 hitDay = analyzer.GetHitDay(teamInitial, playerId);
            // HitterInfoDetail 클래스 다시 코딩

            Boolean isAllDayHit5        = analyzer.IsAllDayHit(teamInitial, playerId, 5);
            Boolean isAllDayHit3        = analyzer.IsAllDayHit(teamInitial, playerId, 4);
            Boolean isLongHit           = analyzer.IsLongHitLastGame(teamInitial, playerId, 2);
            Boolean isAllDayFirstNumber = analyzer.IsAllFastNumber(teamInitial, playerId, 4);
            Int32   hitCount            = analyzer.GetHitNumberForNDays(teamInitial, playerId, 3);
            Double  hitRatio            = analyzer.GetHitRatio(teamInitial, playerId, 3);
            String  name = analyzer.GetPlayerName(playerId);

            return(new HitterInfoDetail
            {
                IsAllDayFirstNumber = isAllDayFirstNumber,
                PlayerId = playerId,
                PlayerName = name,
                IsAllDayHit3 = isAllDayHit3,
                IsAllDayHit5 = isAllDayHit5,
                IsLongHit = isLongHit,
                HitCount = hitCount,
                HitRatio = hitRatio,
            });
        }
Beispiel #3
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);
        }
Beispiel #4
0
        //  한경기의 한쪽 팀의 분석정보를 가져온다.
        private AnalyzerData GetAnalyzerData(Match match, AttackType attckType,
                                             String teamInitial, DateTime dateTime)
        {
            // 분석된 데이터 만들기
            AnalyzerData analyzerData = new AnalyzerData();

            analyzerData.HitterInfos = new List <HitterInfo>();

            // 경기를 가져온다.
            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>();

            ThType tyType = attckType == AttackType.Home ? ThType.말 : ThType.초;

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

            // 당일 선발투수 가져오기(분석시 입력 혹은 크롤링 구현)
            var pitcherId = (from t in ths
                             join b in bats
                             on t.Id equals b.ThId
                             where t.MatchId == match.Id &&
                             t.Number == 1 && t.ThType == tyType
                             select b).First().PitcherId;

            // 투수 정보 가져오기
            analyzerData.PitcherInfo = analyzer.GetPitcherInfo(pitcherId, 4);

            // 타자리스트 얻어오기
            var hitters = analyzer.GetStartPlayerForNDays(teamInitial, 4);

            foreach (var hitter in hitters)
            {
                // 각타자의 정보 얻어오기
                var HitInfo = GetHitterInfo(hitter.PlayerId, analyzer, teamInitial);
                analyzerData.HitterInfos.Add(HitInfo);
            }
            return(analyzerData);
        }
Beispiel #5
0
        //  한경기의 한쪽 팀의 분석정보를 가져온다.
        private List <BatterInfo> GetAnalyzerData(Match match, AttackType attckType,
                                                  String teamInitial, 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>();

            ThType tyType = attckType == AttackType.Home ? ThType.말 : ThType.초;

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

            var   batterInfos = new List <BatterInfo>();
            Int32 pitcherId;

            // 당일 선발투수 가져오기(분석시 입력 혹은 크롤링 구현)
            try
            {
                pitcherId = (from t in ths
                             join b in bats
                             on t.Id equals b.ThId
                             where t.MatchId == match.Id &&
                             t.Number == 1 && t.ThType == tyType
                             select b).First().PitcherId;



                //// 투수 정보 가져오기
                //Boolean isQualityStart = analyzer.IsQualityStart(pitcherId);
                //if (isQualityStart)
                //{
                //    return batterInfos;
                //}
            }
            catch
            {
                return(batterInfos);
            }

            // N경기동안 M번 선발출장한 선수들 가져오기
            var hitters = analyzer.GetPlayersStartingGame(teamInitial, 5, 4);

            // 타자조건 실행하기
            foreach (var hitter in hitters)
            {
                try
                {
                    // 타석수 구하기
                    var pa = analyzer.GetPA(teamInitial, hitter.PlayerId);

                    // 안타수 구하기
                    var hitCount = analyzer.GetHitCout(teamInitial, hitter.PlayerId);

                    // 안타확률 구하기
                    var hitRatio = (hitCount * 1.0) / pa;

                    // 팀의 지난 M경기동안 안타를 친날 구하기
                    var hitDayCount = analyzer.GetHitDayCountForNDays(teamInitial, hitter.PlayerId, 6);

                    var batterInfo = new BatterInfo();
                    if (hitRatio > 0.2 && hitDayCount >= 5)
                    {
                        batterInfo.PlayerId    = hitter.PlayerId;
                        batterInfo.Name        = hitter.Name;
                        batterInfo.PA          = pa;
                        batterInfo.HitCount    = hitCount;
                        batterInfo.HitRatio    = hitRatio;
                        batterInfo.HitDayCount = hitDayCount;
                        batterInfos.Add(batterInfo);
                    }
                }
                catch
                {
                }
            }
            return(batterInfos);
        }
Beispiel #6
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());
        }
Beispiel #7
0
        //  한경기의 한쪽 팀의 분석정보를 가져온다.
        private List <BatterInfo> GetAnalyzerData(Match match, AttackType attckType,
                                                  String teamInitial, DateTime dateTime, Int32 alldayHitcount)
        {
            // 경기를 가져온다.
            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>();

            ThType tyType = attckType == AttackType.Home ? ThType.말 : ThType.초;

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

            var   batterInfos = new List <BatterInfo>();
            Int32 pitcherId;

            // 당일 선발투수 가져오기(분석시 입력 혹은 크롤링 구현)
            try
            {
                pitcherId = (from t in ths
                             join b in bats
                             on t.Id equals b.ThId
                             where t.MatchId == match.Id &&
                             t.Number == 1 && t.ThType == tyType
                             select b).First().PitcherId;



                // 투수 정보 가져오기
                Boolean isQualityStart = analyzer.IsQualityStart(pitcherId);
                if (isQualityStart)
                {
                    return(batterInfos);
                }
            }
            catch
            {
                return(batterInfos);
            }

            // 타자리스트 얻어오기
            var hitters = analyzer.GetStartPlayerForNDays(teamInitial, 3);

            foreach (var hitter in hitters)
            {
                try
                {
                    var   hitRatio        = analyzer.GetHitRatio(teamInitial, hitter.PlayerId, 3);
                    var   allHitRatio     = analyzer.GetHitRatio(teamInitial, hitter.PlayerId, 100);
                    var   isAllFastNumber = analyzer.IsAllFastNumber(teamInitial, hitter.PlayerId, 3);
                    Int32 hitCount        = analyzer.GetHitNumberForNDays(teamInitial, hitter.PlayerId, 1);
                    if (hitRatio > 0.33 && allHitRatio > 0.3 && isAllFastNumber && (hitCount < 2))
                    {
                        var batterInfo = new BatterInfo();
                        batterInfo.PlayerId  = hitter.PlayerId;
                        batterInfo.Name      = hitter.Name;
                        analyzer.MaxDateTime = analyzer.MaxDateTime.AddDays(-1);
                        batterInfo.HitRatio  = analyzer.GetHitRatio(teamInitial, hitter.PlayerId, 7);
                        analyzer.MaxDateTime = analyzer.MaxDateTime.AddDays(1);
                        batterInfos.Add(batterInfo);
                    }
                }
                catch
                {
                }
            }
            return(batterInfos);
        }