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); } }
public override List <ChanceClass> getChances(BaseCollection sc, ExpectData ed) { List <ChanceClass> ret = new List <ChanceClass>(); Dictionary <string, string> MatchCols = new Dictionary <string, string>(); Dictionary <string, int> MatchCnt = new Dictionary <string, int>(); int MutliMinCnt = this.CommSetting.GetGlobalSetting().SingleColMinTimes; int TwoMinCnt = (this.CommSetting.GetGlobalSetting().MinTimeForChance(1) + this.CommSetting.GetGlobalSetting().MinTimeForChance(2)) / 2; string colmodel = "{0}_{1}";//列_长度 for (int i = 0; i < 10; i++) { int ishift = MutliMinCnt; if (!sc.Data[i].ContainsKey(ishift) || sc.Data[i][ishift].Trim().Length == 0) //不及最小值,跳过 { continue; } string strCol = string.Format(colmodel, i, sc.Data[i][ishift].Length); if (!MatchCols.ContainsKey(strCol)) { MatchCols.Add(strCol, sc.Data[i][ishift]); MatchCnt.Add(strCol, ishift + 1);//实际数量 } ishift++; while (sc.Data[i].ContainsKey(ishift) && sc.Data[i][ishift].Trim().Length > 0) //一直往上找 { string lastVal = sc.Data[i][ishift]; //可能不止一个数字 strCol = string.Format(colmodel, i, lastVal.Length); if (!MatchCols.ContainsKey(strCol)) { MatchCols.Add(strCol, lastVal); MatchCnt.Add(strCol, ishift + 1);//实际数量 } else { MatchCnt[strCol] = MatchCnt[strCol] + 1; } ishift++; } //ishift--; } //替换列中数据长度大于1的数据,只留最短的 for (int i = 0; i < 10; i++) { string keymodel = "{0}_{1}"; string key = string.Format(keymodel, i, 1); if (!MatchCols.ContainsKey(key))//如果1个都不存在,跳过 { continue; } string strVal = MatchCols[key]; int k = 2; key = string.Format(keymodel, i, k); while (MatchCols.ContainsKey(key))//逐级替换 { string tmp = MatchCols[key]; MatchCols[key] = MatchCols[key].Replace(strVal, ""); strVal = tmp; k++; key = string.Format(keymodel, i, k); } } if (MatchCols.Count > 1) { Log("50以上的组合", string.Join("+", MatchCols.Select(p => string.Format("{0}/{1}:{2}", p.Key, p.Value, MatchCnt[p.Key])).ToArray())); } if (MatchCols.Count < 2) { return(ret); } List <string> strCodes = new List <string>(); List <string> strCodes2 = new List <string>(); List <int> intCnt2 = new List <int>(); foreach (string key in MatchCnt.Keys) { string[] keys = key.Split('_'); string strCode = string.Format("{0}/{1}", (int.Parse(keys[0]) + 1) % 10, MatchCols[key]); if (MatchCnt[key] > TwoMinCnt)//如果2个数小于58 { strCodes2.Add(strCode); intCnt2.Add(MatchCnt[key]); } strCodes.Add(strCode); } if (strCodes.Count == 2) { if (strCodes2.Count < 2) { return(ret); } } List <string> strCommCodes = new List <string>(); List <string> strCommCnts = new List <string>(); if (strCodes2.Count >= 2) //合成2个的组合 { Log("50以上机会:", string.Join("+", strCodes2.ToArray())); for (int i = 0; i < strCodes2.Count; i++) { for (int j = i + 1; j < strCodes2.Count; j++) { strCommCodes.Add(string.Format("{0}+{1}", strCodes2[i], strCodes2[j])); strCommCnts.Add(string.Format("{0}_{1}", intCnt2[i], intCnt2[j])); } } } for (int i = 0; i < strCommCodes.Count; i++) { NolimitTraceChance cc = new NolimitTraceChance(); cc.SignExpectNo = ed.Expect; cc.ChanceType = 0; cc.ChipCount = 2; cc.InputTimes = MatchCnt.Values.Min <int>(); cc.strInputTimes = strCommCnts[i]; //cc.AllowMaxHoldTimeCnt = this.AllowMaxHoldTimeCnt; cc.InputExpect = ed; cc.StragId = this.GUID; cc.MinWinRate = this.CommSetting.GetGlobalSetting().DefaultHoldAmtSerials.MaxRates[cc.ChipCount - 1]; cc.IsTracer = 1; cc.HoldTimeCnt = 1; cc.Odds = this.CommSetting.GetGlobalSetting().Odds; cc.ExpectCode = ed.Expect; cc.ChanceCode = strCommCodes[i]; cc.CreateTime = DateTime.Now; cc.UpdateTime = DateTime.Now; cc.Closed = false; ret.Add(cc); } if (strCodes.Count > 2) { string strAllCodes = string.Join("+", strCodes.ToArray()); NolimitTraceChance cc = new NolimitTraceChance(); cc.SignExpectNo = ed.Expect; cc.ChanceType = 0; cc.ChipCount = strCodes.Count; cc.InputTimes = MatchCnt.Values.Min <int>(); cc.strInputTimes = string.Join("_", MatchCnt.Values.ToArray <int>()); //cc.AllowMaxHoldTimeCnt = this.AllowMaxHoldTimeCnt; cc.InputExpect = ed; cc.StragId = this.GUID; cc.MinWinRate = this.CommSetting.GetGlobalSetting().DefaultHoldAmtSerials.MaxRates[cc.ChipCount - 1]; cc.IsTracer = 1; cc.HoldTimeCnt = 1; cc.Odds = this.CommSetting.GetGlobalSetting().Odds; cc.ExpectCode = ed.Expect; cc.ChanceCode = strAllCodes; cc.CreateTime = DateTime.Now; cc.UpdateTime = DateTime.Now; cc.Closed = false; ret.Add(cc); } return(ret); }
public override List <ChanceClass> getChances(BaseCollection sc, ExpectData ed) { List <ChanceClass> ret = new List <ChanceClass>(); //ExpectListProcess elp = new ExpectListProcess(Data); //CommCollection sc = elp.getSerialData(ReviewExpectCnt,BySer); Dictionary <string, int> MatchTimes = new Dictionary <string, int>(); Dictionary <string, string> MatchChances = new Dictionary <string, string>(); Dictionary <string, string> CombDic = new Dictionary <string, string>(); Dictionary <int, int> MaxCnts = new Dictionary <int, int>(); Dictionary <int, int> NoCnts = new Dictionary <int, int>(); int MinLimit = this.CommSetting.minColTimes[this.ChipCount + 3 - 1]; #region 获取所有满足基本条件的组合 for (int i = 0; i < 10; i++) { Dictionary <int, string> SerStrs = sc.Data[i]; int ishift = MinLimit - 1; //多三级 if (SerStrs[ishift].Length < this.ChipCount) //不满足基本条件 { continue; } MaxCnts.Add(i, this.ReviewExpectCnt);//默认长度都是reviewcnt,如果大于指定长度的机会持续次数大于review,所有子机会都会加一 NoCnts.Add(i, SerStrs[ishift].Length); string strColKeymModel = "{0}_{1}"; while (ishift < this.ReviewExpectCnt)//从前三级开始爬 { ishift++; if (SerStrs.ContainsKey(ishift) && SerStrs.ContainsKey(ishift - 1)) { string strCode = ""; int INo = -1; if (BySer) { INo = (i) % 10; strCode = SerStrs[ishift - 1].Trim();//1,2,3,4,5,6,7,8,9,0 } else { INo = i; strCode = SerStrs[ishift - 1].Trim(); //0,1,2,3,4,5,6,7,8,9 } if (SerStrs[ishift].Trim().Length >= this.ChipCount) //往上看 { bool Matched = false; if (SerStrs[ishift].Trim().Length < SerStrs[ishift - 1].Trim().Length)//收缩,当前行小于上一行 { Matched = true; } else { if (ishift >= this.ReviewExpectCnt - 1)//结束了还未收缩,则加入 { Matched = true; } } if (Matched) { List <string> AllStrCode = new List <string>(); if (strCode.Trim().Length == this.ChipCount) { AllStrCode.Add(strCode); } else { AllStrCode = ChanceClass.getAllSubCode(strCode, this.ChipCount); } for (int j = 0; j < AllStrCode.Count; j++) { string strColKey = string.Format(strColKeymModel, INo, AllStrCode[j]); if (!MatchChances.ContainsKey(strColKey)) { MatchChances.Add(strColKey, AllStrCode[j]); MatchTimes.Add(strColKey, ishift + 1 - 1); } else { MatchTimes[strColKey] = ishift + 1 - 1; } } } } else//爬到看到的数量小于长度时,很可能会匹配不到,因为到最后一条数据显示长度仍然大于等于长度,所以,review需要足够长,最好大于高一码的最大长度 { string strColKey = string.Format(strColKeymModel, INo, strCode); if (!MatchChances.ContainsKey(strColKey)) { MatchChances.Add(strColKey, strCode); MatchTimes.Add(strColKey, ishift + 1 - 1); } else { MatchTimes[strColKey] = ishift + 1 - 1; } MaxCnts[i] = ishift; //每列符合条件的最大值,作为判断是否是本车/本排名的最大列用 break; // } } } } #endregion string ComKeyModel = "{0}+{1}";//小大排列 if (MatchChances.Count <= 1) { return(ret); //只有一个组合 } foreach (string _key in MatchChances.Keys) { string[] keyArr = _key.Split('_'); int key = int.Parse(keyArr[0]); //int cnt = int.Parse(keyArr[1]); foreach (string _key1 in MatchChances.Keys) { string[] keyArr1 = _key1.Split('_'); int key1 = int.Parse(keyArr1[0]); //int cnt1 = int.Parse(keyArr1[1]); if (key == key1) { continue; } string sKey, bKey; if (key < key1) { sKey = _key; bKey = _key1; } else { sKey = _key1; bKey = _key; } string CombKey = string.Format(ComKeyModel, sKey, bKey); if (CombDic.ContainsKey(CombKey)) { continue;//防止实质相同但是顺序相反组合重复进入 } int Time1, Time2, SameNoCnt; Time1 = MatchTimes[_key]; Time2 = MatchTimes[_key1]; if (!BySer)//如果是按车视图 { Time1 -= 2; Time2 -= 2; } SameNoCnt = ChanceClass.getSameNoCnt(MatchChances[_key], MatchChances[_key1]); //获得相同号码的数量 //判断两个是不是本车/本排名中最大长度的机会 int AddSameNocnt = -2; //只有两个都是最长才不减,否则每个减1 if (MaxCnts[key] > Time1) { Time1 -= 2; } if (MaxCnts[key1] > Time2) { Time2 -= 2; } if (MaxCnts[key] < this.CommSetting.minColTimes[this.ChipCount]) { Time1 -= 2; } if (MaxCnts[key1] < this.CommSetting.minColTimes[this.ChipCount]) { Time2 -= 2; } //SameNoCnt += AddSameNocnt; bool Matched = false; //Level1 int LevelU2 = this.CommSetting.minColTimes[this.ChipCount + 2 - 1]; //上两级 int LevelU1 = this.CommSetting.minColTimes[this.ChipCount + 1 - 1]; //上一级 int LevelU0 = this.CommSetting.minColTimes[this.ChipCount - 1]; //本级 List <string> strCodes = getAllCodes(MatchChances[_key], MatchChances[_key1], this.BySer); //////if (BySer) ////// strCode = string.Format("{0}/{1}", (i + 1) % 10, SerStrs[ishift].Trim()); //////else ////// strCode = string.Format("{0}/{1}", SerStrs[ishift].Trim(), i); string strCode = this.BySer ? string.Format("{0}/{1}+{2}/{3}", (key + 1) % 10, MatchChances[_key], (key1 + 1) % 10, MatchChances[_key1]) : string.Format("{0}/{1}+{2}/{3}", MatchChances[_key], key, MatchChances[_key1], key1); if (SameNoCnt >= 3)//所有相同个数等于 { if (Time1 >= MinLimit && Time2 >= MinLimit && this.ChipCount == SameNoCnt) { Matched = true; } //////else //////{ if ((Time1 + Time2) >= (LevelU1 + LevelU2) && Time1 >= LevelU2 && Time2 > LevelU2) { Matched = true; } //////} } if (SameNoCnt >= 2) { if (Time1 * 2 >= (LevelU2 + LevelU1) && Time2 * 2 >= (LevelU2 + LevelU1) && (Time1 + Time2) >= 2 * LevelU1) { Matched = true; } } if (SameNoCnt >= 1) { if (Time1 >= LevelU1 && Time2 >= LevelU1 && (Time1 + Time2) >= (LevelU1 + LevelU0)) { Matched = true; } } if (SameNoCnt >= -2) { if (Time1 * 2 >= (LevelU0 + LevelU1) && Time2 * 2 >= (LevelU1 + LevelU0)) { Matched = true; } } if (!Matched) { continue; } CombDic.Add(CombKey, strCode); NolimitTraceChance cc = new NolimitTraceChance(); cc.ChipCount = this.ChipCount * 2; //cc.AllowMaxHoldTimeCnt = this.AllowMaxHoldTimeCnt; cc.SignExpectNo = ed.Expect; cc.ChanceType = 0; cc.InputTimes = Math.Min(Time1, Time2); cc.strInputTimes = string.Format("{0}_{1}", Time1, Time2); cc.InputExpect = ed; cc.ChanceCode = strCode; cc.IsTracer = 1; 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>(); //ExpectListProcess elp = new ExpectListProcess(Data); //CommCollection sc = elp.getSerialData(ReviewExpectCnt,BySer); // Log("策略关键参数",string.Format("name:{4};ViewCnt:{0};MinInput:{1};DataCnt:{2};Chipcnt:{3}",this.ReviewExpectCnt,this.InputMinTimes,sc.Data[0].Count,this.ChipCount,this.StragScript)); for (int i = 0; i < 10; i++) { Dictionary <int, string> SerStrs = sc.Data[i]; if (!SerStrs.ContainsKey(this.InputMinTimes - 1)) { continue; } if (SerStrs[this.InputMinTimes - 1].Length < this.ChipCount) { continue; } int ishift = this.InputMinTimes - 1; //Log("起始位置", ishift.ToString()); List <string> strCcs = ChanceClass.getAllSubCode(SerStrs[ishift].Trim(), this.ChipCount); for (int j = 0; j < strCcs.Count; j++) { string strCars = strCcs[j]; if (this.ExcludeBS && ChanceClass.isBS(strCars)) { continue; } if (this.ExcludeSD && ChanceClass.isSD(strCars)) { continue; } if (this.OnlyBS && !ChanceClass.isBS(strCars)) { continue; } if (this.OnlySD && !ChanceClass.isSD(strCars)) { continue; } NolimitTraceChance cc = new NolimitTraceChance(); cc.SignExpectNo = ed.Expect; cc.ChanceType = 0; cc.ChipCount = strCars.Length; cc.InputTimes = ishift + 1; cc.strInputTimes = cc.InputTimes.ToString(); //cc.AllowMaxHoldTimeCnt = this.AllowMaxHoldTimeCnt; cc.InputExpect = ed; cc.StragId = this.GUID; cc.MinWinRate = this.CommSetting.GetGlobalSetting().DefaultHoldAmtSerials.MaxRates[cc.ChipCount - 1]; cc.IsTracer = 1; cc.HoldTimeCnt = 1; cc.Odds = this.CommSetting.GetGlobalSetting().Odds; cc.ExpectCode = ed.Expect; string strCode = ""; if (BySer) { strCode = string.Format("{0}/{1}", (i + 1) % 10, strCcs[j].Trim()); } else { strCode = string.Format("{0}/{1}", strCcs[j].Trim(), i); } cc.ChanceCode = strCode; cc.CreateTime = DateTime.Now; cc.UpdateTime = DateTime.Now; cc.Closed = false; ret.Add(cc); } //} //} } return(ret); }