阅读背景:

星力九代 命中算法 特殊用户处理 点控调整

来源:互联网 

 

难度命中算法制excel表格

 

 

 

 

package com.miracle9.game.algorithm;
import com.miracle9.game.algorithm.FishServerSuanfa.FISH_TYPE;

import java.util.Objects;
import java.util.Random;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;

public class DieFishSuanfa {
    public Logger log = Logger.getLogger(DieFishSuanfa.class);
    private static float afloat14 = 1.4F;
    private static int _int10 = 10;
    private static int _int4 = 4;
    private static int int10w = 1000000;
    private static float _float05f = 0.5F;
    private static double IIllIIlIIlIlIlIl;
    private static float[] levelPoint = new float[]{0.999F, 0.998F, 0.997F, 0.996F, 0.995F};
    private STRUCT_GET_GF_RECORD struct_record = new STRUCT_GET_GF_RECORD();
    private long _totalPlay;
    private long _totalWin;
    private boolean _fangWater;
    private double _amendedGameDf;
    double gameDf = 0.7 ;
    Random mRand = new Random();

    public DieFishSuanfa() {
        this.Init();
    }

    public void Init() {

        //DOMConfigurator.configureAndWatch("config/log4j.xml", 10000L);
        String logenable = LoadPropertiesUtil.getKey("../setting.properties", "logenable");
        if (logenable.equals("INFO"))
            log.setLevel(Level.INFO);
        else if(logenable.equals("DEBUG"))
            log.setLevel(Level.DEBUG);
        else
            log.setLevel(Level.OFF);

        this.struct_record.totalRecord = 0L;
        for(int i = 0; i < _int4; ++i) {
            this.struct_record.record[i] = 0L;
            this.struct_record.tmpGf[i] = 1.0D;
        }
        this._fangWater = false;
        this._totalPlay = 0L;
        this._totalWin = 0L;
    }
    public double GetGameDf(int level) {
        if (level > 5 || level <= 0) { level = 3; }

        double[] var2 = new double[]{(double)0.99F, (double)0.95F, (double)0.9F, (double)0.8F, (double)0.75F};
        return var2[level - 1];
		//return (double)levelPoint[level - 1];  // Q10 备用
    }

    public DieFishOutputInfo Fishing(DieFishInputInfo input) {
        DieFishOutputInfo output = new DieFishOutputInfo();
        int nFishCounts = input.totalFish;
        //System.out.println( "\n nFishCounts: "+ nFishCounts );

        int fishesCanGetIonic = 0;
        int ionicFlag = 0;
        int i;
        for(i = 0; i < nFishCounts; ++i) {
            output.dead[i].fishType = -1;
            output.dead[i].bet = 0;
            output.dead[i].fishid = input.fishes[i].fishid;
            output.dead[i].fx = input.fishes[i].fx;
            output.dead[i].fy = input.fishes[i].fy;
        }
        output.ionicCannonIndex = -1;

        gameDf = this.GetGameDf(input.gameDfLevel);
        //System.out.print("A3 "+input.hallType+" B3 "+input.gameDfLevel +" totalFish "+nFishCounts+" gameDf "+ gameDf);

        this._Preprocess(input); //处理额外奖励倍数
        this._amendedGameDf = this._AmendGameDf(input);

        log.debug("当前 _AmendGameDf: "+ this._amendedGameDf ); // 0.9681936677049267

        output.totalFish = input.totalFish;

        for(i = 0; i < nFishCounts; ++i) {
            output.dead[i].fishType = input.fishes[i].fishType;
        }

        label48: {
            if (input.locked) {
                this._CalculateLockedFish(input, output);
                if (output.dead[0].bet <= 0) {
                    break label48;
                }
            }
            this._CalcultateUnlockedFishes(input, output);
        }
        //倍数大于9 有1/30机会获得能量炮
        for(i = 0; i < nFishCounts; ++i) {
            if (output.dead[i].bet > 9) {
                ++fishesCanGetIonic;
                ionicFlag = output.dead[i].fishid;
                break;
            }
        }
        if (fishesCanGetIonic > 0) {
            if (Math.random() < (double)fishesCanGetIonic / 30.0D) {
                output.ionicCannonIndex = ionicFlag;
            } else {
                output.ionicCannonIndex = -1;
            }
        }

        output.totalFish = 0;

        for(i = 0; i < nFishCounts; ++i) {
            //System.out.println(i+" bet: "+ output.dead[i].bet );
            //System.out.println(i+" output.totalFish: "+ output.totalFish );
            if (output.dead[i].bet > 0) {
                output.dead[output.totalFish] = output.dead[i];
                ++output.totalFish;
            }
        }
        //System.out.println(" output.totalFish: "+ output.totalFish );
        return output;
    }

