Dicey Randomness

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Narvius
    Knight
    • Dec 2007
    • 589

    Dicey Randomness

    While being bored during maths class today, I thought about Angband. And the [XdY] notation for damage/healing. And ToME 3, which prefers [X-XY].

    Until then I thought that XdY perfectly equals X-XY, but that's not true.
    I'll take 3d3 as example.
    3-9 means that there's an equal chance for each number to be chosen randomly (in that case, around 14% per number).
    But 3d3 is different:

    Code:
    | # | A |  B  |
    |--------------
    | 3 | 1 |  4% |
    | 4 | 3 | 11% | A = Possible different combinations
    | 5 | 6 | 22% | B = Probability
    | 6 | 7 | 26% |
    | 7 | 6 | 22% |
    | 8 | 3 | 11% |
    | 9 | 1 |  4% |
    As you see, you'll get more average values.

    And now the question I wanted to ask:
    Does Angband one random() for each dice
    { for (y; y > 0; y--) foo += random(x) + 1 }
    or only one big random using-xy?
    { foo +=randomX(x, xy) + 1 }

    Not that it would make a big difference, the average stays the same after all, but I'm in my curious-about-Angband-game-mechanics-phase.
    If you can convincingly pretend you're crazy, you probably are.
  • Mangojuice
    Z+Angband Maintainer
    • Jun 2008
    • 318

    #2
    Originally posted by Narvius
    While being bored during maths class today, I thought about Angband. And the [XdY] notation for damage/healing. And ToME 3, which prefers [X-XY].

    And now the question I wanted to ask:
    Does Angband one random() for each dice
    { for (y; y > 0; y--) foo += random(x) + 1 }
    or only one big random using-xy?
    { foo +=randomX(x, xy) + 1 }

    Not that it would make a big difference, the average stays the same after all, but I'm in my curious-about-Angband-game-mechanics-phase.
    In Angband, it's the former: it really rolls 3 separate dice and adds them together. The average is the same, but the overall effect on game strategy is, I think, not the same.

    Due to the normal distribution, you can see the 3d3 weapon is more consistent at doing close-to-average damage, but quite unlikely to get especially high damage. For instance, the expected number of hits needed to reach, say, 5 damage is 1.185 for the 3d3 weapon and 1.286 for the 3-9 weapon - about 10% better. Other targets may work out differently. For instance, if we have to deal 9 damage, we expect 2.001 hits for the 3d3 weapon but 1.980 hits for the 3-9 weapon. These numbers get closer and closer together as the goal goes up.

    But there is a substantive difference, too: if, for instance, you are fighting something a little hard for you, it's possible that dealing average damage every time will never be sufficient, but above-average damage could do it. In that kind of case, you'd want to have the more variable 3-9 weapon.

    Also, if you play a variant with to_d bonuses expressed in percentages, there is an added benefit from having fewer dice with more sides: the real effect of a "+10%" damage rating is to upgrade a 1d10 weapon to a 1d11 one; a +10% bonus may have no effect at all on a 3d3 weapon.

    Of course this is all quite minor in the grand scheme of things.
    -----------------------------------------
    Z+Angband: A Zangband evolution
    http://tinyurl.com/5pq2bd

    Comment

    • Narvius
      Knight
      • Dec 2007
      • 589

      #3
      Originally posted by Mangojuice
      In Angband, it's the former: it really rolls 3 separate dice and adds them together.
      Okay, thanks, that's what I wanted to know.

      How the heck did you calculate that expected blows-stuff? oO
      If you can convincingly pretend you're crazy, you probably are.

      Comment

      • Mangojuice
        Z+Angband Maintainer
        • Jun 2008
        • 318

        #4
        Originally posted by Narvius
        Okay, thanks, that's what I wanted to know.

        How the heck did you calculate that expected blows-stuff? oO
        For reaching 5 damage it's easy: basically, 2 blows would be enough no matter what, so the question is what's the probability that the first blow does 5 or more? It's 5/7 for the 3-9 weapon, and 23/27 for the 3d3 weapon. 1.286 is about 1+2/7, while 1.185 is about 1+4/27.

        For more damage, it's a lot of individual cases; you collect the probability to hit each particular amount of damage in each number of turns, and use that for the next higher number of turns. I made a spreadsheet for some more tests because I got curious. For instance, if you want 20 damage, and you have a weapon with mean damage 6, the expected number of turns is:

        1d11: 3.886 turns
        3-9 (1d7+2): 3.802 turns
        2d5: 3.804 turns
        3-9 (2d4+1): 3.783 turns
        3d3: 3.783 turns
        4d2: 3.817 turns
        6d1: 4 turns

        (3d3 is better by 0.00008 compared to 2d4+1; not an exact tie.)

        So you see the differences become pretty small generally.
        -----------------------------------------
        Z+Angband: A Zangband evolution
        http://tinyurl.com/5pq2bd

        Comment

        • Narvius
          Knight
          • Dec 2007
          • 589

          #5
          Wow, that's interesting.
          You could upload that spreadsheet... ^.^
          If you can convincingly pretend you're crazy, you probably are.

          Comment

          • bpleshek
            Apprentice
            • Sep 2008
            • 59

            #6
            3-9 is basically 1d7+2 rather than 3d3 if you're looking for an equivalent to random distribution.

            Brian

            Comment

            • Mangojuice
              Z+Angband Maintainer
              • Jun 2008
              • 318

              #7
              Originally posted by Mangojuice
              Also, if you play a variant with to_d bonuses expressed in percentages, there is an added benefit from having fewer dice with more sides: the real effect of a "+10%" damage rating is to upgrade a 1d10 weapon to a 1d11 one; a +10% bonus may have no effect at all on a 3d3 weapon.
              Actually, that's wrong. On closer checking, I note that the Zangband/Oangband style damage algorithm actually handles fractional dice. So a d3.5 is a d3 with a 50% chance of an extra +1. Which is actually kind of bad: that .5 adds .5 to the expected result, whereas a whole 1 (d4 in this case) would add only .5. So, for instance, a 3d3 weapon with +30% damage would do an average of 8.7 damage, while a 3d3 weapon with +35% damage would actually do 7.55 damage average.
              -----------------------------------------
              Z+Angband: A Zangband evolution
              http://tinyurl.com/5pq2bd

              Comment

              • Narvius
                Knight
                • Dec 2007
                • 589

                #8
                @bpleshek
                Yeah, I know. But as said, I refer to ToME 3. It has 3-9 as warhammer damage (at least I think so... *cough*).
                If you can convincingly pretend you're crazy, you probably are.

                Comment

                • Djabanete
                  Knight
                  • Apr 2007
                  • 576

                  #9
                  You should forget about the math and go sacrifice a sheep to the RNG.

                  Comment

                  • Narvius
                    Knight
                    • Dec 2007
                    • 589

                    #10
                    You surely meant a yeek
                    If you can convincingly pretend you're crazy, you probably are.

                    Comment

                    Working...
                    😀
                    😂
                    🥰
                    😘
                    🤢
                    😎
                    😞
                    😡
                    👍
                    👎