+ Reply to Thread
Results 1 to 4 of 4

Thread: Statistics CHALLENGE!!     submit to reddit submit to twitter submit to tumblr

  1. #1
    Ridill
    Join Date
    Oct 2005
    Posts
    10,227
    BG Level
    9
    FFXI Server
    Asura

    Statistics CHALLENGE!!

    I've made a battle simulator for a certain game that handles battles between two units as such:

    A unit has two attributes, attack and defense which represent the chance (out of 100%) to land or avoid a hit.

    For example, Unit 1 with 30 attack and 15 defense attacks Unit 2 with 40 attack and 20 defense. Unit 1 has 30% chance to hit modified by Unit 2's 20% chance to dodge. So the actual chance of Unit 1 hitting Unit 2 is 0.3 * (1 - 0.2) = 24%. Likewise, Unit 2 has a 34% chance of hitting Unit 1.

    A battle takes place between a group of units, say, 200 of Unit 1 versus 180 of Unit 2. The battle takes place over multiple rounds. It only takes one successful hit to kill a unit. Therefore, in round 1, you would expect 24% of Unit 2 to die, and 34% of Unit 1 to die, leaving you with 132 Unit 1 and 137 of Unit 2 left to move on to round 2... which continues in that fashion until one side is completely dead.

    Now, the challenge is to calculate our chances of winning with a certain force. I can do that already by running multiple simulated trials, say 100 or more, and seeing how often one side wins, and how often the other side wins. I might find that one side wins 78% of the time, and the other wins 22% of the time. For a low number of trials, that number can fluctuate, but after a high enough number of trials, those percentages converge on a single unchanging value. That's the number we want to get via calculation rather than simulation. We could calculate, just using percentages, who "should" win. But it won't tell us how close the fight really is or how confident we can be of winning.

    So, who can actually calculate that 78% chance of somebody winning without running multiple simulated trials?

    As a check, take all units with 30 Attack, 30 Defense. 100 vs 95 gives 76% chance for the larger force to win via simulation.

  2. #2

    Re: Statistics/math/programming question

    Sorry, I don't know the answer off the top of my head but it seems that a similar situation arises when watching people play poker on TV. They show the percentage odds of a given hand winning, and as more cards are placed, the percentages change as more information is added. In the same way, the odds of each group of units winning will change each round. So it seems it should be possible to find that percentage without running successive trials. All you need is the initial conditions to get a percentage for the first round.

  3. #3

    Re: Statistics/math/programming question

    Pretty sure this isn't correct but here goes anyway:

    100 - ((#1*attack) * (#2 - #2*defense))/#2
    100 - (30 * 66.5)/2
    100 - 21 = 79%

    Maybe something like ?attack * ?(1-defense)?

  4. #4
    Ridill
    Join Date
    Oct 2005
    Posts
    10,227
    BG Level
    9
    FFXI Server
    Asura

    Re: Statistics/math/programming question

    Quote Originally Posted by Snowknight26
    Pretty sure this isn't correct but here goes anyway:

    100 - ((#1*attack) * (#2 - #2*defense))/#2
    100 - (30 * 66.5)/2
    100 - 21 = 79%

    Maybe something like ?attack * ?(1-defense)?
    I'm not entirely sure that can stay within the 0-100% bounds, since you could have any number of units.

    It could also be possible that this is impossible to do without simulation, but anything that requires less calculation steps than a few hundred full-blown simulation trials will suffice.

    Maybe I'll change the topic title to "Statistics CHALLENGE!!", that'll get more attention!

Quick Reply Quick Reply

  • Decrease Size
    Increase Size
  • Remove Text Formatting
  • Insert Link Insert Image Insert Video
  • Wrap [QUOTE] tags around selected text
  • Insert NSFW Tag
  • Insert Spoiler Tag

Similar Threads

  1. Colbert Challenge
    By Ksandra in forum General Discussion
    Replies: 14
    Last Post: 2006-08-26, 23:58