Пример #1
0
        public string GetPrediction(string scheduleID, float num)
        {
            WebClientBLL.UpdateAnalysisContent(scheduleID);
            string actual = DataCache.GetCache("AnalysisContent").ToString();
            string h_data = "";
            Regex  reg    = new Regex("var h_data\\=\\[\\[" + "\\S[^;" + "]*\\]\\];");
            Match  mat    = reg.Match(actual);

            if (mat != null)
            {
                h_data = mat.Value;
            }
            h_data = h_data.Replace("var h_data=[[", "").Replace("]];", "");

            string h2h_home = "";

            reg = new Regex("var h2h_home \\= " + "\\d+;");
            mat = reg.Match(actual);
            if (mat != null)
            {
                h2h_home = StringPlus.DelLastChar(mat.Value.Replace("var h2h_home = ", ""), ";");
            }

            string a_data = "";

            reg = new Regex("var a_data\\=\\[\\[" + "\\S[^;" + "]*\\]\\];");
            mat = reg.Match(actual);
            if (mat != null)
            {
                a_data = mat.Value;
            }
            a_data = a_data.Replace("var a_data=[[", "").Replace("]];", "");

            string h2h_away = "";

            reg = new Regex("var h2h_away \\= " + "\\d+;");
            mat = reg.Match(actual);
            if (mat != null)
            {
                h2h_away = StringPlus.DelLastChar(mat.Value.Replace("var h2h_away = ", ""), ";");
            }

            float big   = 0f;
            float small = 0f;

            //分解出主队过去成绩
            string[] h_dataArr = Regex.Split(h_data, "\\],\\[", RegexOptions.IgnoreCase);
            foreach (string arr in h_dataArr)
            {
                string[] match = arr.Split(',');
                float    goal  = float.Parse(match[8]) + float.Parse(match[9]);
                if (goal > num)
                {
                    big++;
                }
                else if (goal < num)
                {
                    small++;
                }
            }

            //分解出客队过去成绩
            string[] a_dataArr = Regex.Split(a_data, "\\],\\[", RegexOptions.IgnoreCase);
            foreach (var arr in a_dataArr)
            {
                string[] match = arr.Split(',');
                float    goal  = float.Parse(match[8]) + float.Parse(match[9]);
                if (goal > num)
                {
                    big++;
                }
                else if (goal < num)
                {
                    small++;
                }
            }

            float bigprobability = big / (h_dataArr.Length + a_dataArr.Length);

            float smallprobability = small / (h_dataArr.Length + a_dataArr.Length);

            StringBuilder sb = new StringBuilder();

            sb.Append("大于" + num + "的机会有 :" + bigprobability);

            sb.Append("<br /><br />");

            sb.Append("小于" + num + "的机会有 :" + smallprobability);

            sb.Append("<br /><br />");

            sb.Append("走盘的机会有 :" + (1f - bigprobability - smallprobability));
            return(sb.ToString());
        }
Пример #2
0
        public string Analysis(string scheduleID)
        {
            WebClientBLL.UpdateAnalysisContent(scheduleID);
            string actual = DataCache.GetCache("AnalysisContent").ToString();
            string h_data = "";
            Regex  reg    = new Regex("var h_data\\=\\[\\[" + "\\S[^;" + "]*\\]\\];");
            Match  mat    = reg.Match(actual);

            if (mat != null)
            {
                h_data = mat.Value;
            }
            h_data = h_data.Replace("var h_data=[[", "").Replace("]];", "");

            string h2h_home = "";

            reg = new Regex("var h2h_home \\= " + "\\d+;");
            mat = reg.Match(actual);
            if (mat != null)
            {
                h2h_home = StringPlus.DelLastChar(mat.Value.Replace("var h2h_home = ", ""), ";");
            }

            string a_data = "";

            reg = new Regex("var a_data\\=\\[\\[" + "\\S[^;" + "]*\\]\\];");
            mat = reg.Match(actual);
            if (mat != null)
            {
                a_data = mat.Value;
            }
            a_data = a_data.Replace("var a_data=[[", "").Replace("]];", "");

            string h2h_away = "";

            reg = new Regex("var h2h_away \\= " + "\\d+;");
            mat = reg.Match(actual);
            if (mat != null)
            {
                h2h_away = StringPlus.DelLastChar(mat.Value.Replace("var h2h_away = ", ""), ";");
            }


            //分解出主队过去成绩
            string[] h_dataArr   = Regex.Split(h_data, "\\],\\[", RegexOptions.IgnoreCase);
            float    h_point     = 100f;
            float    h_goalcount = 0f;
            int      h_sixpoint  = 0;

            foreach (string arr in h_dataArr)
            {
                string[] match = arr.Split(',');
                if (h2h_home == match[4])
                {
                    h_point      = PredictionHelper.EloHomePointsCalculation(h_point, match[17]);
                    h_goalcount += int.Parse(match[8]);
                }
                else
                {
                    h_point      = PredictionHelper.EloAwayPointsCalculation(h_point, match[17]);
                    h_goalcount += int.Parse(match[9]);
                }
                h_sixpoint = PredictionHelper.SixGamePointCalculation(h_sixpoint, match[17]);
            }

            //分解出客队过去成绩
            string[] a_dataArr   = Regex.Split(a_data, "\\],\\[", RegexOptions.IgnoreCase);
            float    a_point     = 100;
            float    a_goalcount = 0f;
            int      a_sixpoint  = 0;

            foreach (string arr in a_dataArr)
            {
                string[] match = arr.Split(',');
                if (h2h_away == match[4])
                {
                    a_point      = PredictionHelper.EloHomePointsCalculation(a_point, match[17]);
                    a_goalcount += int.Parse(match[8]);
                }
                else
                {
                    a_point      = PredictionHelper.EloAwayPointsCalculation(a_point, match[17]);
                    a_goalcount += int.Parse(match[9]);
                }
                a_sixpoint = PredictionHelper.SixGamePointCalculation(a_sixpoint, match[17]);
            }

            string HomePossible = PredictionHelper.EloHomePrediction(h_point, a_point) * 100 + "%";
            string AwayPossible = PredictionHelper.EloAwayPrediction(h_point, a_point) * 100 + "%";


            //string SixGame = PredictionHelper.SixGamePrediction(h_sixpoint, a_sixpoint);
            StringBuilder sb = new StringBuilder();

            sb.Append("埃罗预测法 :主队积分为" + h_point + ",客队积分为" + a_point + ",按照埃罗预测法主队获胜的可能性有" + HomePossible + ",客队获胜的可能性有" + AwayPossible);



            return(sb.ToString());
        }