Miscellaneous Forums > Scripting and Reverse Engineering

[FF7] 3D Battler RNG

<< < (2/2)

JBedford128:
I'm not a statistician, but there's no way you have a 25% chance of beating the fourth opponent.

There's a 25% chance you'll beat him in any given round, but to beat him overall you have to hit him ten times while avoiding being hit ten times. (I think) Since there's no ties, that means you have to roll a 4 on a d4 ten times in 19 contests.

Edit: This dice probability calculator says the probabiliy is 0.8903279303922318%.

Edit Edit: Opponent 1 is 92.58414292768207%. Opponent 2 is 54.13893634975759%. Opponent 3 is 6.4766172790962875%.

ff7man:
You are right.... balls. Thanks for correcting me, I don't want to be giving out wrong stats.

Your math checks out with a simple python script


--- Code: ---import random

n = 0
win = 0
loss = 0
while n<1000000:
 ehealth = 0
 mhealth = 0
 while (ehealth < 10 and mhealth < 10):
  num = random.randint(0,3)
  if num == 1:
    ehealth +=1
  else:
    mhealth +=1
 if ehealth > mhealth:
  win+=1
 else:
  loss+=1
 n+=1

print(n)
print(win)
print(loss)
print(win/n)

--- End code ---

Python random isn't precise but gives a .87-.90% depending on the run

So on the website I'm guessing you did:
Dice Type: Tetrahedron (4 faces)
Total number of dice: 19
I want to get: At least X dice equal to
The value: 1 (any of them really)
.. or: 0
Target number of dice (X): 10

How'd you get the numbers in the edit edit?

JBedford128:
The linked calculator page gave the formula for calculating the probability so I wrote a quick JavaScript script to execute in the console


--- Code: ---//probability of succeeding a roll (win, loss)
function prob(w, l) {
  return 1/(w+l)*w;
}

function binomial(n, k) {
    let coeff = 1;
    for (let x = n-k+1; x <= n; x++) coeff *= x;
    for (x = 1; x <= k; x++) coeff /= x;
    return coeff;
}

//probability of rolling r number of successes at p probablity with n number of dice
function P(n, r, p) {
  return binomial(n,r) * Math.pow(p,r) * Math.pow(1-p,n-r)
};
//probability of rolling /at least/ r at p with n
function Pplus(n, r, p) {
  let out = 0;
  for(let i = r; i <= n; i++) {
    out += P(n, i, p);
  }
  return out;
}

function battler() {
  let opponents = [
    [120, 62],
    [ 87, 83],
    [ 64,128],
    [ 64,192]
  ];
  let rolls = 19;
  let wins = 10;
 
  let output = [];
 
  for(let [i, stack] = [0, 1]; i < opponents.length; i++) {
    let p = prob(...opponents[i]);
    let success = Pplus(rolls, wins, p);
    stack *= success;
    output[i] = [success*100, stack*100];
  }
 
  return output;
}

console.log(...battler());

--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version