User:Salamangkero/Experiments

The UESPWiki – Your source for The Elder Scrolls since 1995
Jump to: navigation, search

<small> is faster than {{small}}[edit]

<small>[edit]

KJAH SDFH KLJH FAKL SDJH FAKL DSHF KJAD SHFL KJAN SDCJ NASO ERUH AUWO IYEF HADS CHNK SNCL KNAS JROR IEWU PIWE HJKF NBDS LKJV NKLA SDNF OHRF OIQP REWF HSAD KJVH AKSJ DNFP OQRE HFOI DSAP AKJS DHFK AJEH NFFA JKWH EFKJ ADSH CALS EKRY LCAM IWYR AMLX KERM HLAK SJDF AJSC NCMN ALSK DJFO QIWE URPO QYET UIRY HTJK DVNM CXZV NSMC FNLS AKFY JTQP OIRE UTPW EOIG SDKJ FVNB ZMCV NAMC SVNA QLKJ FOQI REUT WPOI RGKJ SDFH VNJC XZVN

CPU time usage 0.003 seconds 0.007 seconds 0.005 seconds 0.003 seconds 0.003 seconds
Real time usage 0.005 seconds 0.013 seconds 0.010 seconds 0.006 seconds 0.005 seconds

{{small}}[edit]

KJAH SDFH KLJH FAKL SDJH FAKL DSHF KJAD SHFL KJAN SDCJ NASO ERUH AUWO IYEF HADS CHNK SNCL KNAS JROR IEWU PIWE HJKF NBDS LKJV NKLA SDNF OHRF OIQP REWF HSAD KJVH AKSJ DNFP OQRE HFOI DSAP AKJS DHFK AJEH NFFA JKWH EFKJ ADSH CALS EKRY LCAM IWYR AMLX KERM HLAK SJDF AJSC NCMN ALSK DJFO QIWE URPO QYET UIRY HTJK DVNM CXZV NSMC FNLS AKFY JTQP OIRE UTPW EOIG SDKJ FVNB ZMCV NAMC SVNA QLKJ FOQI REUT WPOI RGKJ SDFH VNJC XZVN

CPU time usage 0.014 seconds 0.016 seconds 0.014 seconds 0.022 seconds 0.015 seconds
Real time usage 0.021 seconds 0.022 seconds 0.021 seconds 0.029 seconds 0.021 seconds

Conclusion[edit]

The experiment above used <small> and transcluded {{small}} only 83 times.

  • Using <small>, there was no need to transclude any template. Furthermore, it also does not result in any additional HTML code being generated.
<small>SMALL TEXT</small>
  • Transcluding the {{small}} template adds a small overhead when rendering, which becomes readily apparent with repeated transclusions. Each transclusion also results in more HTML code.
<span style="font-size: x-small">SMALL TEXT</span>

The difference between both approaches to small text is negligible for web browsers, mobile browsers and the UESP app. For wiki editors, I don't think maintainability and/or readability is negatively or significantly impacted, if at all, by using <small>. Thus, I would strongly recommend (eventually) phasing out the {{small}} template and replacing it with <small>. However, I must admit I have not yet evaluated either approach from an accessibility perspective; for example, will screen readers read small text differently for both cases?

Result[edit]

After revision 3030483, the template {{small}} now also uses <small>.

Repeated transclusions are slow[edit]

{{al}}, transcluded every time[edit]

