Year of the Dragon: Through April 23rd, claim the adventure pack Slice of Life for free! Speak to Xatheral in the Hall of Heroes.

Game mechanicsNewbie guideIn developmentDDO StoreSocial Media


ChallengesClassesCollectablesCraftingEnhancementsEpic DestiniesFavorFeats

GlossaryItemsMapsMonstersPlacesQuestsRacesReincarnationSkillsSpells


Please create an account or log in to build a reputation and unlock more editing privileges, and then visit DDO wiki's IRC Chat/Discord if you need any help!

Talk:Repair (equipment)

From DDO wiki
Jump to navigation Jump to search

Proof that it does matter when you repair (by anonymous user)[edit]

a. The chance of permanent damage is inversely proportional to the ratio of current durability to maximum durability.
b. Many weapons have max durability over 100, such as 115.
c. DDO uses simulated dice-rolling for random numbers.
d. Dice can only return integers.
e. Expressed as an integer, 1/115 is a 0% chance of permanent damage.
f. Therefore, repair often enough, and the weapon will never be permanently damaged.

I don't know if it's a joke, or a serious attempt at demonstrating something. Since you always repair before the durability is zero, the fraction is always a real number less than 1, and truncating as per usual D&D practice would always return a 0% chance of permanent damage. Thus there would never be any permanent damage in game. Tihocan 11:32, August 16, 2006 (EDT)
No. Your assumptions on at what point the code truncates are unfounded and insensible. If they truncate, it would be with probability measured in % (0-100), not probability measured in fractions (0-1).. because the latter, as you mention, would be insane, and would never allow damage to happen. There is no D&D tradition supporting the use of real-number probability between 0-1, but 1d4, 1d6, 1d10, 1d20, and even 1d100 are part of the game. If one assumes that permament damage is computed with a 1d100 roll, then there will NEVER be perma-damage when repairing at 114/115 durability, meaning that frequent repairs will extend the life of a weapon.
I guess you're Gimpster? ;) Yes, now I understand what you meant. It made no sense to me because you didn't say the probability was multiplied by 100 to be rounded to an integer between 0 and 100, and that by "often enough" you meant "after every single point of temporary damage". I will mention this on the main page though, to make it very clear under which assumptions my maths are correct. By the way, I have no way to tell if your assumption is more sensible than mine. You're reasoning per D&D rules, but nowhere in D&D can I think of an example of a probability expressed as a fraction and rounded down to an integer value. Tihocan 09:52, August 21, 2006 (EDT)

Simulation confirming the mathematical analysis[edit]

I wrote a short piece of code to simulate DDO repairs. It considers an item of initial durability 100, and compares the lifespan of the object depending on the repair strategy (repairing every x amount of temporary damage). This is done 1 million times, then it outputs the average lifespan, as well as a 95% confidence interval.

The meaning of this confidence interval is as follows: in 95% of cases, the lifespan was comprised between (avg - i) and (avg + i), where avg is the average lifespan and i the value given for the confidence interval: the higher the confidence interval, the less likely you are to be near the average lifespan.

Here are the results:

  • Repair every 1 damage: avg = 1542, i = 675
  • Repair every 2 damage: avg = 1541, i = 670
  • Repair every 5 damage: avg = 1542, i = 658
  • Repair every 10 damage: avg = 1543, i = 639
  • Repair every 20 damage: avg = 1542, i = 592
  • Repair every 50 damage: avg = 1541, i = 400
  • Repair every 90 damage: avg = 1542, i = 133

And here is the code:

