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); }
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); }