A B C D E F G H I J K L
KJAH SDFH KLJH FAKL SDJH FAKL DSHF KJAD SHFL KJAN SDCJ NASO
ERUH AUWO IYEF HADS CHNK SNCL KNAS JROR IEWU PIWE HJKF NBDS
LKJV NKLA SDNF OHRF OIQP REWF HSAD KJVH AKSJ DNFP OQRE HFOI
DSAP AKJS DHFK AJEH NFFA JKWH EFKJ ADSH CALS EKRY LCAM IWYR
AMLX KERM HLAK SJDF AJSC NCMN ALSK DJFO QIWE URPO QYET UIRY
HTJK DVNM CXZV NSMC FNLS AKFY JTQP OIRE UTPW EOIG SDKJ FVNB
ZMCV NAMC SVNA QLKJ FOQI REUT WPOI RGKJ SDFH VNJC XZVN KJAH
SDFH KLJH FAKL SDJH FAKL DSHF KJAD SHFL KJAN SDCJ NASO ERUH
AUWO IYEF HADS CHNK SNCL KNAS JROR IEWU PIWE HJKF NBDS LKJV
NKLA SDNF OHRF OIQP REWF HSAD KJVH AKSJ DNFP OQRE HFOI DSAP
AKJS DHFK AJEH NFFA JKWH EFKJ ADSH CALS EKRY LCAM IWYR AMLX
KERM HLAK SJDF AJSC NCMN ALSK DJFO QIWE URPO QYET UIRY HTJK
DVNM CXZV NSMC FNLS AKFY JTQP OIRE UTPW EOIG SDKJ FVNB ZMCV
NAMC SVNA QLKJ FOQI REUT WPOI RGKJ SDFH VNJC XZVN
CPU time usage 0.053 seconds 0.032 seconds 0.032 seconds 0.055 seconds 0.032 seconds
Real time usage 0.062 seconds 0.040 seconds 0.039 seconds 0.063 seconds 0.039 seconds

{{al}}, assigned to a variable[edit]

A B C D E F G H I J K L
KJAH SDFH KLJH FAKL SDJH FAKL DSHF KJAD SHFL KJAN SDCJ NASO
ERUH AUWO IYEF HADS CHNK SNCL KNAS JROR IEWU PIWE HJKF NBDS
LKJV NKLA SDNF OHRF OIQP REWF HSAD KJVH AKSJ DNFP OQRE HFOI
DSAP AKJS DHFK AJEH NFFA JKWH EFKJ ADSH CALS EKRY LCAM IWYR
AMLX KERM HLAK SJDF AJSC NCMN ALSK DJFO QIWE URPO QYET UIRY
HTJK DVNM CXZV NSMC FNLS AKFY JTQP OIRE UTPW EOIG SDKJ FVNB
ZMCV NAMC SVNA QLKJ FOQI REUT WPOI RGKJ SDFH VNJC XZVN KJAH
SDFH KLJH FAKL SDJH FAKL DSHF KJAD SHFL KJAN SDCJ NASO ERUH
AUWO IYEF HADS CHNK SNCL KNAS JROR IEWU PIWE HJKF NBDS LKJV
NKLA SDNF OHRF OIQP REWF HSAD KJVH AKSJ DNFP OQRE HFOI DSAP
AKJS DHFK AJEH NFFA JKWH EFKJ ADSH CALS EKRY LCAM IWYR AMLX
KERM HLAK SJDF AJSC NCMN ALSK DJFO QIWE URPO QYET UIRY HTJK
DVNM CXZV NSMC FNLS AKFY JTQP OIRE UTPW EOIG SDKJ FVNB ZMCV
NAMC SVNA QLKJ FOQI REUT WPOI RGKJ SDFH VNJC XZVN
CPU time usage 0.017 seconds 0.011 seconds 0.012 seconds 0.028 seconds 0.011 seconds
Real time usage 0.023 seconds 0.019 seconds 0.019 seconds 0.040 seconds 0.018 seconds

{{subst:al|r}} or style=align:right[edit]

A B C D E F G H I J K L
KJAH SDFH KLJH FAKL SDJH FAKL DSHF KJAD SHFL KJAN SDCJ NASO
ERUH AUWO IYEF HADS CHNK SNCL KNAS JROR IEWU PIWE HJKF NBDS
LKJV NKLA SDNF OHRF OIQP REWF HSAD KJVH AKSJ DNFP OQRE HFOI
DSAP AKJS DHFK AJEH NFFA JKWH EFKJ ADSH CALS EKRY LCAM IWYR
AMLX KERM HLAK SJDF AJSC NCMN ALSK DJFO QIWE URPO QYET UIRY
HTJK DVNM CXZV NSMC FNLS AKFY JTQP OIRE UTPW EOIG SDKJ FVNB
ZMCV NAMC SVNA QLKJ FOQI REUT WPOI RGKJ SDFH VNJC XZVN KJAH
SDFH KLJH FAKL SDJH FAKL DSHF KJAD SHFL KJAN SDCJ NASO ERUH
AUWO IYEF HADS CHNK SNCL KNAS JROR IEWU PIWE HJKF NBDS LKJV
NKLA SDNF OHRF OIQP REWF HSAD KJVH AKSJ DNFP OQRE HFOI DSAP
AKJS DHFK AJEH NFFA JKWH EFKJ ADSH CALS EKRY LCAM IWYR AMLX
KERM HLAK SJDF AJSC NCMN ALSK DJFO QIWE URPO QYET UIRY HTJK
DVNM CXZV NSMC FNLS AKFY JTQP OIRE UTPW EOIG SDKJ FVNB ZMCV
NAMC SVNA QLKJ FOQI REUT WPOI RGKJ SDFH VNJC XZVN
CPU time usage 0.015 seconds 0.011 seconds 0.010 seconds 0.008 seconds 0.017 seconds
Real time usage 0.019 seconds 0.014 seconds 0.013 seconds 0.011 seconds 0.022 seconds

Conclusion[edit]

Repeated transclusions seem to be slower; need more measurements. If transcluding the same content over and over, consider either assigning it to a variable or using a substitution instead.

Full namespaces and shortened ones are equally fast[edit]

Full namespace[edit]

CPU time usage 0.127 seconds 0.101 seconds 0.094 seconds 0.103 seconds 0.098 seconds
Real time usage 0.206 seconds 0.175 seconds 0.175 seconds 0.186 seconds 0.169 seconds

Shortened namespace[edit]

CPU time usage 0.107 seconds 0.112 seconds 0.129 seconds 0.096 seconds 0.107 seconds
Real time usage 0.185 seconds 0.192 seconds 0.214 seconds 0.175 seconds 0.176 seconds

Conclusion[edit]

No significant difference found. I recommend using shortened namespaces but only because it results in shorter (and arguably more readable) wikitext.

{{Ingredient Entry}} fields can be overridden[edit]

Ingredient Description Effects Value Weight H%
Bread
ingred_bread_01_UNI2
Item ID can be overridden.
  1. Restore Fatigue
1 0.2 N/A
Diamond
ingred_Dae_cursed_diamond_01
Item ID and harvest data can be overridden.
  1. Drain Agility
  2. Invisibility
  3. Reflect
  4. Detect Key
250 0.2 N/A
Guar Vomit
ingred_preloved_01
Item ID, label and effects can be overridden.
  1. Bad Breath
  2. Purge Magicka
  3. Purify Curse
  4. Immunocompromise
0 0.1 N/A
Muffin
ingred_bread_01_UNI3
Ingredient data can be loaded from redirects with {{Ingredient Summary}}.
  1. Restore Fatigue
1 0.2 N/A

MW:Enchant Formula[edit]

Old vs. Current Enchant Formula[edit]

Saw this video, tried it on my own calculator (which is based on the current enchant formula in UESP) and got a different calculation. It's bothering me so, for starters, I'm testing the two known formulas against vanilla Morrowind.

Historically, there have been two enchant formulae:

  • The old enchant formula is based on the enchant simulator by user Kertaw48 (or vice-versa)
  • The current enchant formula was written by user Scientific Gamer, as a correction
Summon Ancestral Ghost on Self 1s 2s 3s 4s 5s 6s 7s 8s 9s 10s 11s 12s 13s 14s 15s 16s 17s 18s 19s 20s
Unmodded MW (GOTY) 1 1 1 1 1 2 2 2 3 3 4 4 4 5 5 5 6 6 6 7
Old Enchant Formula (1pt in 1ft) 0.44 0.79 1.14 1.49 1.84 2.19 2.54 2.89 3.24 3.59 3.94 4.29 4.64 4.99 5.34 5.69 6.04 6.39 6.74 7.09
Old Enchant Formula (1pt in 0ft) 0.35 0.70 1.05 1.40 1.75 2.10 2.45 2.80 3.15 3.50 3.85 4.20 4.55 4.90 5.25 5.60 5.95 6.30 6.65 7.00
Current Enchant Formula (1pt in 1ft) 0.53 0.88 1.23 1.58 1.93 2.28 2.63 2.98 3.33 3.68 4.03 4.38 4.73 5.08 5.43 5.78 6.13 6.48 6.83 7.18
Current Enchant Formula (1pt in 0ft) 0.35 0.70 1.05 1.40 1.75 2.10 2.45 2.80 3.15 3.50 3.85 4.20 4.55 4.90 5.25 5.60 5.95 6.30 6.65 7.00

Okay, so for a single enchantment, assuming the total enchant cost is truncated (ie. floored / rounded down), it seems the current enchant formula is correct... so far. In a later section, we'll see how it fares against multiple enchantments, that is, when compounded multipliers come into play.

Experiment: Min-1 Rule[edit]

Enchantments, no matter how cheap, cost a minimum of 1 charge. When is this rule applied?

  • Is it applied to the total enchantment cost?
  • Or is it applied per spell effect? In which case, is it applied before or after the spell effect's cost is compounded?

For this experiment, we're working with the unmodified costs per spell effect, that is, we don't want to factor in the effects of either rounding or truncating. We're using cheap spell effects so everything rounds down and truncates to zero.

MW (GOTY) Total: 5
M Spell Effect Cost Just Compounded Min-1 then Compound Compound then Min-1
1 Detect Animal 1s 1pt on Self 0.06 0.06 1.0 1.0
2 Fortify Fatigue 1s 1pt on Self 0.04 0.08 2.0 1.0
3 Resist Paralysis 1s 1pt on Self 0.02 0.06 3.0 1.0
4 Light 1s 1pt on Self 0.02 0.08 4.0 1.0
5 Night Eye 1s 1pt on Self 0.02 0.10 5.0 1.0
Total 0.38 15.0 5.0

Well, that was fairly straightforward. The per-effect cost is compounded, then set to a minimum of 1, then summed to get the final enchantment cost.

Experiment: Two Enchantments, Part One[edit]

Unmodded MW
(GOTY)
1st: Summon Ancestral Ghost on Self (x2)
1s 2s 3s 4s 5s 6s 7s 8s 9s 10s
2nd: 1pt Fire Damage on Touch (x1)
1s 2 2 2 2 3 4 5 5 6 7
2s 2 2 2 3 3 4 5 5 6 7
3s 2 2 3 3 3 5 5 5 7 7
4s 3 3 3 3 4 5 5 5 7 7
5s 3 3 3 3 4 5 6 6 7 8
6s 3 3 3 4 4 5 6 6 7 8
7s 3 3 4 4 4 6 6 6 8 8
8s 4 4 4 4 5 6 6 7 8 8
9s 4 4 4 4 5 6 7 7 8 9
10s 4 4 4 5 5 6 7 7 8 9
Current Enchant Formula
(truncate, compound, min-1, then sum)
1st: Summon Ancestral Ghost on Self (x2)
1s 2s 3s 4s 5s 6s 7s 8s 9s 10s
2nd: 1pt Fire Damage on Touch (x1)
1s 2 2 3 3 3 5 5 5 7 7
2s 2 2 3 3 3 5 5 5 7 7
3s 2 2 3 3 3 5 5 5 7 7
4s 2 2 3 3 3 5 5 5 7 7
5s 2 2 3 3 3 5 5 5 7 7
6s 2 2 3 3 3 5 5 5 7 7
7s 2 2 3 3 3 5 5 5 7 7
8s 3 3 4 4 4 6 6 6 8 8
9s 3 3 4 4 4 6 6 6 8 8
10s 3 3 4 4 4 6 6 6 8 8

Obviously, the outcomes are different. I have some hypotheses:

  • the order of compounding, min-1, summation and truncation are incorrect, and/or
  • the game might be rounding instead of truncating, and/or
  • the game might be rounding / truncating to the nearest 0.1

As already established in the previous section, min-1, happens after compounding. Thus, for the following experiments,

I'm assuming the following order of operations:

  • Calculate cost-per-spell-effect as n
  • α(n)
  • Multiply n by i
  • β(n)
  • Set the minimum of n to 1
  • Get the total of n1…i
  • γ(n)
  • The end result is Cx,y

where:

  • α, β and γ are functions that:
    • does nothing,
    • floors / truncates n, or
    • rounds n to the nearest integer.
  • i is the number of enchantments.
  • Cx,y is the total cost of the following enchantment:
    • Summon Ancestral Ghost for x seconds on Self (first effect, x2)
    • 1pt Fire Damage for y seconds on Touch (second effect, x1)

and we're only comparing twenty values:

  • C1,1 to C10,1, and
  • C1,10 to C10,10

because we don't need to generate 100 values for every experiment (yet).

α β γ C1…10,1 C1…10,10
Morrowind (GOTY) 2 2 2 2 3 4 5 5 6 7 4 4 4 5 5 6 7 7 8 9
none none / floor(0.1) / round(0.1) none / floor(0.1) / round(0.1) 2.0 2.7 3.4 4.1 4.8 5.5 6.2 6.9 7.6 8.3 3.6 4.3 5.0 5.7 6.4 7.1 7.8 8.5 9.2 9.9
none none / floor(0.1) / round(0.1) floor 2 2 3 4 4 5 6 6 7 8 3 4 5 5 6 7 7 8 9 9
none none / floor(0.1) / round(0.1) round 2 3 3 4 5 6 6 7 8 8 4 4 5 6 6 7 8 9 9 10
none floor any 2 2 3 4 4 5 6 6 7 8 3 3 4 5 5 6 7 7 8 9
none round any 2 3 3 4 5 6 6 7 8 8 4 5 5 6 7 8 8 9 10 10
floor any any 2 2 3 3 3 5 5 5 7 7 3 3 4 4 4 6 6 6 8 8
floor(0.1) none / floor(0.1) / round(0.1) none / floor(0.1) / round(0.1) 2.0 2.6 3.4 4.0 4.8 5.4 6.2 6.8 7.6 8.2 3.6 4.2 5.0 5.6 6.4 7.0 7.8 8.4 9.2 9.8
floor(0.1) none / floor(0.1) / round(0.1) floor 2 2 3 4 4 5 6 6 7 8 3 4 5 5 6 7 7 8 9 9
floor(0.1) none / floor(0.1) / round(0.1) round 2 3 3 4 5 5 6 7 8 8 4 4 5 6 6 7 8 8 9 10
floor(0.1) floor any 2 2 3 4 5 6 6 7 8 3 3 4 5 5 6 7 7 8 9
floor(0.1) round any 2 3 3 4 5 5 6 7 8 8 4 5 5 6 7 7 8 9 10 10
round any any 3 3 3 5 5 5 7 7 7 9 5 5 5 7 7 7 9 9 9 11
round(0.1) none / floor(0.1) / round(0.1) none / floor(0.1) / round(0.1) 2.0 2.8 3.4 4.2 4.8 5.6 6.2 7.0 7.6 8.4 3.6 4.4 5.0 5.8 6.4 7.2 7.8 8.6 9.2 10.0
round(0.1) none / floor(0.1) / round(0.1) floor 2 2 3 4 4 5 6 7 7 8 3 4 5 5 6 7 7 8 9 10
round(0.1) none / floor(0.1) / round(0.1) round 2 3 3 4 5 6 6 7 8 8 4 4 5 6 6 7 8 9 9 10
round(0.1) floor any 2 2 3 4 4 5 6 7 7 8 3 3 4 5 5 6 7 8 8 9
round(0.1) round any 2 3 3 4 5 6 6 7 8 8 4 5 5 6 7 8 8 9 10 10

None of them matched! That stretch of 2's in C1…4,1 and that stretch of 4's in C1…3,10 are both very challenging to replicate.

Oh well, let's keep trying!

Experiment: Two Enchantments, Part Two[edit]

I'm working with two assumptions in this section:

  • The game engine uses precision of up to 0.1, so we'll disregard floor(1) and round(1) functions for α.
  • What if it's min-n after summation and not min-1 after compounding?
α β γ C1…10,1 C1…10,10
Morrowind (GOTY) 2 2 2 2 3 4 5 5 6 7 4 4 4 5 5 6 7 7 8 9
none none none 1.43 2.13 2.83 3.53 4.23 4.93 5.63 6.33 7.03 7.73 3.68 4.38 5.08 5.78 6.48 7.18 7.88 8.58 9.28 9.98
none floor(0.1) none 2.0 2.0 2.7 3.4 4.1 4.8 5.5 6.2 6.9 7.6 3.6 4.3 5.0 5.7 6.4 7.1 7.8 8.5 9.2 9.9
none floor none 2 2 2 3 3 4 5 5 6 7 3 3 4 5 5 6 7 7 8 9
none round(0.1) none 2.0 2.2 2.9 3.6 4.3 5.0 5.7 6.4 7.1 7.8 3.7 4.4 5.1 5.8 6.5 7.2 7.9 8.6 9.3 10.0
none round none 2 2 2 3 4 5 5 6 7 7 4 5 5 6 7 8 8 9 10 10
floor(0.1) none / floor(0.1) / round(0.1) none 2.0 2.0 2.7 3.3 4.1 4.7 5.5 6.1 6.9 7.5 3.6 4.2 5.0 5.6 6.4 7.0 7.8 8.4 9.2 9.8
floor(0.1) floor none 2 2 2 3 3 4 5 5 6 7 3 3 4 5 5 6 7 7 8 9
floor(0.1) round none 2 2 2 3 4 4 5 6 7 7 4 5 5 6 7 7 8 9 10 10
round(0.1) none / floor(0.1) / round(0.1) none 2.0 2.2 2.8 3.6 4.2 5.0 5.6 6.4 7.0 7.8 3.6 4.4 5.0 5.8 6.4 7.2 7.8 8.6 9.2 10
round(0.1) floor none 2 2 2 3 3 4 5 6 6 7 3 3 4 5 5 6 7 8 8 9
round(0.1) round none 2 2 2 3 4 5 5 6 7 7 4 5 5 6 7 8 8 9 10 10

Still trying!

Experiment: Two Enchantments, Part Three[edit]

What if the folks at OpenMW have truly cracked the formula? Confirmed! So they have!

Conclusion[edit]

There is no "formula"; just an algorithm, a chain of conditional / piece-wise functions. Also, there is no order-based "multiplier"; just an integer accumulator in a process that works on floats. A bug. A weed. A piece of dust. Busy, busy, busy.

What next?[edit]

This is going to be challenging. Can we come up with an accurate but also accessible write-up for non-coders / non-maths? Lemme try...

  • area, max and min all have a minimum of 1; they can never be zero
  • duration is set to 100 if Constant Effect; has a minimum of 1, otherwise

For every spell effect, its per-effect cost is first calculated as: (((min+max) × duration) + area) × base cost / 40

Next, the corresponding compounded costs are calculated:

  1. For the first spell effect's per-effect cost:
    • it is set to 1.0, if it is less than 1.0
    • it is then multiplied by 1.5, if it is on Target
    • it is finally truncated into an integer (i.e. all digits to the right of the decimal point are removed)
  2. For subsequent spell effects' per-effect costs:
    • the sum of the preceding compounded costs is added to it first
    • then it proceeds in the same manner (i.e. set to minimum of 1, apply range multiplier and truncated)

Finally, the cost of the whole enchantment is computed as the total of the compounded costs.

  • It is the minimum enchantment points required of the armor, clothing or weapon, which is intended to hold the enchantment
  • It is also the minimum size required of the soul, which is intended to power the enchantment
    • For Constant Effect enchantments, however, a soul size of 400 or higher is required, regardless of the actual enchantment cost.

Okay, that sucks. It might be challenging in the absence of examples, which "normal" readers can follow. I'll see what I can come up with later.

Sorting Number Ranges[edit]

When dealing with number ranges, sorting defaults to alphabetical order, which results in sorting by the min value first, then sorting by the max value. I think a more sensible sort key would be the average of the two.

Name ID Chop Slash Thrust
Imaginary Spear imaginary spear 1-1 1-1 7-7
Chitin Spear Chitin Spear chitin spear 1-2 1-2 5-13
Iron Spear Iron Spear iron spear 2−4 2−4 6−15
Iron Spear Iron Spear Iron Long Spear 1-3 1-3 5−20
Steel Spear Steel Spear steel spear 2−5 2−5 6−17
Iron Halberd Iron Halberd iron halberd 1−3 1−3 5−20
Steel Halberd Steel Halberd steel halberd 1−4 1−4 5−23
Silver Spear Silver Spear silver spear 1−4 1−4 5−23
Dwarven Spear Dwarven Spear dwarven spear 2−5 2−5 5−21
Dwarven Halberd Dwarven Halberd dwarven halberd 3−17 1−13 5−28
Ebony Spear Ebony Spear ebony spear 2−8 2−8 5−32
Glass Halberd Glass Halberd glass halberd 1−6 1−6 5−38
Daedric Spear Daedric Spear daedric spear 2−9 2−9 6−40