public override List <ChanceClass> getChances(CommCollection sc, ExpectData ed)
        {
            List <ChanceClass> ret = new List <ChanceClass>();
            DataTableEx        dt  = null;

            if (this.BySer)
            {
                dt = sc.SerialDistributionTable;
            }
            else
            {
                dt = sc.CarDistributionTable;
            }
            if (dt == null)
            {
                throw new Exception("无法获得概率分布表!");
            }
            string strCodes   = "";
            int    AllChipCnt = 0;

            for (int i = 0; i < 10; i++)
            {
                //获得各项的最小的
                List <double> coldata = null;
                string        strCol  = string.Format("{0}", (i + 1) % 10);
                dt.getColumnData(strCol, ref coldata);
                double    avgval  = coldata.Average();
                double    stdval  = ProbMath.CalculateStdDev(coldata);
                string    strSql  = string.Format("[{0}]<{1}", strCol, avgval - this.StdvCnt * stdval);
                string    strSort = string.Format("[{0}] asc", "Id");
                DataRow[] drs     = dt.Select(strSql, strSort);
                if (drs.Length < this.ChipCount)
                {
                    continue;
                }

                string        strCode = "";
                StringBuilder sb      = new StringBuilder();
                bool          Matched = false;
                for (int j = 0; j < drs.Length; j++)
                {
                    string strId  = drs[j]["Id"].ToString();
                    int    RowCnt = sc.FindLastDataExistCount(this.InputMinTimes, strCol, strId);
                    if (RowCnt > 0)//任何一个不匹配最近5期内出现,不满足条件
                    {
                        Matched = false;
                        break;
                    }
                    sb.Append(drs[j]["Id"].ToString());
                    Matched = true;
                }
                if (!Matched)
                {
                    continue;
                }
                AllChipCnt += drs.Length;
                if (BySer)
                {
                    strCode = string.Format("{0}/{1}", strCol, sb.ToString());
                }
                else
                {
                    strCode = string.Format("{0}/{1}", sb.ToString(), strCol);
                }
                if (strCode.Length > 0)
                {
                    strCodes = string.Format("{0}{1}{2}", strCodes, strCodes.Length > 0?"+":"", strCode);
                }
            }
            if (strCodes.Length < 2 * (this.ChipCount + 2))
            {
                return(ret);
            }
            ChanceClass cc = new ChanceClass();

            cc.SignExpectNo        = ed.Expect;
            cc.ChanceType          = 3;
            cc.InputTimes          = 1;
            cc.strInputTimes       = "1";
            cc.AllowMaxHoldTimeCnt = 1;
            cc.InputExpect         = ed;
            cc.ChipCount           = AllChipCnt;
            cc.ChanceCode          = strCodes;
            cc.CreateTime          = ed.OpenTime;
            cc.Closed = false;
            ret.Add(cc);
            return(ret);
        }
Ejemplo n.º 2
0
        public override List <ChanceClass> getChances(BaseCollection sc, ExpectData ed)
        {
            List <ChanceClass> ret = new List <ChanceClass>();

            CurrChancesCnt = 0;//置零,防止后面留存
            ExpectList LastDataList = this.LastUseData();

            if (LastDataList == null)
            {
                Log(this.StragClassName, "数据为空!");
                return(ret);
            }
            if (LastDataList.Count < ReviewExpectCnt)
            {
                Log("基础数据数量不足", string.Format("小于回览期数:{0}", ReviewExpectCnt));
                return(ret);
            }
            //ExpectList LastDataList = datas;
            ExpectData PreData = LastDataList[LastDataList.Count - 2];
            //Log(string.Format("前期{0}:{1}", PreData.Expect, PreData.OpenCode), string.Format("当期{0}:{1}", LastDataList.LastData.Expect, LastDataList.LastData.OpenCode));
            //Log(string.Format("el数据长度:{0},First:{1};Last{2}", LastDataList.Count,LastDataList.FirstData.Expect,LastDataList.LastData.Expect), string.Format("原始数据长度:{0};First:{1};Last:{2}", sc.orgData.Count,sc.orgData.FirstData.Expect,sc.orgData.LastData.Expect));
            DataTableEx   dt       = sc.getSubTable(sc.orgData.Count - this.ReviewExpectCnt, this.ReviewExpectCnt);
            List <string> strCodes = new List <string>();

            for (int i = 0; i < 10; i++)//遍历每个车号/名次
            {
                List <int> coldata = null;
                string     strCol  = string.Format("{0}", (i + 1) % 10);
                dt.getColumnData(strCol, ref coldata);
                //Log(string.Format("车/次:{0}",strCol), string.Format("取得的数据:{0}",string.Join(",",coldata)));
                int RepeatCnt = 0;
                for (int j = 1; j < ReviewExpectCnt; j++)
                {
                    if (coldata[j] == coldata[j - 1])
                    {
                        RepeatCnt++;
                    }
                }
                if (RepeatCnt < this.ReviewExpectCnt - 1)//如果重复次数小于回顾次数减一,表示重复次数不够,跳过
                {
                    continue;
                }
                string strCode = "";//其实无需比较,对单个车/名次来说,矩阵都一样,策略只需建立一个即可
                strCode = string.Format("{0}/{1}", strCol, coldata[0]);

                //Log(string.Format("车/次:{0}", strCol), strCode);
                strCodes.Add(strCode);

                if (HoldCnt >= 0) //当持有次数超过指定次数后,不再增加
                {
                    HoldCnt++;    //持有次数加1
                }
                //Log("获得机会处理", string.Format("当前持有次数:{0}", HoldCnt));
                RealCnt++;
            }

            if (strCodes.Count == 0)//机会数为0
            {
                return(ret);
            }
            if (!GetRev)
            {
                OnceChance cc = new OnceChance();
                cc.SignExpectNo        = ed.Expect;
                cc.ChanceType          = 1;
                cc.ChanceCode          = string.Join("+", strCodes);
                cc.ChipCount           = strCodes.Count;//码数必须是实际码数,使用的金额队列必须是1码的队列
                cc.InputTimes          = RealCnt;
                cc.strInputTimes       = string.Format("{0}", cc.InputTimes);
                cc.AllowMaxHoldTimeCnt = 1;
                cc.InputExpect         = ed;
                cc.NeedConditionEnd    = true;
                cc.StragId             = this.GUID;
                //cc.MinWinRate = this.CommSetting.GetGlobalSetting().DefaultHoldAmtSerials.MaxRates[cc.ChipCount - 1];
                cc.IsTracer    = 0;
                cc.Odds        = this.CommSetting.GetGlobalSetting().Odds;
                CurrChancesCnt = strCodes.Count;
                //cc.UnitCost = this.getChipAmount(0,cc,);
                ret.Add(cc);
                //获得所有机会后,统一为本次机会分配资金
                return(ret);
            }
            else
            {
                for (int i = 0; i < strCodes.Count; i++)
                {
                    NolimitTraceChance cc = new NolimitTraceChance();
                    cc.SignExpectNo        = ed.Expect;
                    cc.ChanceType          = 1;
                    cc.ChanceCode          = ChanceClass.getRevChance(strCodes[i]);
                    cc.ChipCount           = 9;//码数必须是实际码数,使用的金额队列必须是1码的队列
                    cc.InputTimes          = RealCnt;
                    cc.strInputTimes       = string.Format("{0}", cc.InputTimes);
                    cc.AllowMaxHoldTimeCnt = 1;
                    cc.InputExpect         = ed;
                    cc.StragId             = this.GUID;
                    //cc.MinWinRate = this.CommSetting.GetGlobalSetting().DefaultHoldAmtSerials.MaxRates[cc.ChipCount - 1];
                    cc.IsTracer    = 1;
                    cc.Odds        = this.CommSetting.GetGlobalSetting().Odds;
                    CurrChancesCnt = strCodes.Count;
                    //cc.UnitCost = this.getChipAmount(0,cc,);
                    ret.Add(cc);
                }
                return(ret);
            }
        }
