@glennyisbae/

FirstOrchard

Java

No description

fork
loading
Files
  • Main.java
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class Main {
public static void main(String[] args){
    int ravenPos;
    int yellowNum;
    int redNum;
    int greenNum;
    int blueNum;
    int roll;
    boolean win;
    int winCount=0;
    for (int i=0; i<1000000; i++){
      ravenPos=0;
      yellowNum=4;
      redNum=4;
      greenNum=4;
      blueNum=4;
      win=false;
     while (ravenPos!=5 && !win){
      roll=(int)(Math.random()*6);
      if (roll==0)
        ravenPos++;
      if (roll==1 && yellowNum>0)
        yellowNum--;
      if (roll==2 && redNum>0)
        redNum--;
      if (roll==3 && greenNum>0)
        greenNum--;
      if (roll==4 && blueNum>0)
        blueNum--;
      if (roll==5)
        if (redNum>=blueNum && redNum>=greenNum && redNum>=yellowNum)
          redNum--;
        else if (blueNum>=redNum && blueNum>=greenNum && blueNum>=yellowNum)
          blueNum--;
        else if (greenNum>=redNum && greenNum>=blueNum && greenNum>=yellowNum)
          greenNum--;
        else if (yellowNum>=redNum && yellowNum>=blueNum && yellowNum>=greenNum)
          yellowNum--;
      if (redNum==0 && blueNum==0 && greenNum==0 && yellowNum==0){
        win=true;
        winCount++;
     }
    }
   }
    System.out.print(winCount/1000000.0);
  }
}