    //修正游戏难度
    public double ModifyGameDf(long totalPlay, double gameDf, int coinValue, int hallType) {
		double dbGameDf;
        long profitStartCredit = 0L;
        double tmp = 0.0D;
        switch(hallType) {
            case 1:
                profitStartCredit = (long)(coinValue * 500000);
                break;
            case 2:
                profitStartCredit = (long)(coinValue * 1000000);
                break;
            case 3:
                profitStartCredit = (long)(coinValue * 2000000);
				break;
        }

        long profitConvergenceZone = (long)((double)(profitStartCredit * 5L) * (1.0D - gameDf) - (double)profitStartCredit * 0.001D);
        if (totalPlay < profitStartCredit) {
            dbGameDf = 0.999D;
        } else if (totalPlay < profitStartCredit << 1) {
            dbGameDf = 0.999D - (-0.0010000000000000009D + ((double)profitConvergenceZone * 0.25D + (double)profitStartCredit * 0.001D) / (double)(profitStartCredit << 1)) * (double)(totalPlay - profitStartCredit) / (double)profitStartCredit;
        } else if (totalPlay < profitStartCredit * 3L) {
            dbGameDf = (tmp = 1.0D - ((double)profitConvergenceZone * 0.25D + (double)profitStartCredit * 0.001D) / (double)(profitStartCredit << 1)) - (tmp - 1.0D + ((double)profitConvergenceZone * 0.5D + (double)profitStartCredit * 0.001D) / (double)(profitStartCredit * 3L)) * (double)(totalPlay - (profitStartCredit << 1)) / (double)profitStartCredit;
        } else if (totalPlay < profitStartCredit << 2) {
            dbGameDf = (tmp = 1.0D - ((double)profitConvergenceZone * 0.5D + (double)profitStartCredit * 0.001D) / (double)(profitStartCredit * 3L)) - (tmp - 1.0D + ((double)profitConvergenceZone * 0.75D + (double)profitStartCredit * 0.001D) / (double)(profitStartCredit << 2)) * (double)(totalPlay - profitStartCredit * 3L) / (double)profitStartCredit;
        } else if (totalPlay < profitStartCredit * 5L) {
            dbGameDf = (tmp = 1.0D - ((double)profitConvergenceZone * 0.75D + (double)profitStartCredit * 0.001D) / (double)(profitStartCredit << 2)) - (tmp - gameDf) * (double)(totalPlay - (profitStartCredit << 2)) / (double)profitStartCredit;
        } else {
            dbGameDf = gameDf;
        }
        System.out.print( "ModifyGameDf dbGameDf->"+dbGameDf );
        return (double)((float)dbGameDf);
    }

