Calculating mana cost reduction when there is a % reduction to cost from an event with a % chance to occur on each expenditure

47 Views Asked by At

I'm trying to determine, or at least approximate, the actual expenditure of a resource in a game. The expenditure event is as follows:

  • When casting a spell with a mana cost of X, there is a Y% chance that spell will be a critical success.
  • If the spell is a critical success, the subsequent two spells (with the same mana cost X), will have their mana cost reduced by 40%.
  • If either of those two is a critical success, that spell still has its mana most reduced, and it resets the cost reduction effect to apply to the subsequent two spells; making a chain possible.
  • If neither of them is a critical success, the cost reduction ends, and the subsequent spell will cost its full mana cost.
  • This results in the spell's actual mana cost (effective mana cost) being a mix between its base cost, and the reduced cost, we'll call this value Z.

How would one express how to calculate what Z is when casting the same spell over and over, given the mana cost and critical success chance for said spell?

My purpose is to use this in a Google Sheet, if that's relevant to how one writes the expression.

Thanks for your interest!

For background:

  • "Spell" refers to a magical incantation that results in a specific paranormal effect - such as launching a fireball or healing wounds instantly.

  • "Mana cost" refers to the specific expenditure of "mana" required to manifest a given "spell".

  • "Critical success" refers to the chance for a "spell" to have an increased effect.

The goal of this is to be able to better understand each spell's mana cost, and thereby be able to compare them to one another. For example not all spells have the same chance to critically succeed, and that may well make one spell a better choice for efficient mana expenditure.

P.S I do hope I tagged this correctly!

1

There are 1 best solutions below

0
On BEST ANSWER

As the number of reduced spells is never increased above 2, the expected value of the mana cost of a cast spell depends on the last two spells and nothing more.

More formally: There are two possible ways of mana cost, $X$ and $(1-0.4)X$. The expected value is then $$E(X)=p(\text{previous spells were not critical})\cdot X+p(\text{at least one previous spell was critical})\cdot (1-0.4)X$$

The probability of two non-critical spells are $$ p(\text{previous spells were not critical})=(1-Y/100)^2$$

The probability of at least one critical spell in the last two spells is then $$ p(\text{at least one previous spell was critical})=1-(1-Y/100)^2$$

Together: $$E(X)=(1-Y/100)^2\cdot X + (1-(1-Y/100)^2) \cdot (1-0.4)X$$

or combined more: $$E(X)=0.6X+0.4X(1-Y/100)^2$$