27 August, 2010

About the Artemis' Medal

One of the new items brought about by the version update that introduced Abyssea and raised the level cap to 80 was an Artemis' Medal,

The Artemis' Medal drops from Cannered Noz, a force-pop NM in Abyssea-Tahrongi.

The Bluegartr forums had a quick post that documented some of the testing behind the medal- namely how much MAB it gives based on the moon phase. They were pretty spot on, but the testing seemed to be left incomplete. There was also a lot of conflicting information regarding how the medal worked on other websites, like FFXIclopedia and FFXIah, so this was an open invitation to complete the test and set some numbers straight.

I won't bore you with the details of the testing, but the results can be summarized with the following diagram:
Some points to take note:
  • The MAB gains is not tied to the actual moon percentage, but is instead linked to the moon phase.
  • Both Gibbous and Crescent stages are split into two moon phases, but the in-game command, /clock does not differentiate between the two.

As of now, this is the best neckpiece for damage in the game, of course, depending on the moon phase. After all, +10 MAB is nothing to scoff at, even if it doesn't happen all that often.

But we don't want to carry around situational pieces of equipment like this, so how does it interact with the other neckpieces in the game, namely the Uggalepih Pendant and Goetia Chain? (Or if you're RDM or SCH, Lemegeton Medallion +1).

Based on my previous post comparing INT and MAB, I know that (at least for me) 1MAB is roughly equal to 1INT. Using this as a rough guide, we can say that Goetia Chain adds roughly 3.8MAB, while Lemegeton Medallion +1 adds roughly 2.7MAB.

From here, the analysis is easy- Artemis Medal is king until the MAB bonus reaches +6, where you will want to start swapping in Uggalepih Pendants. After that, you will continue using Artemis' Medal until the MAB bonus reaches +3 before swapping in Goetia Chain, or +1 before swapping in Lemegeton Medallion +1. Still, notice that even against a Goetia Chain, an Artemis' Medal will still be better more than half (7/12ths) the time!

That's all fine and dandy, but the next question comes from all Spellcast users- how do I script all this?
Unfortunately, the designers up in Square-Enix and their infinite wisdom (/sarcasm) made it such that the moon cycle is not actually symmetric. That is to say, if you wanted to use the moon percentage to determine which neckpiece to use, there isn't actually a set number. The last day on the Early Waxing Gibbous has a moon phase of 71% and the first day of the Late Waxing Gibbous has a moon phase of 74%. The problem is, the last day of Early Waning Gibbous is at 79%, while the first day of Late Waning Gibbous is 76%, so no matter what number you pick, you will miss out on some optimization somewhere.

In pseudocode, the process might look something like this:

equip "Artemis' Medal"

if(moonphase < 73)
   if(moon phase < 30)
      equip "Goetia Chain"

   if(MP after cast < 50%)
      equip "Uggalepih Pendant"

As for the actual code, well, I'll figure this xml jazz out eventually. :)

Of course, adjust the numbers if you're not using a Goetia Chain. In addition, I haven't quite pinned down the transition times between Waning Crescent or Waxing Crescent subphases, so that's something to look out for.

30 April, 2010

Calculus & FFXI II -- Haste vs Enmity

I was browing around the forums, when I came across this Allakhazam post, where the OP poses the following question:
For a long time now, I have been using a full enmity set for casting Flash to maximize as much hate as I can get out of flash. However, I am curious, over the course of an extended fighting session, say HNM/God/Ground king/Omega etc, would it be mathematically better to use Haste when Flashing?
Judging from the responses, the general consensus is to emphasize Haste over Emnity. This would probably be true based on observation.

We would like to give mathematical support to verify this claim.

But before we start, we need to establish how Enmity works, and how +Enmity and +Haste affect your overall enmity gain.

Once again, if the equations don't display properly, your browser is probably blocking the HTML or Java script that takes the code and turns it into equations.

Enmity 101
In late 2007, Kaeko (of Odin) began a series of tests to break down and analyze exactly how Enmity (also commonly referred to as just "hate") works. I won't go over the whole series, but to briefly summarize the basics,

Enmity has two components:-
  • Cumulative Enmity (CE)-- Enmity that does not decay over time, but instead decays when you take damage.
  • Volatile Enmity (VE)-- Enmity that naturally decays over time, and is not reduced through taking damage.
The sum of a person's CE and VE is that person's Total Enmity (TE), and the one with the highest TE value "has hate" (i.e. the mob goes after that person).

Both CE and VE share the same base unit of measurement (E), defined as "the enmity generated by casting Cure 1 for 0HP," and each is capped at 10,000E. Therefore, there is an overall "hate cap" at 20,000E.

The goal would be to reach this hate cap as fast as possible, and once you have reached the cap, maintain it.

Constructing the model
For any particular action, be it Flash, Provoke, Dispel, or what-have-you, the Total Enmity, $E$ that you gain as a result of performing that action can be thought of as a function of one variable, that variable being the total +Enmity from your gear and merits ($e$) that modifies the base enmity gain ($e_0$). Notice that I said a function of one variable, even though $e$ and $e_0$ both appear in the equation, but because I am talking about a specific action here, $e_0$ is really a constant.

+Enmity is a straight percentage increase over the base enmity gain, so

\[E(e)=e_0(1+\frac{e}{100})=\frac{e_0 (100+e)}{100}\]
(As documented by Kaeko, here.)