    /**
     *  处理奖励倍数
     *  */
    public void _Preprocess(DieFishInputInfo input) {
        int i,j;
        for(i = 0; i < input.totalFish; ++i) {

            if (FISH_TYPE.Fish_GreenDragon.ordinal() == input.fishes[i].fishType) {
                if (this.mRand.nextDouble() < 0.66D) {
                    input.fishes[i].bet = this.mRand.nextInt(41) + 40;
                } else {
                    input.fishes[i].bet = this.mRand.nextInt(61) + 40;
                }
            }
            else if (FISH_TYPE.Fish_SilverDragon.ordinal() == input.fishes[i].fishType) {
                if (this.mRand.nextDouble() < 0.8571D) {
                    input.fishes[i].bet = this.mRand.nextInt(201) + 100;
                } else {
                    input.fishes[i].bet = this.mRand.nextInt(101) + 100;
                }
            }
            //牛魔王
            else if (FISH_TYPE.Fish_GoldenDragon.ordinal() == input.fishes[i].fishType) {
                // double gameDf = this.GetGameDf(input.gameDfLevel);
                int betflag=1 , RandInt301 = this.mRand.nextInt(75);
                double RandFloat = this.mRand.nextDouble();
                double totalCoin = gameDf*input.totalPlay - input.totalWin;
                if (totalCoin > 30000L*input.coinValue){
                    //原版 1-0.8571D 可能600倍以上
                    if (this.mRand.nextDouble() < 0.8571D)
                        j = this.mRand.nextInt(301) + 300;
                    else
                        j = this.mRand.nextInt(401) + 600;
                }else{
                    if (totalCoin > 10000L*input.coinValue)   betflag = 4;
                    else if (totalCoin > 6000L*input.coinValue) betflag = 3;
                    else if (totalCoin > 3000L*input.coinValue)  betflag = 2;
                    else betflag = 1;

                    if (RandFloat < 0.12D) j = betflag*this.mRand.nextInt(101) + 300;
                    else if(RandFloat < 0.15D)  j = betflag*RandInt301 +130 + 300;
                    else if(RandFloat < 0.18D)  j = betflag*RandInt301 +110 + 300;
                    else if(RandFloat < 0.20D)  j = betflag*RandInt301 +100 + 300;
                    else if(RandFloat < 0.22D)  j = betflag*RandInt301 +60 + 300;
                    else if(RandFloat < 0.25D)  j = betflag*RandInt301 +30 + 300;
                    else j = betflag*this.mRand.nextInt(80) + 300;
                }
                input.fishes[i].bet = j;
            }
        }

        if (input.locked) {
            if (input.fishes[0].fishType == FISH_TYPE.Fish_Double_Kill.ordinal()) {
                for(i = 1; i < input.totalFish; ++i) {
                    input.fishes[i].bet = -1;
                }
            }

            if (FISH_TYPE.Fish_Same_Shrimp.ordinal() <= input.fishes[0].fishType && input.fishes[0].fishType <= FISH_TYPE.Fish_Same_Turtle.ordinal()) {
                for(i = 1; i < input.totalFish; ++i) {
                    if (input.fishes[i].fishType == input.fishes[0].fishType) {
                        input.fishes[i].bet = -1;
                    }
                }

            }
            else {
                for(i = 1; i < input.totalFish; ++i) {
                    if (input.fishes[i].fishType == FISH_TYPE.Fish_LimitedBomb.ordinal() || input.fishes[i].fishType == FISH_TYPE.Fish_Double_Kill.ordinal() || FISH_TYPE.Fish_Same_Shrimp.ordinal() <= input.fishes[i].fishType && input.fishes[i].fishType <= FISH_TYPE.Fish_Same_Turtle.ordinal()) {
                        input.fishes[i].bet = -1;
                    }
                }

            }
        }
        else {
            for(i = 0; i < input.totalFish; ++i) {
                if (input.fishes[i].fishType == FISH_TYPE.Fish_LimitedBomb.ordinal() && input.totalFish > 1 && input.fishes[i].bet != -1) {
                    if (this.mRand.nextBoolean()) {
                        for(j = 0; j < input.totalFish; ++j) {
                            if (i != j) {
                                input.fishes[j].bet = -1;
                            }
                        }
                    } else {
                        input.fishes[i].bet = -1;
                    }
                } else if (FISH_TYPE.Fish_Same_Shrimp.ordinal() <= input.fishes[i].fishType && input.fishes[i].fishType <= FISH_TYPE.Fish_Same_Turtle.ordinal() && input.fishes[i].bet != -1) {
                    for(j = 0; j < input.totalFish; ++j) {
                        if (i != j && input.fishes[j].fishType == input.fishes[i].fishType) {
                            input.fishes[j].bet = -1;
                        }
                    }
                } else if (input.fishes[i].fishType == FISH_TYPE.Fish_Double_Kill.ordinal() && input.fishes[i].bet != -1) {
                    for(j = 0; j < input.totalFish; ++j) {
                        if (i != j && (input.fishes[j].fishType == input.fishes[i].doubleKillType[0] || input.fishes[j].fishType == input.fishes[i].doubleKillType[1])) {
                            input.fishes[j].bet = -1;
                        }
                    }
                }
            }

        }
    }

