public override long getChipAmount(double RestCash, ChanceClass cc, AmoutSerials amts)
 {
     try
     {
         if (cc.HoldTimeCnt > cc.MaxHoldTimeCnt && cc.MaxHoldTimeCnt > 0)//但是只有第一次有投入
         {
             return(0);
         }
         if (cc.IncrementType == InterestType.CompoundInterest)
         {
             double rate = KellyMethodClass.KellyFormula(cc.ChipCount, 10, 9.75, 1.001);
             //double rate = KellyMethodClass.KellyFormula(cc.ChipCount, 9.75, 0.3396);
             long ret = (long)Math.Floor((double)(RestCash * rate) / cc.ChipCount);
             return(ret);
         }
         int chips  = cc.ChipCount - 1;
         int maxcnt = amts.MaxHoldCnts[chips];
         int bShift = 0;
         if (cc.HoldTimeCnt > maxcnt)
         {
             Log("风险", "达到最大上限", string.Format("机会{0}持有次数达到{1}次总投入金额已为{2}", cc.ChanceCode, cc.HoldTimeCnt, cc.Cost));
             bShift = (int)maxcnt * 2 / 3;
         }
         int RCnt = (cc.HoldTimeCnt % (maxcnt + 1)) + bShift - 1;
         return(amts.Serials[chips][RCnt]);
     }
     catch
     {
     }
     return(0);
 }
 public override long getChipAmount(double RestCash, ChanceClass cc, AmoutSerials amts)
 {
     try
     {
         if (cc.IncrementType == InterestType.CompoundInterest)
         {
             if (cc.MaxHoldTimeCnt > 0 && cc.HoldTimeCnt > cc.MaxHoldTimeCnt)
             {
                 return(0);
             }
             //
             double rate = KellyMethodClass.KellyFormula(1, 10, 9.75, 1.001);
             //double rate = KellyMethodClass.KellyFormula(1, 9.75, 0.1032);
             long ret = (long)Math.Ceiling((double)(RestCash * rate));
             return(ret);
         }
         if (cc.ChipCount <= 3 && cc.HoldTimeCnt > cc.MaxHoldTimeCnt && cc.MaxHoldTimeCnt > 0)
         {
             return(0);
         }
         if (cc.HoldTimeCnt <= cc.MaxHoldTimeCnt && cc.MaxHoldTimeCnt > 0) //如果小于等于1
         {
             return(cc.FixAmt.Value);
         }
         int chips  = cc.ChipCount - 1;
         int maxcnt = amts.MaxHoldCnts[chips];
         int bShift = 0;
         if (cc.HoldTimeCnt > maxcnt)
         {
             Log("风险", "达到最大上限", string.Format("机会{0}持有次数达到{1}次总投入金额已为{2}", cc.ChanceCode, cc.HoldTimeCnt, cc.Cost));
             bShift = (int)maxcnt * 2 / 3;
         }
         int RCnt = (cc.HoldTimeCnt % (maxcnt + 1)) + bShift - 1;
         return(amts.Serials[chips][RCnt]);
     }
     catch (Exception e)
     {
         Log("错误", "获取单码金额错误", e.Message);
     }
     return(1);
 }
        public override long getChipAmount <T>(double RestCash, ChanceClass <T> cc, AmoutSerials amts)
        {
            try
            {
                //////if (amts.Serials[cc.ChipCount - 1].Length == 0)
                //////{
                //////    Log("获取单码金额", "队列长度为0");
                //////}
                //////else
                //////{
                //////    Log(string.Format("获取到{0}码金额:{1}",cc.ChipCount,cc.HoldTimeCnt),string.Join(",",amts.Serials[cc.ChipCount-1]));
                //////}


                if (cc.IncrementType == InterestType.CompoundInterest)
                {
                    double rate = KellyMethodClass.KellyFormula(cc.ChipCount, 10, 9.75, 1.01);
                    long   ret  = (long)Math.Floor((double)(RestCash * rate));
                    return(ret);
                }
                if (cc.AllowMaxHoldTimeCnt > 0 && cc.HoldTimeCnt > cc.AllowMaxHoldTimeCnt)
                {
                    return(0);
                }
                int chips  = cc.ChipCount - 1;
                int maxcnt = amts.MaxHoldCnts[chips];
                int bShift = 0;
                if (cc.HoldTimeCnt > maxcnt)
                {
                    Log("风险", "达到最大上限", string.Format("机会{0}持有次数达到{1}次总投入金额已为{2}", cc.ChanceCode, cc.HoldTimeCnt, Cost));
                    bShift = (int)maxcnt * 2 / 3;
                }
                int RCnt = (cc.HoldTimeCnt % (maxcnt + 1)) + bShift - 1;
                return(amts.Serials[chips][RCnt]);
            }
            catch (Exception e)
            {
                Log("错误", string.Format("TraceChance,获取单码金额错误:{0}", e.Message), e.StackTrace);
            }
            return(1);
        }
        public override long getChipAmount(double RestCash, ChanceClass cc, AmoutSerials amts)
        {
            cc.AllowMaxHoldTimeCnt = 1;
            try
            {
                if (LastUseData().LastData.Expect != cc.ExpectCode)
                {
                    return(0);
                }
                if (cc.IncrementType == InterestType.CompoundInterest)
                {
                    if (cc.HoldTimeCnt > 1)
                    {
                        return(0);
                    }
                    if (cc.AllowMaxHoldTimeCnt > 0 && cc.HoldTimeCnt > cc.AllowMaxHoldTimeCnt)
                    {
                        return(0);
                    }
                    if (LastUseData().LastData.Expect != cc.ExpectCode)
                    {
                        return(0);
                    }
                    //
                    double rate = KellyMethodClass.KellyFormula(1, 10, 9.75, 1.001);
                    //double rate = KellyMethodClass.KellyFormula(1, 9.75, 0.1032);
                    long ret = (long)Math.Ceiling((double)(RestCash * rate));
                    return(ret);
                }
                //大于5码的不受限制
                int shift = 0;

                if (cc.ChipCount < this.InputMinTimes && cc.HoldTimeCnt > cc.AllowMaxHoldTimeCnt && cc.AllowMaxHoldTimeCnt > 0)
                {
                    int CurrChipCount = ChanceClass.getChipsByCode(cc.ChanceCode);
                    if (CurrChipCount >= 2)//大于等于3的,超过了一定期数以后可以跟号。4码5次,3码7次,2码11次。6-n+(6-n+1)^2
                    {
                        shift = (this.InputMinTimes + 1 - CurrChipCount) + (int)(Math.Pow((this.InputMinTimes + 1 - CurrChipCount + 1), 2));
                        //shift = (6 - CurrChipCount) + (6 - CurrChipCount + 1) ^ 2;
                    }
                    else
                    {
                        shift = 50;
                    }
                    //                [组合信息:1/0+6/7;组合长度:2;指定最小长度:6:Log]当前次数:10;最小入场次数:9
                    Log(string.Format("组合信息:{0};组合长度:{1};指定最小长度:{2}", cc.ChanceCode, CurrChipCount, this.InputMinTimes), string.Format("当前次数:{0};最小入场次数:{1}", cc.HoldTimeCnt, shift));
                    if (cc.HoldTimeCnt < shift)
                    {
                        return(0);
                    }
                }
                if (cc.HoldTimeCnt <= cc.AllowMaxHoldTimeCnt && cc.AllowMaxHoldTimeCnt > 0) //如果小于等于1
                {
                    return(cc.FixAmt.Value);
                }
                int hcnt = cc.HoldTimeCnt - shift;
                if (hcnt < 0)
                {
                    return(0);
                }
                int chips  = cc.ChipCount - 1;
                int maxcnt = amts.MaxHoldCnts[chips];
                int bShift = 0;
                if (hcnt > maxcnt)
                {
                    Log("风险", "达到最大上限", string.Format("机会{0}持有次数达到{1}次总投入金额已为{2}", cc.ChanceCode, hcnt, cc.Cost));
                    bShift = (int)maxcnt * 2 / 3;
                }
                int RCnt = (hcnt % (maxcnt + 1)) + bShift - 1;
                return(amts.Serials[chips][RCnt]);
            }
            catch (Exception e)
            {
                Log("错误", string.Format("二项分布,获取单码金额错误:{0}", e.Message), e.StackTrace);
            }
            return(1);
        }