Similarly, your recast, $R$, can be thought of as a function of haste ($h$) that acts upon the base recast time, $r_0$:

\[R(h)=r_0(1-\frac{h}{100})=\frac{r_0 (100-h)}{100}\]
(As documented by Kirschy, here.)

Now that we've got some quantities, it's important to be clear what exactly we want to model. Since one of a tank's main goals is to maximize the amount of Enmity they have, you could just model the current amount of Enmity a tank currently has as a function of time, and maximize that. However, there are several complications in doing so, including taking enmity decay into account, not to mention that such a function is not even continuous.

We can accomodate for all that with the appropriate substitutions, but the question is whether all that is actually relevant to our problem.

Sure, we'd like to maximize the amount of Enmity that we have, but we don't consider Enmity's rate of decay when choosing what gear to wear. Instead, we load up on +Enmity and +Haste gear, and aim to generate as much enmity as we can, with as low a recast as possible.

That is to say, the quantity that we really want to maximize is not the actual amount of enmity we have, but rather the enmity generated per unit time, or the rate at which we generate enmity.

This is thankfully much simpler to model, and is the classic "rise over run" function:

\[f(e,h)=\frac{E(e)}{R(h)}=\frac{e_0 (100+e)}{r_0 (100-h)}\]
Now that we have the quantity we want to maximize, it's time to use calculus.

In order to answer the OP's question, we want to see how the rate at which we generate enmity, $f(e,h)$ changes as we change either $e$ or $h$. We can then analyze the resulting quantities to hopefully establish a relationship between the two.

So, in order to approximate how the rate changes as I change one of the input variables, I first compute the partial derivaties:

First, the partial with respect to $e$:
\[\frac{\partial f}{\partial e}=\frac{e_0}{r_0 (100-h)}\]
Then the partial with respect to $h$ (this one uses the product rule):
\[\frac{\partial f}{\partial h}=\frac{e_0 (100+e)}{r_0 (100-h)^2}\]
Notice then, that
\[\frac{\partial f}{\partial h}=\frac{100+e}{100-h}\frac{e_0}{r_0 (100-h)}\]
\[\frac{\partial f}{\partial h}=\frac{100+e}{100-h}\frac{\partial f}{\partial e}\]

Recall that the two partial derivatives approximate the incremental gain in the rate of enmity generation as we increase either +Enmity or +Haste.

Thus, if $(100+e)/(100-h)>1$, that means that $\partial f/\partial h > \partial f/\partial e$, so +Haste has more impact than +Enmity on the rate of enmity generation.

Conversely, if $(100+e)/(100-h)<1$, then $\partial f/\partial h < \partial f/\partial e$, so +Enmity will have more impact than +Haste on the rate of enmity generation.

Clearly, that fraction acts as a boundary of sorts that separates the two cases, and in order to get an idea of what this boundary looks like, we set the two partial derivatives to be equal. So,

This is thankfully simple, although you might expect such a simple relationship, since both +Enmity and +Haste act on the base enmity and recast time in a similar way. In any case, the relationship can be illustrated using a graph as follows:

Thus, we get the following conclusion:

If the sum of your +Enmity and +Haste is greater than 0, you will gain more by increasing +Haste over +Enmity.
Otherwise, if the sum of your +Enmity and +Haste is less than 0, you will gain more by increasing +Enmity over +Haste.

Since the vast majority of Paladins out there (hopefully) have a positive sum of +Enmity and +haste, this analysis shows that you will benefit from increasing +Haste over +Enmity the vast majority of the time.
 (Q.E.D. ^^)

Further questions and limitations
While the simple analysis above illustrates that +Haste should generally be prioritized over +Enmity, it only tells us that the gains from +Haste is more than +Enmity. What it doesn't tell us is how much better +Haste is over +Enmity, under given conditions.

So while we can say +Haste is generally better than +Enmity, the only way we have right now to compare two pieces of gear against each other would be to plug the values into $f(e,h)$ and see what numbers come out.

Since the function is simple enough to compute numerically, I won't go down that line for now, and is not a typically asked question, anyway. But if you wanted to, you can simply repeat the analysis I did on INT vs MAB to better understand the relationsihp between +Enmity and +Haste.

More importantly, understand that this model only captures a small part of tanking mechanics-- the first part where the goal is to generate as much Enmity as you can, as quick as you can. This would be fine if there weren't a cap to the amount of CE and VE a player can have, but there is, and this analysis does not directly apply to the latter part of tanking, which focuses on maintaining the hate cap after it has been established.

Fortunately, that analysis is also simple, since any extra Enmity over the cap is effectively wasted, your focus now shifts to just trying to use your actions with as high a frequency as possible, so stack +Haste all the way.

More importantly, this analysis does not actually tell you how to tank. For example, a new RDM tank may misinterpret this analysis and believe that all they need to do is stack up on +Enmity and +Haste and spam Blind until the cows come home, not realising that Blind does not have a CE component-- thus once that RDM's VE is capped, all Blind does is re-establish the VE cap, but does nothing for CE!

In other words, the mathematics and formula in this case are used to manipulate known data to illustrate and verify a claim that we've already known. It will not make you a better player, not will it make you a better tank.

All it is is solid verification, a proof per se, and to some the proof is really what it's all about.