    private static boolean IIIIlIlIIIIlIIlI(DieFishInputInfo input) {
        double credit = (double)input.fishes[0].bet * 0.19999999999999996D / 0.8D;
        double[] pkill = new double[_int10];
        double[] rateAmongFish = new double[_int10];
        double totalRate = 0.0D;
        boolean flag = false;
        if (input.fishes[0].fishType == FISH_TYPE.Fish_LimitedBomb.ordinal()) {
            flag = true;
        }
        if (input.fishes[0].fishType == FISH_TYPE.Fish_SilverDragon.ordinal()) {
            flag = true;
        }
        if (FISH_TYPE.Fish_BigEars_Group.ordinal() <= input.fishes[0].fishType && input.fishes[0].fishType <= FISH_TYPE.Fish_Turtle_Group.ordinal()) {
            flag = true;
        }
        if (input.fishes[0].fishType == FISH_TYPE.Fish_GoldenDragon.ordinal()) {
            flag = true;
        }
        int i;
        for(i = 1; i < _int10; ++i) {
            pkill[i] = 0.0D;
            rateAmongFish[i] = 0.0D;
        }

        for(i = 1; i < input.totalFish; ++i) {
            if (input.fishes[i].bet > 0) {
                totalRate += Math.pow((double)input.fishes[i].bet, 0.5D);
            }
        }

        if (totalRate < 0.1D) {
            flag = true;
        } else {
            for(i = 1; i < input.totalFish; ++i) {
                if (input.fishes[i].bet > 0) {
                    rateAmongFish[i] = Math.pow((double)input.fishes[i].bet, 0.5D) / totalRate;
                }
            }
        }

        for(i = 1; i < input.totalFish; ++i) {
            if (input.fishes[i].bet > 0) {
                pkill[i] = credit * rateAmongFish[i] / (double)input.fishes[i].bet;
            }
            if (pkill[i] > 1.0D) {
                flag = true;
            }
        }
        return flag;
    }

    public void _CalculateLockedFish(DieFishInputInfo input, DieFishOutputInfo output) {
        double a = this._AmendGameDf(input) * 0.8D;
        double prob;
        if (IIIIlIlIIIIlIIlI(input)) {
            prob = a / 0.8D / (double)input.fishes[0].bet;
        } else {
            prob = a / (double)input.fishes[0].bet;
        }
        System.out.print(prob);
        if (this.mRand.nextDouble() < prob) {
            output.dead[0].bet = input.fishes[0].bet;
        }

    }