#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
int main(int argc, char** argv)
{
    if (argc < 3) {
        printf("Usage: repair <n_tries> <item_durability> <repair_every>\n");
        return 1;
    }
    // Parse command-line arguments.
    int c = 1;
    int n_tries = atoi(argv[c++]);
    int item_durability = atoi(argv[c++]);
    int repair_every = atoi(argv[c++]);
    const char* output_file = argv[c++];
    // Initialize random seed.
    time_t t;
    time(&t);
    srand((unsigned int) t);
    // Max lifespan we think we can possibly get (only limited by the computer
    // memory). If really too low, results may not be accurate.
    // The i-th element is the number of times the item's lifespan has been
    // equal to i, among the 'n_tries' tries.
    int max_lifespan = 1000000;
    int count_lifespan[max_lifespan];
    for (int i = 0; i < max_lifespan; i++)
        count_lifespan[i] = 0;
    int n_valid_tries = 0;
    // Main loop: average over 'n_tries' tries.
    for (int i = 0; i < n_tries; i++) {
        int current_max_durability = item_durability;
        int current_permanent_damage = 0;
        int current_durability = current_max_durability;
        int lifespan = 0;
        int temp_damage = 0;
        while (current_max_durability > 0) {
            // Each iteration brings one additional point of temporary damage.
            temp_damage++;
            current_durability--;
            lifespan++;
            if (temp_damage == repair_every || current_durability == 0) {
                // Time to repair.
                double chance_of_success =
                    current_durability / double(current_max_durability);
                double random_0_1 = rand() / (RAND_MAX + 1.0);
                if (random_0_1 >= chance_of_success) {
                    // Failure: get new permanent damage.
                    int new_perm_damage;
                    if (current_permanent_damage == 0)
                        new_perm_damage = 1;
                    else
                        new_perm_damage = int(sqrt(current_permanent_damage));
                    current_max_durability -= new_perm_damage;
                    current_permanent_damage += new_perm_damage;
                }
                // Item is repaired now.
                temp_damage = 0;
                current_durability = current_max_durability;
            }
        }
        if (lifespan < max_lifespan) {
            n_valid_tries++;
            count_lifespan[lifespan]++;
        }
    }
    // Scale the results to obtain a frequency, between 0 and 1.
    if (n_valid_tries == 0) {
        printf("Could not perform any valid try, something is wrong\n");
        return 1;
    }
    int max_lifespan_found = 0; // Will store the highest lifespan encountered.
    double freq_lifespan[max_lifespan];
    for (int i = 0; i < max_lifespan; i++) {
        int count = count_lifespan[i];
        freq_lifespan[i] = count / double(n_valid_tries);
        if (count > 0)
            max_lifespan_found = i;
    }
    // Compute average and 95% confidence interval.
    double avg = 0;
    for (int i = 0; i <= max_lifespan_found; i++)
        avg += freq_lifespan[i] * i;
    int avg_int = int(round(avg));
    double cumul = freq_lifespan[avg_int];
    int interval = 0;
    while (cumul <= 0.95) {
        interval++;
        if (avg_int + interval < max_lifespan)
            cumul += freq_lifespan[avg_int + interval];
        if (avg_int - interval >= 0)
            cumul += freq_lifespan[avg_int - interval];
    }
    interval--;
    printf("Average lifespan: %d\n", avg_int);
    printf("95 percent confidence interval: %d\n", interval);
    return 0;
}

Re: simulation[edit]

That source code is not appropriate for a talk page. If the math equations about hypothetical repair effects deserve a real page, then so does that source code. Additionally, that simulation is only correct if you use durability <=100, which is NOT how good DDO weapons work, and if you assume floating-point RNG, which is totally inconsistent with D&D tradition.

I put the source code in the talk page because I don't belive many people are interested in it. It's just so that people can check it out if they want to. I don't mind if you want to put it on its own page, I just don't think it deserves one. That simulation is only correct assuming floating point RNG, yes, but there is no assumption of the durability being <= 100. Tihocan 10:40, August 21, 2006 (EDT)

Just because your assumptions were consistent with themselves doesn't mean they are consistent with the game. If you'd like to prove otherwise, you'd have to take a 115 durability weapon down to 114, screenshot it at a vendor, and then get a sequential screenshot of it recieving permanent damage despite being at over 99% of total durability.

If this situation happens and I notice it, I'll report it. Considering how unlikely it is to happen though, it might take a lot of time :P Tihocan 10:40, August 21, 2006 (EDT)

replace page contents?[edit]

I'm considering replacing this page with the first post from this thread on the forums: DDO Forums Seems like that is far more up to date, and usefull. Any considerations? --Cyanpill 12:32, November 16, 2009 (EST)

Sure. This page is pretty intimidating as it is. It would be better if we could dumb it down so that the normal user would not die in front of all the math involved. Though, don't just copy/paste Garth's thread. Try to reformat the whole thing in an article if you can. --Borror0 05:48, November 17, 2009 (EST)
Yeah, just move my maths on their own page somewhere else. They're not really useful to the typical wiki reader, but I'd like to keep them somehwere as reference -- Tiho unlogged, Nov. 19, 2009