简单的DNF增幅模拟器
package com.xxx;import java.util.Random;public class Equipmet {int level;int level_max;public Equipmet(){level_max=0;level=12;};public Equipmet(int level,int level_max){this.level=level;this.level_max=level_max;};public boolean Strengthen(){Random r=new Random();if(this.level==-1){System.out.println(" 武器已损坏!!!");}else if(this.level<=3){//增幅成功概率为100%this.level++;System.out.println("强化成功,现在等级是"+this.level);this.level_max=this.level>this.level_max?this.level:this.level_max;}else if (this.level==4){//增幅成功概率为80%int number=r.nextInt(101);if (number>20){this.level++;System.out.println("强化成功,现在等级是"+this.level);this.level_max=this.level>this.level_max?this.level:this.level_max;}else {this.level--;System.out.println("强化失败,现在等级是"+this.level);}}else if (this.level==5){//增幅成功概率为70%int number=r.nextInt(101);if (number>30){this.level++;System.out.println("强化成功,现在等级是"+this.level);this.level_max=this.level>this.level_max?this.level:this.level_max;}else {this.level--;System.out.println("强化失败,现在等级是"+this.level);}}else if (this.level==6){//增幅成功概率为60%int number=r.nextInt(101);if (number>40){this.level++;System.out.println("强化成功,现在等级是"+this.level);this.level_max=this.level>this.level_max?this.level:this.level_max;}else {this.level--;System.out.println("强化失败,现在等级是"+this.level);}}else if (this.level==7){//增幅成功概率为70%//9失败到6//8失败到5//7失败到4int number=r.nextInt(101);if (number>30){this.level++;System.out.println("强化成功,现在等级是"+this.level);this.level_max=this.level>this.level_max?this.level:this.level_max;}else {this.level=4;System.out.println("强化失败,现在等级是"+this.level);}}else if (this.level==8){//增幅成功概率为60%//9失败到6//8失败到5//7失败到4int number=r.nextInt(101);if (number>40){this.level++;System.out.println("强化成功,现在等级是"+this.level);this.level_max=this.level>this.level_max?this.level:this.level_max;}else {this.level=5;System.out.println("强化失败,现在等级是"+this.level);}}else if (this.level==9){//增幅成功概率为50%//9失败到6//8失败到5//7失败到4int number=r.nextInt(101);if (number>50){this.level++;System.out.println("强化成功,现在等级是"+this.level);this.level_max=this.level>this.level_max?this.level:this.level_max;}else {this.level=6;System.out.println("强化失败,现在等级是"+this.level);}}else if (this.level==10){int number=r.nextInt(101);if (number>60){this.level++;System.out.println("强化成功,现在等级是"+this.level);this.level_max=this.level>this.level_max?this.level:this.level_max;}else {this.level=-1;System.out.println("增幅失败,武器损坏!!!");}}else if (this.level==11){int number=r.nextInt(101);if (number>70){this.level++;System.out.println("强化成功,现在等级是"+this.level);this.level_max=this.level>this.level_max?this.level:this.level_max;}else {this.level=-1;System.out.println("增幅失败,武器损坏!!!");}}else {int number=r.nextInt(101);if (number>80){this.level++;System.out.println("强化成功,现在等级是"+this.level);this.level_max=this.level>this.level_max?this.level:this.level_max;}else {this.level=-1;System.out.println("增幅失败,武器损坏!!!");}}return false;}
}
主函数
public static void main(String[] args) {final int my_equiment=100000;Equipmet ee[] ;ee=new Equipmet[my_equiment];for (int i=0;i<my_equiment;i++){ee[i]=new Equipmet();}for(int i=0;i<my_equiment;i++){for (;ee[i].level!=-1;){ee[i].Strengthen();}}int max_max=0;for (int i=0;i<my_equiment;i++){max_max=ee[i].level_max>max_max?ee[i].level_max:max_max;}System.out.println("最高增幅"+max_max);}
模拟9999999把增幅10武器最高能上到多少: