Advertisement
TForgery

GamesToLegend

Aug 11th, 2015
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. import java.util.*;
  2. public class GamesToLegend {
  3.  
  4.     public static void main(String[] args) {
  5.         Scanner scanIn = new Scanner(System.in);
  6.         System.out.print("What is your winrate? (65% should be written as 0.65) ");
  7.         double winRate = scanIn.nextDouble();
  8.         System.out.print("What rank were you last season? (If Legend, input 0)");
  9.         int numStarsStart = 25-scanIn.nextInt();
  10.         int[] totalGames= new int[10000];
  11.         for(int i = 0;i<totalGames.length;i++){
  12.             int numStars=numStarsStart;
  13.             int winStreak=0;
  14.             int numGames = 0;
  15.             while(numStars < 95){
  16.                 if(matchResult(winRate)){
  17.                     numStars++;
  18.                     winStreak++;
  19.                     if(winStreak>3 && numStars < 75) numStars++;
  20.                 } else {
  21.                     if(numStars>10){
  22.                         numStars--;
  23.                     }
  24.                     winStreak = 0;
  25.                 }
  26.                 numGames++;
  27.             }
  28.             //System.out.println("You hit legend in " + numGames + " games.");
  29.             totalGames[i]=numGames;
  30.         }
  31.         double avgGames = 0;
  32.         for(int j = 0;j<totalGames.length;j++){
  33.             avgGames+=totalGames[j];
  34.         }
  35.         avgGames/=totalGames.length;
  36.         System.out.println("You reached legend in an average of " + avgGames + " games.");
  37.     }
  38.    
  39.     public static boolean matchResult(double winRate) {
  40.         Random rand = new Random();
  41.         if(rand.nextDouble()<=winRate){
  42.             return true;
  43.         }
  44.         return false;
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement