Open source skill gain analysis pt 1: gains vs % chance of success

Discussion in 'Renaissance Discussion' started by Unternoober, Mar 25, 2022.

  1. Unternoober

    Unternoober Member

    Joined:
    Jan 11, 2022
    Messages:
    67
    Likes Received:
    48
    Hello folks. This is the first of a few (at least 2) part series I've been working up to. The second part will be around Magery gains in particular, and I'm considering making one about Resist. As I think you'll see below, this post by itself is probably sufficient for all crafting skills... the rest is an exercise in choosing crafting items that stay near the optimal level of challenge (and maybe other folks will want to follow-up with guides that recommend specific items).

    I've found some awesome guides on this forum based on empirical evidence, for all sorts of things, but most guides are anecdotal and as far as I can tell there are none based on analysis of the RunUO source code that UOR is based on.

    Wanting to get past that recently to understand how to conserve resources while leveling a crafting skill, I dug into the code. What follows was what I found.

    TL;DR:
    1. For difficulty-based skills, your % chance to succeed at any given skill-attempt is a dominant factor as you get into the high numbers (at low numbers it's dominated by the skillgains just being very fast at low skill)
    2. The optimal % chance to succeed is 1/6, or about 16.66% (see attached graph)

    ANALYSIS
    The code which decides whether you'll gain on a given skill attempt is here: https://github.com/runuo/runuo/blob...0eb1499d3fe08/Scripts/Misc/SkillCheck.cs#L130
    I'll transcribe with some annotations
    // First bit
    double gc = (double)(from.Skills.Cap - from.Skills.Total) / from.Skills.Cap;

    // Second bit
    gc += ( skill.Cap - skill.Base ) / skill.Cap;
    gc /= 2;

    // Third bit
    gc += ( 1.0 - chance ) * ( success ? 0.5 : (Core.AOS ? 0.0 : 0.2) );
    gc /= 2;

    // Fourth bit
    gc *= skill.Info.GainFactor;
    The first bit has been explicitly refuted by Chris/Telamon, on this forum, as not being present on UOR. The effect there would've been to make skill gain slower the closer your base skill total is to 700.0.

    The second bit is straightforward. The effect, if it's active on UOR (and I believe it is), is to make skill gain much faster the lower your skill, regardless of your chance to succeed in the attempt.

    The third bit is the interesting part and the subject of this post, as it makes skill-gain a function of your % chance to succeed on the skill-attempt.
    This is not an AOS shard, so we can omit the Core.AOS ternary, leaving us with:
    (1.0 - chance) * (success ? 0.5 : 0.2)​
    And since we're interested in probability, not a single skill-check, we can get rid of the true/false "success" bit.... whatever our % chance to succeed is, we'll get 0.5 when we succeed and 0.2 when we fail. So replace the latter part with:
    ((chance * 0.5) + ((1-chance) * 0.2))​
    And overall we're left with:
    (1.0 - chance) * (0.5 * chance + (0.2 * (1 - chance)))​
    I wrote a program to simulate this, which produced the graph attached. Looking at the line, you'd be right to say "hey that's an upside-down parabola". And you'd be further right if you said "hey, if I found the peak of that parabola, wouldn't that be the optimal % success-chance for skill gain?".Rather than be a regular nerd and just use the program to tell me, I decided to use math for this part. First, I cross-multiplied everything out to give a more familiar polynomial:
    y = -0.3chance^2 + 0.1chance + 0.2​
    That let's us easily do a tiny bit of calculus here, applying the Power Rule to find the first derivative:
    y = -0.6chance + 0.1​
    If we find where that line crosses the X axis, we'll have the value of X where the parabola peaks. So we set y to 0, giving chance = 0.1 / 0.6, or 1/6, or about 16.66% chance to succeed.

    The fourth bit I'll cover in the next post, as "gainFactor" is a constant-- whether it's high or low doesn't have any bearing on how your % chance to succeed impacts your % chance to gain.

    Attached Files:

    Kiryana, Jill Stihl and Buga like this.

Share This Page