Ejemplo n.º 3
0
        public override List <ChanceClass> getChances(BaseCollection sc, ExpectData ed)
        {
            List <ChanceClass> ret = new List <ChanceClass>();
            DataTableEx        dt  = null;

            if (this.BySer)
            {
                dt = sc.SerialDistributionTable;
            }
            else
            {
                dt = sc.CarDistributionTable;
            }
            if (dt == null)
            {
                throw new Exception("无法获得概率分布表!");
            }
            int    MatchCnt    = 0;
            string strAllCodes = "";
            double MinSucRate  = 0;

            if (this.FixChipCnt)
            {
                MinSucRate = this.CommSetting.Odds / this.ChipCount; //指定注数需要的最小胜率
            }
            for (int i = 0; i < 10; i++)
            {
                //获得各项的最小的
                List <double> coldata = null;
                string        strCol  = string.Format("{0}", (i + 1) % 10);

                string strVal   = ed.ValueList[i];
                int    ExistCnt = sc.FindLastDataExistCount(this.InputMinTimes, strCol, strVal);
                if (ExistCnt > 1)//前n次不是最后一次才出现
                {
                    continue;
                }
                dt.getColumnData(strCol, ref coldata);
                double    avgval  = coldata.Average();
                double    stdval  = ProbMath.CalculateStdDev(coldata);
                string    strSql  = string.Format("[{0}]={1}", "Id", strVal);
                string    strSort = string.Format("[{0}] asc", "Id");
                DataRow[] drs     = dt.Select(strSql, "");
                if (drs.Length != 1)
                {
                    throw new Exception("概率数据表错乱!");
                }
                int InAllViewExistCnt = int.Parse(drs[0][strCol].ToString()); //前100(指定的viewcnt)期出现的次数
                if (InAllViewExistCnt > avgval - stdval * this.StdvCnt)       //如果前100期内出现的概率大于指定的标准差数,跳过
                {
                    continue;
                }
                if (InAllViewExistCnt > this.ReviewExpectCnt * (1 - MinSucRate))//如果成功数小于对应注数的失败数
                {
                    continue;
                }
                string strCode = string.Format("{0}/{1}", BySer ? strCol : strVal, BySer ? strVal : strCol);

                MatchCnt++;
                strAllCodes = string.Format("{0}{1}{2}", strAllCodes, MatchCnt > 1 ? "+" : "", strCode);
            }
            if (MatchCnt < this.ChipCount)
            {
                return(ret);
            }
            ChanceClass cc = new ChanceClass();

            cc.SignExpectNo        = ed.Expect;
            cc.ChanceType          = 3;
            cc.InputTimes          = 1;
            cc.strInputTimes       = "1";
            cc.AllowMaxHoldTimeCnt = 1;
            cc.InputExpect         = ed;
            cc.ChipCount           = MatchCnt;
            cc.ChanceCode          = strAllCodes;
            cc.CreateTime          = ed.OpenTime;
            cc.NeedConditionEnd    = true;
            cc.OnCheckTheChance   += CheckNeedEndTheChance;
            cc.Closed = false;
            ret.Add(cc);
            return(ret);
        }