Ich versuche einen Elo-Simulator zu programmieren. Durch die Kommentare am Anfang (sorry fürs schlechte Englisch) hab ich kurz und knapp erklärt was das Programm so tut. Ich versuche nun Elo-Tiers hinzufügen, damit ich weiß wie viele Spiele ich ungefähr spielen muss um die z.b Platinum 2 zu erreichen. Wenn ich aber die SwitchMethoden hinzufüge, dann funktioniert mein Code nicht mehr.
Wenn ich die Switchmethoden weglasse, dann klappt der restliche Code.
Kann mir jemand erklären, was ich denn falsch mache.
Danke im Voraus.
Lg,
Visar
Java:
import java.util.Random;
import java.util.Scanner;
public class EloSimulator {
/*This Code will simulate:
* -The player starting at a specific amount of LP to 100
* -If the player reaches 100 LP he will do his promo
* -If he wins his promo he will add it to PromosWon/if he loses nothing happens and the simulations goes to the next player
* -After that process the simulation restarts with another player with the same amount of LP
* -The Player will not demote he will have negative Lp but he wont demote because I didn't take it into account so dont hate pls
*/
public static void main(String[]args) {
//Editable/you can edit the code underneath this comment
int TRank = 0;
int TRank2 = 0;
int AmountofSimulations = 1000;
int maxLPWON = 24;
int minLPWON = 17;
int maxLPLOST = 17;
int minLPLOST = 13;
int Winrate = 49;
int StartingLP = 0;
//not editable/you shouldn't edit the code underneath this comment
int Simulations = 0;
int PromosWon = 0;
int[] GArray = new int[AmountofSimulations+1];
Scanner sc = new Scanner(System.in);
System.out.println("Rank:");
String Rank = sc.next();
System.out.println("Tier:");
int Tier = sc.nextInt();
System.out.println("Rank:");
String Rank2 = sc.next();
System.out.println("Tier:");
int Tier2 = sc.nextInt();
switch(Rank) {
case "Iron":
TRank=0;
break;
case "Bronze":
TRank=4;
break;
case "Silver":
TRank=4;
break;
case "Gold":
TRank=12;
break;
case "Platinum":
TRank=16;
break;
case "Diamond":
TRank=20;
break;
default:
System.out.println("Fehler");
break;
}
switch (Tier) {
case 1:
TRank=TRank+3;
break;
case 2:
TRank=TRank+2;
break;
case 3:
TRank=TRank+1;
break;
default:
TRank=TRank+0;
break;
}
switch(Rank2) {
case "Iron":
TRank2=0;
break;
case "Bronze":
TRank2=4;
break;
case "Silver":
TRank2=4;
break;
case "Gold":
TRank2=12;
break;
case "Platinum":
TRank2=16;
break;
case "Diamond":
TRank2=20;
break;
default:
System.out.println("Fehler");
break;
}
switch (Tier2) {
case 1:
TRank2=TRank2+3;
break;
case 2:
TRank2=TRank2+2;
break;
case 3:
TRank2=TRank2+1;
break;
default:
TRank2=TRank2+0;
break;
}
while(Simulations<AmountofSimulations) {
int Games = 0;
int LP = StartingLP;
do {
double Winrate2 = Math.random()*100;
int LPLost= new Random().nextInt((maxLPLOST-minLPLOST)+1)+minLPLOST;
int LPWIN = new Random().nextInt((maxLPWON-minLPWON)+1)+minLPWON;
if(Winrate2<Winrate) {
LP=LP+LPWIN;
}
else {
LP=LP-LPLost;
}
Games++;
}
while(LP<100);
Simulations++;
GArray[Simulations] = Games;
if(LP>=100) {
int PromoGamesWON = 0;
do {
if(TRank % 4 ==3) {
for(int i=1; i<5; i++) {
double Winrate2 = Math.random()*100;
if(Winrate2<Winrate) {
PromoGamesWON++;
Games++;
if(PromoGamesWON==3) {
TRank++;
}
}
}
}
else {
for(int i=1; i<3; i++) {
double Winrate2 = Math.random()*100;
if(Winrate2<Winrate) {
PromoGamesWON++;
Games++;
if(PromoGamesWON==2) {
TRank++;
}
}
}
}
}
while(TRank!=TRank2);
}
}
int x = 0;
for(int i:GArray) {
x=x+i;
}
double y = AmountofSimulations*10/10;
x=x/GArray.length;
System.out.println("Average Games: "+x);
System.out.println("Percentage of Promos won: "+(PromosWon/y)*100+"%");
}
}
Wenn ich die Switchmethoden weglasse, dann klappt der restliche Code.
Kann mir jemand erklären, was ich denn falsch mache.
Danke im Voraus.
Lg,
Visar