    public void _CalcultateUnlockedFishes(DieFishInputInfo input, DieFishOutputInfo output) {
        double var3 = 0.0D;
        double[] pkill = new double[_int10];
        double[] rateAmongFish = new double[_int10];
        double totalRate = 0.0D;
        double amendedGameDf = this._amendedGameDf;
        int lockFlag = 0;
        if (input.locked) {
            lockFlag = 1;
            if (IIIIlIlIIIIlIIlI(input)) {
                lockFlag = input.totalFish;
            }
        }
        int i;
        for(i = 0; i < _int10; ++i) {
            pkill[i] = 0.0D;
            rateAmongFish[i] = 0.0D;
        }

        //region 击中的权重分配 不影响命中
        for(i = lockFlag; i < input.totalFish; ++i) {
            if (input.fishes[i].bet > 0) {
                    totalRate += Math.pow( (double)input.fishes[i].bet, (double) _float05f) ;//  18
            }
        }
        //如果击中多条 按权重分配每条鱼
        for(i = lockFlag; i < input.totalFish; ++i) {
            if (input.fishes[i].bet > 0) {
                    rateAmongFish[i] = Math.pow((double)input.fishes[i].bet, (double) _float05f) / totalRate;
            }
        }
        //endregion

        //按当前难度,确认命中 fix 如果special标记 提高4倍命中
        for(i = lockFlag; i < input.totalFish; ++i) {
            if (lockFlag == 0) {
                if (input.fishes[i].bet > 0) {
                        pkill[i] = amendedGameDf * rateAmongFish[i] / (double)input.fishes[i].bet;
                } else {
                    pkill[i] = -1.0D;
                }
            }
			else if (input.fishes[i].bet > 0) {
			    pkill[i] = (double)input.fishes[0].bet * 0.24999999999999994D * rateAmongFish[i] / (double)input.fishes[i].bet;
			}
			else {
                pkill[i] = -1.0D;
            }

            //System.out.print("\nfsDead "+input.fishes[i].fsDead);
            if (input.fishes[i].fsDead){
                pkill[i] = 2.0 * pkill[i];
                if (input.fishes[i].bet>299 )
                    pkill[i] = 10.0 * pkill[i];
                else if(input.fishes[i].bet>99 )
                    pkill[i] = 4.0 * pkill[i];
                else if(input.fishes[i].bet>39)
                    pkill[i] = 2.0 * pkill[i];
            }

            var3 = this.mRand.nextDouble() ;
            //System.out.print("rand "+var3+ " < pkill["+i+"] " + pkill[i] + " rateAmongFish[i] " +rateAmongFish[i]);
            if ( var3  < pkill[i]) {
                output.dead[i].bet = input.fishes[i].bet;
            } else {
                output.dead[i].bet = 0;
            }
        }

    }

    public double _AmendGameDf(DieFishInputInfo input) {
        //region 异常炮值修正
        if (input.coinValue <= 0 || input.coinValue > 10000) {
            input.coinValue = 500;
        }
        //场地类型
        if (input.hallType <= 0 || input.hallType > 3) {input.hallType = 2;}
        //endregion

        // 逻辑部分开始
        double l_feadback3 = 1.0D;
        double specialAmend = 1.0D;
        if (input.coinValue < 500) {
            specialAmend = Math.pow( (double)input.coinValue / 500.0D , 0.8D); //pow(底数,次方)
        }
        // [ 阶段盈利 = 动态(总押-总得) - 参照(总押-总得) ]
        double nowWin = (double)(input.totalPlay - input.totalWin - (this._totalPlay - this._totalWin));


        //当 重启后 或者 动态总押-参照总押 > 20W
        if (input.totalPlay - this._totalPlay > 200000L * (long)input.coinValue || this._totalPlay == 0L) {
            // 阶段盈利  > [ 3W / specialAmend ]
            if (this._totalPlay != 0L && nowWin > (double)(30000 * input.coinValue) / specialAmend) {
                this._fangWater = true;
            } else {
                this._fangWater = false;
                l_feadback3 = 1.0D;
            }
            this._totalPlay = input.totalPlay;
            this._totalWin = input.totalWin;
        }

        // 如果阶段盈利 且 币值>200 且 阶段盈利 + 1.5w > 0
        if (this._fangWater && input.coinValue > 200 && nowWin + 15000.0D * (double)input.coinValue > 0.0D) {
            // l_FeedBack3 = 1.0D + { 阶段盈利 + 1.5W } / 10W
            l_feadback3 = 1.0D + ( nowWin + 15000.0D * (double)input.coinValue) / (100000.0D * (double)input.coinValue);
        }
        log.debug(" input.totalPlay=" +input.totalPlay
                +"\n input.totalWin=" +input.totalWin
                +"\n this._totalPlay=" +this._totalPlay
                +"\n this._totalWin=" + this._totalWin
                +"\n input.totalPlay - this._totalPlay=" + (input.totalPlay - this._totalPlay)
                +"\n nowWin =" + nowWin
                +"\n input.slavePlay=" + input.slavePlay
                +"\n input.slaveWin=" + input.slaveWin + " water->"+this._fangWater + " l_FeedBack3->"+l_feadback3+ " totalUnproCredit->" + input.totalUnproCredit);

        gameDf = this.GetGameDf(input.gameDfLevel);  // 读取台桌难度系数
        input.totalWin += (long)(gameDf * (double)input.totalUnproCredit); //飞在外面的分 可忽略
        //座位总押盈利大于200 && 总押>20
        if (this.struct_record.record[input.whichSlave] <= 0L || 
            input.slavePlay - this.struct_record.record[input.whichSlave] > (long)( input.coinValue * 200 )
            && input.totalPlay - this.struct_record.totalRecord > (long)(input.coinValue * 20))
		 {
            this.struct_record.totalRecord = input.totalPlay;   // 动态总押
            this.struct_record.record[input.whichSlave] = input.slavePlay; // 座位总押
            STRUCT_AMEND_INPUT_SIM simAmendInput = new STRUCT_AMEND_INPUT_SIM();
            simAmendInput.coinValue = input.coinValue;
            simAmendInput.gameDf = gameDf;
            simAmendInput.hallType = input.hallType;
            simAmendInput.feadback3 = l_feadback3;
            simAmendInput.totalPlay = input.totalPlay;
            simAmendInput.totalWin = input.totalWin;
            simAmendInput.slavePlay = input.slavePlay;
            simAmendInput.slaveWin = input.slaveWin;
            this.struct_record.tmpGf[input.whichSlave] = this.AmendGameDf_sim(simAmendInput);
        }
        return this.struct_record.tmpGf[input.whichSlave];
    }

