Battle Calc Question


  • Donators

    While being fairly good with numbers, advanced math, not so much. This guy has a chart:

    link text that leads me to believe that the odds of rolling a 1 or 2 with 2, 6 sided dice is 66.7%.

    So I tried it with 2 subs who hit at 1 or 2 against a cruiser that hit's at 1, 2 or 3 ( which probably isn't super relevant ) and I get 58% basically instead of 67% when set to one rd of battle.

    0_1520307255051_Screenshot from 2018-03-05 21-25-21.png

    So is this Guy's number's wrong or is triplea or both ? He seemed to make a pretty logical explanation and since I'm only testing 1 rd of combat with the sub getting an instant kill if it hits, seems as if 67% should be correct ?

    Would appreciate any mathematicians who care to take the time to explain this to me : )

    Thanks


  • Admin

    @beelee So one thing to remember is the battle calc is approximate and just averages based on the run count (increasing run count should get closer to the true value). That said the chance with dice that 2 subs get at least 1 hit in the first round is ~55.56%. The easiest way to think about it is what is the chance of both subs missing? The answer is (4/6) * (4/6) = 4/9 = 44.44% so the chance that 1 or both hit is 100% - 44.44% = 55.56%. So the battle calc is pretty close given you only have it set to 400 run count.


  • Donators

    @redrum Hey cool Thanks redrum. I guess that guys stuff is off or I misinterpreted it.


  • Donators Moderators Admin

    @beelee With run count set to 1. You will see that the results are all over the place as well. Thus this result is extremely misleading. For dice any ways.


  • Donators

    @beelee LOL - I just caught this. Thank you 'Kent' you gave me a good laugh!

    explanation: 'Kent' is the friend of the article writer wanted a 6, with 1 dice = 1/6 thus: with 2 dice =2/6 (incorrect) but, 1 or 2 = 2/6 with 2 dice does not = 4/6 (ie 66.7%).

    But I had to read you post a couple of times to catch the error. Thank You!!

    Cheers... (LOL)


  • Admin

    I had to think about this for like half an hour because I wanted to know why @beelee's assumption was wrong and @redrum is correct and I believe I figured it out now:
    The only mistake is a false assumption that adding the 2 probabilities is the same as throwing dice multiple times. According to that logic throwing at least a 1 or 2 a single time with 4 dice is 1/3 + 1/3 + 1/3 + 1/3 = 4/3 which is of course wrong for obvious reasons.
    What you would need to do instead (if you don't want to calculate the probability of the event not happening as suggested by @redrum) is to add the probabilities of throwing 1/2, then 3-6 plus throwing 1/2, then 1/2 plus throwing 3-6, then 1/2
    Which would be 2 * (2/3 * 1/3) + 1/3 * 1/3 = 4/9 + 1/9 = 5/9 as @redrum Already pointed out.

    But yes, the name OddsCalculator is misleading, because it doesn't really calculate anything it just simulates battles and shows average results of those simulations.
    Now that I'm thinking about it: Calculating odds with actual stochastics would probably be a huge performance improvement for the hard AI, I'll look into that soon /cc @ssoloff
    As a side note (because I remember having this in school) there's a so called significance test that's all about theoretical probabilities vs real world applications.


  • Moderators

    @roiex said in Battle Calc Question:

    I had to think about this for like half an hour because I wanted to know why @beelee's assumption was wrong and @redrum is correct and I believe I figured it out now:
    The only mistake is a false assumption that adding the 2 probabilities is the same as throwing dice multiple times. According to that logic throwing at least a 1 or 2 a single time with 4 dice is 1/3 + 1/3 + 1/3 + 1/3 = 4/3 which is of course wrong for obvious reasons.
    What you would need to do instead (if you don't want to calculate the probability of the event not happening as suggested by @redrum) is to add the probabilities of throwing 1/2, then 3-6 plus throwing 1/2, then 1/2 plus throwing 3-6, then 1/2
    Which would be 2 * (2/3 * 1/3) + 1/3 * 1/3 = 4/9 + 1/9 = 5/9 as @redrum Already pointed out.

    But yes, the name OddsCalculator is misleading, because it doesn't really calculate anything it just simulates battles and shows average results of those simulations.

    I've said a bunch of times that the name should be changed to BattleSimulator.


  • Admin

    @Cernel Ooor it should actually calculate the odds, which is what I'm proposing.
    Because in theory we should expect the dice to not be rigged, and therefore the result should not differ ^^


  • Admin

    @roiex I'm pretty sure the reason we simulate rather than trying to calculate the true odds is complexity and that you'd have to keep that code in sync with the actual battle rolling code if you did create it. Calculating the true odds for 1 round combat isn't too bad but once you expand this out to unlimited rounds of combat with units that have AA attacks, support attachments, etc, it becomes pretty crazy. In the end, I believe you'd have to create a giant tree with each round of combat being a level in that tree and the number of branches to the next level would be equal to the number of different casualty combinations for both sides.

    The example above would be something like this:
    round 0: (A 2 subs, D 1 cruiser)
    round 1: [(A 2 subs, D 1 cruiser) - 22%], [(A 1 subs, D 1 cruiser) - 22%], [(A 2 subs, D 0 cruiser) - 56% - end]
    round 2: [(A 2 subs, D 1 cruiser) - 5%, (A 1 subs, D 1 cruiser) - 5%, (A 2 subs, D 0 cruiser) - 12%], [(A 1 subs, D 0 cruiser) - 7%, (A 1 subs, D 1 cruiser) - 7%, (A 0 subs, D 1 cruiser) - 7%]
    ...

    You'd have to probably expand the tree out until the probabilities get small enough to not really matter. Then you'd have to calculate all of the metrics off the probability tree you generated.


  • Moderators

    @roiex This would be cool, but I would surely suggest you to keep the current BattleCalculator, rename it to BattleSimulator, and add another utility, called BattleCalculator, to do actual calculations. The reason being that with all the stuff going on I don't think it is really feasible to have the math to cover all cases (and there are a few cases not even fully covered by the current simulations, like the "isMarine" property) and that would be a terrible burden imposed to any further changes or additions, as, in any moment you do anything influencing calculation, you would need to update the actual BattleCalculator too (and I can see this really getting in the way of adding features).
    Just based on how much having a BattleCalculator would disincentive adding any kind of additional combat features (think about AA guns specials), I would suggest to forget about it, even tho it is cool, in theory.
    But it would be good if it would be just a subset, supporting only the most common feature, and retaining an alternative BattleSimulator (the current BattleCalculator) for more complex maps. Then, the BattleSimulator could even be absent default, and let the mapmakers of more advanced maps have it, if they think so. Say, you make a reduced BattleCalculator for Classic, Revised and v3, covering all those things that are pretty much set in stone, but TWW etc. keep using the simulations.


  • Admin

    I guess that guys stuff is off or I misinterpreted it.

    @beelee I don't think Ed Collins is wrong. As you said, it may just be a misinterpretation of his table applied to the stated problem ("what is the chance of rolling two dice and at least one die is a 1 or 2?"). Using the graphic Ed Collins presents for the 36 possible combinations of rolling two six-sided dice, if you count all the cells in which either a 1 or a 2 appear, you get 20. Thus, 20 / 36 = 0.5556, as @redrum and @RoiEX calculated via other means.


  • Donators

    @ssoloff right on I come up with 24 ones or twos. Which ones should I not be counting ? Also I count 12 sixes in his example instead of 11.

    When I do it the opposite way it all works fine.


  • Admin

    I come up with 24 ones or twos. Which ones should I not be counting ?

    @beelee The bold entries in the table below are the ones that should be counted:

    - - - - - -
    (1,1) (1,2) (1,3) (1,4) (1,5) (1,6)
    (2,1) (2,2) (2,3) (2,4) (2,5) (2,6)
    (3,1) (3,2) (3,3) (3,4) (3,5) (3,6)
    (4,1) (4,2) (4,3) (4,4) (4,5) (4,6)
    (5,1) (5,2) (5,3) (5,4) (5,5) (5,6)
    (6,1) (6,2) (6,3) (6,4) (6,5) (6,6)

    Remember, you're counting pairs of dice, not the individual dice themselves.


  • Donators Moderators Admin

    @beelee simple finite = (1/6 +1/6) x 2dice = 66% without going into vast explanation.


  • Donators

    @ssoloff Cool ! Pairs of dice was where I was screwing up. Thanks for the explanation : )


  • Donators Moderators Admin

    @beelee naw its more of the fact the extra hit isn't being counted in your ? 🙂 Triplea is looking at hits that could matter.


  • Donators Moderators Admin

    @beelee it also isn't taking inot account subs have first strike ? 🙂


  • Donators Moderators Admin

    @beelee ah missed the one round of combat part


  • Donators

    @prastle heh heh : ) I missed a lot more than that 🙂

    How you doing brother ?


  • Donators Moderators Admin

    @beelee all good 🙂