The point of the game is that there are 3 players player one has 25 accuracy player 2 has 50 accuracy and player 3 has one hundred accuracy who will win in a 10000 round shootoff. thank you so much for helping me out i just really want to make sure that this is correct.
I get outputs like this
Player 1 won 4944.0 times
Player 2 won 7606.0 times
Player 3 won 3725.0 times
Player 1 probablity is 49.44%
Player 2 probability is 76.06%
Player 2 probability is 37.25%
I do not know if this is right because player 2 always seems to win.
Have a great day ツ ☻
import java.io.PrintStream; import java.util.Random; import java.util.Scanner; public class SkillGame { public static void main(String[] args) { int rnum, life = 1, life2 = 1, life3 = 1, player, p1 = 0, p2 = 0, p3 = 0, acc1 = 0, acc2 = 0, acc3 = 0, rnum2, rnum3, rnum4, num; double cnt1 = 0, cnt2 = 0, cnt3 = 0, fin, fin2, fin3; Scanner in = new Scanner(System.in); PrintStream out = new PrintStream(System.out); Random rnd = new Random(); acc1 = 25; acc2 = 50; acc3 = 100; num = 1; for(int i = 0; i < 10000; i++){ while(true){ if(life == 1 ) { rnum4 = rnd.nextInt(4); if(life2 == 1 && life3 == 1) { if(acc3 > acc2) { if (rnum4 == 1) { life3 = 0; cnt1 = cnt1 + 1; } if(life2 == 1) { if(rnum4 == 1) { life2 = 0; cnt1 = cnt1 +1; } if(life2 == 1); { rnum3 = rnd.nextInt(2); if(life == 1 && life3 == 1) { if(acc3 > acc1) { if(rnum3 == 1) { life3 = 0; cnt2 = cnt2 +1; } if(life == 1){ if(rnum3 == 1){ life = 0; cnt2 = cnt2 +1; } } if(life3 == 1) { if(life2 == 1){ life2 = 0; cnt3 = cnt3 +1; } } } } } } } } } if(i < 10000) break; } life = 1; life2 = 1; life3 = 1; } out.println("Player 1 won " + cnt1 + " times" + "\nPlayer 2 won " + cnt2 + " times" + "\nPlayer 3 won " + cnt3 + " times"); fin = cnt1/10000 * 100; Math.round(fin); fin2 = cnt2/10000 * 100; Math.round(fin2); fin3 = cnt3/10000 * 100; Math.floor(fin3); out.println("Player 1 probablity is " + fin + "%\n" + "Player 2 probability is " + fin2 + "%\n" + "Player 2 probability is " + fin3 + "%"); } }