    /* 修正游戏难度 */
    public double AmendGameDf_sim(STRUCT_AMEND_INPUT_SIM input) {
        double specialAmend = 1.0D;
        if (input.coinValue < 500 && input.gameDf * (double)input.totalPlay - (double)input.totalWin > 0.0D) {
            specialAmend = Math.pow((double)input.coinValue / 500.0D, 1.0D); // Math.pow(A,B) A的B次方
        }
        // 1.0 + 1.0 * pow( 3/2 ,1.4 )=1.76  * (1.0 / 1000) * (gameDf * totalPlay -totalWin ) / 10w
        // 1.0 + 1.0 * pow( 3/2 ,1.4 )=1.76  * (1.0 / 1000) * (gameDf * slavePlay -slaveWin ) / 50w
        double feadback1 = 1.0D + specialAmend * Math.pow( 3.0D / (double)input.hallType , (double) afloat14) * (1.0D / (double)input.coinValue) * (input.gameDf * (double)input.totalPlay - (double)input.totalWin) / (double) int10w;
        double feadback2 = 1.0D + specialAmend * Math.pow( 3.0D / (double)input.hallType , (double) afloat14) * (1.0D / (double)input.coinValue) * (input.gameDf * (double)input.slavePlay - (double)input.slaveWin) / (double)(int10w *5);
        log.debug("feadback1=" + feadback1+" feadback2=" + feadback2);
        //预估盈利>(2WB/samend)且 总押<200WB
        if (input.gameDf * (double)input.totalPlay - (double)input.totalWin > (double)(20000 * input.coinValue) / specialAmend && input.totalPlay < 2000000L * (long)input.coinValue) {
            feadback1 = 1.0D + (feadback1 - 1.0D) * 5.0D;
        }
        else if (input.gameDf * (double)input.totalPlay - (double)input.totalWin > (double)(30000 * input.coinValue) / specialAmend) {
            feadback1 = 1.0D + (feadback1 - 1.0D) * 5.0D;
        }
		
		double F8 = feadback1 * feadback2 * input.feadback3;
        log.debug( "F8=" + F8+" feadback3=" + input.feadback3 );

        if (F8 < 0.9D) {
            F8 = 0.9D;
        } else if (F8 > 1.1D) {
            F8 = 1.1D;
        }

        return input.gameDf * F8;
    }
}
pack



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: