Advertisement
MrMusAddict

Stat Roll (4d6 high 3) Java Code

Dec 6th, 2019
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.23 KB | None | 0 0
  1. double t3 = 1.0/1296.0;
  2. double t4 = 4.0/1296.0;
  3. double t5 = 10.0/1296.0;
  4. double t6 = 21.0/1296.0;
  5. double t7 = 38.0/1296.0;
  6. double t8 = 62.0/1296.0;
  7. double t9 = 91.0/1296.0;
  8. double t10 = 122.0/1296.0;
  9. double t11 = 148.0/1296.0;
  10. double t12 = 167.0/1296.0;
  11. double t13 = 172.0/1296.0;
  12. double t14 = 160.0/1296.0;
  13. double t15 = 131.0/1296.0;
  14. double t16 = 94.0/1296.0;
  15. double t17 = 54.0/1296.0;
  16. double t18 = 21.0/1296.0;
  17.  
  18. double total = 0;
  19.  
  20. long[] all = new long[109];
  21. double[] all2 = new double[109];
  22.  
  23. int d1 = 3;
  24. int d2 = 3;
  25. int d3 = 3;
  26. int d4 = 3;
  27. int d5 = 3;
  28. int d6 = 3;
  29.  
  30. void setup() {
  31. }
  32.  
  33. void draw() {
  34.   println(d1 + ", " + d2 + ", " + d3 + ", " + d4 + ", " + d5 + ", " + d6);
  35.   for (int i = 0; i < 100000; i++) {
  36.     all[d1+d2+d3+d4+d5+d6]++;
  37.     all2[d1+d2+d3+d4+d5+d6]+= tc(d1, d2, d3, d4, d5, d6);
  38.     next(15);
  39.     if (d1 == 18 && d2 == 18 && d3 == 18 && d4 == 18 && d5 == 18 && d6 == 18) {
  40.       all[d1+d2+d3+d4+d5+d6]++;
  41.       all2[d1+d2+d3+d4+d5+d6]+= tc(d1, d2, d3, d4, d5, d6);
  42.       println(all);
  43.       println(all2);
  44.       noLoop();
  45.       break;
  46.     }
  47.   }
  48. }
  49.  
  50. void next(int i) {
  51.   if (d1 == 18) {
  52.     d1 = 3;
  53.     if (d2 == 18) {
  54.       d2 = 3;
  55.       if (d3 == 18) {
  56.         d3 = 3;
  57.         if (d4 == 18) {
  58.           d4 = 3;
  59.           if (d5 == 18) {
  60.             d5 = 3;
  61.             if (d6 == 18) {
  62.               d6 = 3;
  63.             } else {
  64.               d6++;
  65.             }
  66.           } else {
  67.             d5++;
  68.           }
  69.         } else {
  70.           d4++;
  71.         }
  72.       } else {
  73.         d3++;
  74.       }
  75.     } else {
  76.       d2++;
  77.     }
  78.   } else {
  79.     d1++;
  80.   }
  81. }
  82.  
  83. double tc(int r1, int r2, int r3, int r4, int r5, int r6) {
  84.   return c(r1)*c(r2)*c(r3)*c(r4)*c(r5)*c(r6);
  85. }
  86.  
  87. double c(int d) {
  88.  
  89.   switch(d) {
  90.   case 3:
  91.     return t3;
  92.   case 4:
  93.     return t4;
  94.   case 5:
  95.     return t5;
  96.   case 6:
  97.     return t6;
  98.   case 7:
  99.     return t7;
  100.   case 8:
  101.     return t8;
  102.   case 9:
  103.     return t9;
  104.   case 10:
  105.     return t10;
  106.   case 11:
  107.     return t11;
  108.   case 12:
  109.     return t12;
  110.   case 13:
  111.     return t13;
  112.   case 14:
  113.     return t14;
  114.   case 15:
  115.     return t15;
  116.   case 16:
  117.     return t16;
  118.   case 17:
  119.     return t17;
  120.   case 18:
  121.     return t18;
  122.   default:
  123.     return 0;
  124.   }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement