# Talk:MP

Martavius has asked "How do you calculate MP?" by adding the question in a Needs Work template. I've removed the Needs Work because I suspect that the question should be here in the talk section, but I'm not really sure what Martavius is asking. Martavius, can you clarify? --Gymnosophist 14:26, 29 Jul 2005 (Central Daylight Time)

• I believe he means what formula you use to calculate your amount of MP based on your Mys, and other factors (if there are other factors). --Pcentella 19:40, 31 Jul 2005 (Central Daylight Time)
• I don't know the answer to this one - does anyone else? --Gymnosophist 23:08, 31 Jul 2005 (Central Daylight Time)

Shouldn't the minus mp items (like stainless steel solitaire i believe) be here? --Kookoo275 11:19, 14 May 2006 (CDT)

From Dornbeast on forums, tweaked & checked by DirkDiggler:

 MP: =CEILING(FLOOR( Max[ (FLOOR(M*C)+P), FLOOR(m)   ] *W)*G)
where
or your buffed Moxie with travoltan trousers and moxie > myst,
or your buffed Moxie with a moxie magnet.
C is 1.5 if you are a Myst class (1 for other classes),
P is any direct MP Modifiers you have (e.g. bejeweled accordion strap),
W is 1.5 if you have Wisdom of the Elder Tortoises (1 if you don't), and
G is 1.05 if you have Cosmic Ugnderstanding (1 if you don't).


Note that a moxie magnet can reduce your MP but travoltan trousers cannot. --DirkDiggler 21:45, 2 November 2006 (CST)

• Fixed this one as well, according to my work here --Salien 20:45, 11 February 2008 (CST)

--Eliza Dane 06:32, 4 August 2008 (CDT) The formula on the article page is incorrect. As a level 10 Pastamancer I had following values:

G = 1.0 (no Cosmic Ugnderstanding)
W = 1.5 (with Wisdom of the Elder Tortoises)
C = 1.5 (Mysticality class)
P = 0.0 (No MP increasers)
m = 91 (base mysticality)


I was influenced by following (relevant) effects:

Confused (-30% Mysticality)
Pasta Oneness (+2 Mysticality)
Strange Mental Acuity (+25% Mysticality)


(Indeed, I just checked the bang-potions).

This resulted in a buffed mysticality: M = 89 (reported by the game).

Now without any armour (P = 0) the game computed 199 MP, but the given formula (as implemented in a computer program) calculates 204 MP.

As soon as I equipped enough Mysticality to compensate for the net negative mysticality effect of my effect (the Dolphin King's Crown was sufficient) the game and the formula produced identical results.

This suggests that the formula should be Max MP =

 CEILING(
G × FLOOR(
W ×
FLOOR(M × C) + P
)


 CEILING(
G × FLOOR(
W × MAXIMUM(
FLOOR(M × C) + P,
FLOOR(m × C)
)
)


If anybody has evidence that the clause FLOOR(m × C) is (still) involved, please post it here. Maybe we can produce a better formula.

FLOOR(m x C) does apply (it's easily exhibited by a high-level myst class with a moxie magnet equipped), but the formula has it in the wrong place - it bypasses all the percentage boosts, not just the additive ones. The only boost that still applies to mxC is Slimy Synapses, which the current formula doesn't properly handle at all. Will fix... --Jasonharper 02:22, 15 July 2009 (UTC)

## Marginally Insane

158 Mysticality. No +MP effects. If Marginally Insane would stack with a floor of Ugnderstanding and Wisdom, you would recieve 273 MP. If it instead goes with a ceiling, it would be 274 MP. I ended with 274 MP, so it appears the only time floor is used is for the wisdom calculation. My calculations are below. --Toffile 05:49, 4 December 2008 (UTC)

M =

158

>> G=1.05

G =

1.0500

>> W=1.5

W =

1.5000

>> I=1.1

I =

1.1000

>> ceil(G*floor(I*floor(W*M)))

ans =

273

>> ceil(I*floor(G*floor(W*M)))

ans =

273

>> ceil(G*floor(I*floor(W*M)))

ans =

273

>> G*floor(I*floor(W*M))

ans =

273

>> G*ceil(I*floor(W*M))

ans =

274.0500

>> floor(G*ceil(I*floor(W*M)))

ans =

274

>> floor(I*ceil(G*floor(W*M)))

ans =

273

>> ceil(I*ceil(G*floor(W*M)))

ans =

274

>> ceil(I*G*floor(W*M))

ans =

274

## Formula still incorrect

I found that the formula for maximum MP given on the WIKI is not quite right. An example where the WIKI formula fails is with data: 70, 75, 1.0, 0, 5, 1.5, 1.05, 1.0 (for int M, int m, double C, int S, int P, double W, double G, double I) In this case the WIKI formula returns 116, the game returns 118). The formula that (until now and on three different characters) has always coincided with the game is the following:

   return S + (int)Math.max(Math.floor(m * C),
Math.ceil(
I * (
Math.ceil(G * Math.floor(W *
(
Math.floor(M * C) + P
))))));


Because I am unable to vary 'I' (and because my last update was incorrect :)) it put this on the discussion page instead of the main page for independant verification. Eliza Dane 10:02, 19 November 2009 (UTC)

Hmm.. Well.. The wiki formula returns exactly what the game does for your numbers.. let me demonstrate.

 formula = slime + max(floor(base*class),
ceil(insane*ceil(gnome*floor(wisdom*(floor(buffed*class)+extra)))))


Java code, if it wasn't abundantly obvious:

 public static void mp_formula() {
int buffed = 70;
int base = 75;
double _class = 1.0;
double insane = 1.0;
double gnome = 1.05;
double wisdom = 1.5;
int extra = 5;
int slime = 0;

double _base_class = base*_class;
int base_class = (int)Math.floor(_base_class);

double _buffed_class = buffed*_class;
int buffed_class = (int)Math.floor(_buffed_class);
int with_extra = buffed_class + extra;

double _with_wisdom = wisdom*with_extra;
int with_wisdom = (int)Math.floor(_with_wisdom);

double _with_gnome = gnome*with_wisdom;
int with_gnome = (int)Math.ceil(_with_gnome);

double _with_insane = insane*with_gnome;
int with_insane = (int)Math.ceil(_with_insane);
int MP = slime + Math.max(base_class, with_insane);

System.out.println("Floor(base * class) = Floor(" + _base_class +"): " + base_class);
System.out.println("----");
System.out.println("Floor(buffed * class) = Floor(" + _buffed_class +"): " + buffed_class);
System.out.println("with extra: " + with_extra);
System.out.println("Floor(with wisdom) = Floor(" + _with_wisdom +"): " + with_wisdom);
System.out.println("Ceil(with gnome) = Ceil(" + _with_gnome +"): " + with_gnome);
System.out.println("Ceil(with insane) = Ceil(" + _with_insane +"): " + with_insane);

System.out.println("MP: " + MP);
}


I am seeing the following output:

Floor(base * class) = Floor(75.0): 75
----
Floor(buffed * class) = Floor(70.0): 70
with extra: 75
Floor(with wisdom) = Floor(112.5): 112
Ceil(with gnome) = Ceil(117.60000000000001): 118
Ceil(with insane) = Ceil(118.0): 118
MP: 118


So no.. I don't know what you think is incorrect, but.. the wiki formula does match the game's output. --MindlessGames 10:40, 19 November 2009 (UTC)

• Furthermore.. on my character right now, who has m=69, M=116, C=1.5, I=1.1, G=1.05, W=1.5, P=0, and S=10, the game shows 313 max MP, and the wiki formula shows 313 max MP. Maybe you're getting some funky floating-point error somewhere? --MindlessGames 10:54, 19 November 2009 (UTC)

You may have found a DIFFERENT way to fix the problem, but you also use a formula that is different from the one on the main page :) In your terminology: you add extra BEFORE multiplying with wisdom. In other words, you have computed: Max MP =

 S +
MAXIMUM(
FLOOR(m × C),
CEILING(
I x CEILING(
G x FLOOR(
W × (FLOOR(M × C) + P)
)
)
)
)


 S +
MAXIMUM(
FLOOR(m × C),
CEILING(
I x CEILING(
G x FLOOR(
W × FLOOR(M × C) + P
)
)
)
)


Note that both in standard arithmetic and in (most?) computer languages the multiplication operator binds stronger than the addition operator. Eliza Dane 11:47, 19 November 2009 (UTC)

• Huh.. You are correct. I have always included the extra before multiplying by wisdom, and it has always given me the correct value. The precise reason for this is because if you put on an item that gives you +40 MP, and your only skill is Wisdom, you will get +60 MP from it. I noticed this a very long time ago, and I guess I just glazed over the MP formula and read what I wanted to read, rather than what was there. The same thing happens with the HP formula, adding something like.. bejeweled pledge pin when your only skill is Spirit of Ravioli gives 50 HP, not 40. --MindlessGames 12:05, 19 November 2009 (UTC)

Thanks, this gave me the confidence to actually change the formula on the main page. I have taken your version instead of my own. I also incorporated the results of Toffile above, although I am unable to verify that myself. Eliza Dane 12:14, 19 November 2009 (UTC)

## And another bug

There is another bug in the formula (I am currently executing a program that wears every piece of equipment, then checks if the game results correspond to the formula and then removes the equipment again) The bug occurs with data 265, 267, 1.5, 0, 0, 1.0, 1.0, 1.0 (for int M, int m, double C, int S, int P, double W, double G, double I): a character only wearing the Orcish baseball cap and having the Saucemastery effect. The formula on the main page returns 400, but the game returns 397. This probably means that the maximum operator is in the wrong location or has an incorrect first operand (the first operand evaluates to 400, the second to 397). It this moment I do not have a clue yet about how to fix this. Any help is appreciated. Eliza Dane 13:41, 19 November 2009 (UTC)

• Hmm... that is a curiosity. Perhaps try to see how de-buffed you need to be before the base Myst takes over? --MindlessGames 14:41, 19 November 2009 (UTC)

I found how to fix the second bug in the formula. The first operand for the max operator must be plain m (instead of m * C): not even the class correction kicks in. This is easily tested with a mysticality class character that has Sugar Rush and Confused. You can then equip/unequip some items that slightly modify mysticality to see that MP stays firmly on the value of your unbuffed mysticality. With data 163, 269, 1.5, 0, 0, 1.0, 1.0, 1.0 or 173, 269, 1.5, 0, 0, 1.0, 1.0, 1.0 the game returns 269. Will fix. Eliza Dane 19:38, 20 November 2009 (UTC)

I would not be surprised if even the S correction must be moved to the second part of the maximum operator, but I am currently unable to test that. Eliza Dane 19:45, 20 November 2009 (UTC)

## Class differences?

It looks like the formula on the main page is fine for mysticality classes, but that non-mysticality classes must be computed differently. The formula for non-mysticality classes is probably S + (int)Math.ceil(I * Math.ceil(G * Math.floor(W * Math.max(M + P, m)))) Still verifying this. With data 97, 102, 1.0, 0, 0, 1.5, 1.05, 1.0 or 92, 102, 1.0, 0, 0, 1.5, 1.05, 1.0 the game returns MP 161 in both cases. Eliza Dane 11:45, 21 November 2009 (UTC)

## Rounding errors

If you apply this or similar formulas by hand, you may get a slightly different result than the game; this is not (necessarily) a problem with the formula. Case in point: a Sauceror with exactly 1000 buffed Myst, Wisdom, Marginally Insane, and +760 in MP bonuses. The formula gives a value of exactly 3729, but the game says 3730...

The problem is at the step where you calculate CEILING(1.1 * 3390). Mathematically, that's exactly 3729, and the rounding applied does nothing. However, computers don't handle non-integer values exactly; in the interests of efficiency, they normally represent such values in a binary floating-point format, that is unable to represent certain values such as 1.1 exactly. (It's the same reason why you can't exactly represent the value 1/3 as a decimal number; you have to truncate the infinite series of 3s at some point, introducing an error.) The closest floating-point approximation to 1.1 has an actual value of 1.1000000000000001, so the result of the multiplication is something like 3729.0000000000005, which CEILING() then rounds up to 3730.

The moral of the story is: to exactly duplicate the game's calculations, you have to perform calculations in the same domain - which appears to be double-precision (64 bit) floats (single-precision floats would also give a non-matching answer in this case). --Jasonharper 20:34, 3 April 2010 (UTC)

• "Lies My Calculator Told Me" was covered in my math classes in high school. If you don't know it, your favorite search engine can find it, where "it" is the concept explained, not a specific screed. --Club (#66669) (Talk) 06:08, 4 April 2010 (UTC)

## New Formula

I've tested this on a few different characters and the formula is working, except for that +3 Myst bonus. A DB with 127 Myst and 55%/+20 in bonuses has 217 MP instead of the expected 222. A PM with 780 Myst and no other bonuses has 1170 instead of 1175. An AT with no bonuses at all and 72 Myst has 72 MP. --TechSmurf 07:31, 13 August 2012 (CEST)

## MP Decreasers

So the Mer-kin eyeglasses lower your max MP. Is there any page that this should go on (i.e. link to in See Also section)? — Cool12309 (talk) 18:20, 31 March 2013 (UTC)