## Optimal Skills Distribution at High Level

### Skills Distribution Theory: Basics

First of all we need to figure out how many skill points every skill level costs, it’s pretty straightforward, to buy up to the Nth level of a skill you need:

- SP(N) = N*(N + 1)/2

Then we need to understand which skills are important to raise, given a defined playstyle.

As written above, the monsters meet the following gems, let’s see which uncapped skills help:

- Blue lantern -> TC (only helps duration), Slow (only helps duration)
- Orange amped traps -> TC, Leech, Traps, Amps
- Red amped lantern -> TC (only helps duration), Bleed (only helps duration), Amps
- Yellow amped traps -> TC, Resonance, Crit, Traps, Amps

True Colors, Resonance, Critical Hit, Leech, Amplifiers and Traps and the best choices.

Bleed and Slowing are not needed, at high level TC gets you all the duration you could ever want.

At this point we need to see what effect those skills have on the game stats, so let

- {tc, r, c, l, a, t}

be the level of every skill (name got from their initial) and ‘ta’ be the bonus granted by your talismans (hopefully 25).

The raw bonuses look like:

TC[tc]:=1+3/100*(tc+ta);

Reson[r]:=1+3/100(r+ta);

Crit[c]:=(1+4/100*(c+ta))*(1+4/100*(c+ta)/5);

Leech[l]:=(1+4/100*(l+ta))*(1+4/100*(l+ta)/5);

AmpsSpecial[a]:=0.15+0.004*(a+ta)/5;

AmpsDamage[a]:=0.20+0.004*(a+ta)/5;

Traps[t]:=1.8+5/100(t+ta);

I assume the gems are at the speedcap (all the decent amped trap gems get to the speed cap before g30, easily reached from WL 3k), so we don’t bother with it.

Now let’s consider what we want to maximize, we’ll divide the problem in more parts:

### Skills Distribution Theory: Amps

The benefit the amps skill gives is more complicated than all the other skills, because it depends on how much mana is in the amps respect to the gems, how many amps you have, how many gems each one sees and what special we’re optimizing.

For 1D amps (leech, bleed) it’s possible to give an analytical solution that gives out what is the ideal amp/gem cost ratio and the associated benefit:

- AmpsRatio1D[a, Ga, g] := (AmpsSpecial[a]*Ga)^(1/(1 – g));
- AmpsPower1D[a, Ga, Qa, g] := (1 + Qa * AmpsRatio1D[a, g, Ga])^(1 – g);

where Qa is the number of amps per gem, Ga is the average number of gems seen by each amp and g is the growth of the gem.

Now, with some reasonable assumptions we can get:

Gal = 2.5; (* The average mana amp sees 2.5 gems, seems reasonable *)

Qal = 2; (* There are 2 amps for every gem, one each side, more or less *)

gl = 0.491084 (* 13c *)

AmpsMana[a] := AmpsPower1D[a, Gal, Qal, gl];

(* Bleed is in a lantern surrounded by 8 amps *)

Gab = 1;

Qab = 8;

gb = 0.214125 (* Log2[1.16], U *)

AmpsBleed[a] := AmpsPower1D[a, Gab, Qab, gb];

For yellow gems, the problem isn’t analytically solvable, but can be solved numerically.

We have 2 competing formulae with similar result but different derivation.

Use the ratio formula you like (or remember) best, they give extremely similar results:

gk = gd + gc = 1.145648 (* 11c *)

RatioCritB[a, Ga] := (0.5 * (AmpsDamage[a] + AmpsSpecial[a]) * Ga) ^ (1 / (1 – 0.5 * gk))

RatioCritI[a, Ga] := 0.883 * (AmpsDamage[a] * Ga) ^ (1 / (1 – 0.574))

AmpsPowerCrit[a, Ga, Qa] := (1+AmpsDamage[a]*Qa*Ga*RatioCrit[a, Ga]^gd)*(1+AmpsSpecial[a]*Qa*Ga*RatioCrit[a, Ga]^gc)/(1+Qa*RatioCrit[a, Ga])^gk

AmpsKillTower[a] := AmpsPowerCrit[a, 1, 8]; (* Ga: 1, Qa: 8 *)

AmpsKillTrap[a] := AmpsPowerCrit[a, 2.5, 2]; (* Ga: 2.5, Qa: 2 *)

We’ll use the power formula for traps here, but I leave the one for a killtower if someone needs it.

### Skills Distribution Theory: M and K

**Manapower**

In this game the best mana gems are pure orange gems, whose leech power is influenced by skills this way:

leech_after_skills = TC[tc]*Leech[l]*base_leech

being in trap -> Traps[t]

having amps -> AmpsMana[a]

So the quantity we need to optimize for mana gaining is:

M[tc, l, a, t] = TC[tc]*Leech[l]*AmpsMana[a]*Traps[t]

if we were to maximize this with respect to {tc,l,a,t} over the constraint of a maximum expendable SP amount, we’d get the best setup for mana farming.

But then we need to kill monsters, too, so let’s understand

**Killpower**

In this game the best killgems are pure yellow gems, whose power is its displayed max damage times its displayed crit (times 0.8 times 0.5, which are constants so we never care about those).

They can be helped by a pure red gem applying bleeding on everything.

The killgem killing power is influenced by skills this way:

damage_after_skills = TC[tc]*Reson[r]*base_damage

crit_after_skills = TC[tc]*Crit[c]*base_crit

being in trap -> Traps[t]

having amps -> AmpsKillTrap[a]

On top of that our bleed gem also helps, but bleed is influenced by no skills aside from amps, so:

having amps -> AmpsBleed[a]

So the quantity we need to optimize for killing power is:

K(tc, b, c, r) = TC[tc]^2 *Reson[r]*Crit[c]*AmpsKillTrap[a]*AmpsBleed[a]*Traps[t]

if we were to maximize this with respect to {tc,r,c,a,t} over the constraint of a maximum expendable SP amount, we’d get the best setup for killing monsters.

This is kinda useful (with minor adjustments) for talisman farming at high level, but not what we need here.

### Skills Distribution Theory: The Exp Model

In this game most of the exp comes from the enraging bonus, you should aim to keep your enraging gem as high as possible all the time, and stop the field once you need to degrade it too much to keep up with the monsters.

A typical endurance is split in 2 phases:

- Mana phase: you set up the mana farm and you can make a killgem to kill anything that comes at max enrage, with a cost much smaller than your mana gems, the enrage gem is limited by max mana
- Kill phase: monsters start getting big enough that the needed killgem is as costly as the manafarm, so you sell the latter, finish upgrading the enrage gem and the killgems and start slowly degrading the enrage gem to keep up, the enrage gem is limited by max killpower

The transition point comes when:

total_killpower[wave] = enemy_health[wave]*hp_bonus_of_the biggest_gem_we_can_make[wave]

given:

gM = 1/(1 – gl)

total_mana[wave] = (M*wave)^gM

total_killpower[wave] = total_mana[wave]^(gk + gb) * K

hp_bonus_of_the biggest_gem_we_can_make[wave] = total_mana[wave]^(log(1.8)/log(2))

enemy_health[wave] = h^wave (h is 1.1-1.11 depending on the field)

we get that the transition point satisfies the equation:

waveT = (log[K] + gM * (gk + gb – log[1.8] / log[2.0]) * log[M * waveT]) / log[h];

it’s possible to solve the above by iteration to find waveT.

We can now compute the total exp before the transition, by summing up the exp of each wave:

- exp_before[wave] = wave^2 * exp_bonus_of_the_biggest_gem_we_can_make[wave]

given: - exp_bonus_of_the_biggest_gem_we_can_make[wave] = total_mana[wave]^(log(1.2)/log(2))

The total exp before transition can be approximated by the integral of the above from 0 to waveT, which is:

- total_exp_before = (M * waveT)^(gM * log(1.2) / log(2.0)) * waveT^3 / (3 + gM * log(1.2) / log(2.0))

Now after the transition we have for each wave:

- exp_after[wave] = wave^2 * exp_bonus_of_the_biggest_gem_that_lets_us_still_kill[wave]

given: - exp_bonus_of_the_biggest_gem_that_lets_us_still_kill[wave] = (total_killpower[waveT] / enemy_health[wave])^(log(1.2)/log(1.8))

The total exp after transition can be approximated by the integral of the above from waveT to infinity, which is:

- total_exp_after = (K * (M * waveT)^(gM * (gk + gb))) ^ (log(1.2) / log(1.8)) * (waveT^2 / c + 2 * waveT / (c * c) + 2 / (c * c * c)) * exp[-c * waveT]

given:

c = log[h] * log[1.2] / log[1.8] (has no deep meaning, just appears often)

The final exp power is then the sum, so:

Relative_exp_power[tc,r,c,l,a,t] = total_exp_before + total_exp_after

this final function depends on M and K, that depend on the skill values, this is the formula we need to maximize to have the best skill setup.

Skills Table

I report here just the first part of the skills table, a full list up to 10M SP is available at this link:

https://gist.github.com/12345ieee/cabb04da5e60b3bf08ddc8635ec7c916

The table assumes +25 bonus from talismans, so in the first line TC will be at 36+25=61 total points.

### Appendix

**Gem growth**

Given a combine scheme, we know its power increment (P) and its length (N).

E.g. for leech gems an U upgrade has P=1.38 and N=2

If we have a certain amount on mana (Nt base gems) to spend on a gem and many combine schemas, which one do we choose? And how strong is the resulting gem?

It’s possible to define a quantity, called growth that is a measure of the goodness of a combine:

final_power = P^number_of_times_we_can_run_this_combine

number_of_times_we_can_run_this_combine = log(Nt)/log(N)

final_power = P^(log(Nt)/log(N)) = Nt^(log(P)/log(N))

let g = log(P)/log(N)

final_power = Nt^g

g only depends on the property of the combine schema, and the bigger it is, the stronger a gem becomes for a given initial mana, so it’s the ideal number to rank combines.

The last equation also gives how spending mana on a gem affects its power, which is used multiple times throughout the guide.

**Proof of the total_mana[wave] formula**

mana_gained_in_one_shot[t] = M * base_leech[t] = M * total_mana[t]^gl

passing to the continuous limit:

d(total_mana[t])/dt = M * total_mana[t]^gl

integrating:

total_mana[t] = (M * t)^(1/(1-gl))

**Proof of the 1D amps metrics**

Ga = average number of gems seen by each amp

Qa = average number of amps per gem

g = growth of the color

Ng = cost of the gem

Na = cost of the amp

ampsSkill[a] := 0.15 + 0.004*(a/5);

we need to maximize wrt Ng and Na:

p1D[Ng, Na, a, Ga, Qa, g] := Ng^g + ampsSkill[a]*Ga*Qa*Na^g;

under:

Nt = Ng + Qa*Na = const

we use Lagrange Multipliers to do so, and when we eliminate lambda from the first 2 equations we are left with:

Ng^(g-1) = ampsSkill[a]*Ga*Na^(g-1)

so we get:

AmpsRatio1D[a, Ga, g] := Na/Ng = (ampsSkill[a] * Ga)^(1/(1 – g));

**Exp_power approximation**

It turns out that at high level (>5k) the relative exp power is well approximated by:

Relative_exp_power[tc,r,c,l,a,t] ≃ M^0.555793 * K^0.0522649

Looking at the exponents we see that improving mana is 10 times more important than improving killpower, and that’s why mana skills are a ton higher than the equivalent damage skills.

**High level skills approximation**

At very high level, once the constant terms are negligible one can find that the SP invested in each skill should be:

Maximize: very_approximate_exp_power[{S_i}] = prod_i(S_i^(e_i/2))

under: sum_i(S_i) = SP = const

and get: SP_i = e_i / sum_i(e_i) * SP

where e_i is the exponent with which each skill level appears in the approximated expression of Relative_exp_power. They are:

e_TC = em + 2 * ek = 0,660

e_Reson = ek = 0.052

e_Crit = 2 * ek = 0.104

e_Leech = 2 * em = 1.111

e_Amps = em + 3 * ek = 0.712

e_Traps = em + ek = 0,608

**The exp growth**

Given the above approximation, we can substitute back in and get:

appr_exp_power[SP] ≃ SP ^ (sum_i(e_i)/2) = SP ^ 1.62

Also:

SP = 7 * WL = 7 * exp ^ 1/3

So:

appr_exp_power[exp] ~ exp ^ 0.54

Considering that appr_exp_power is proportional to the amount of exp we expect to get on the next field, its exponent is the growth of exp.

ge = 0.54

It being less than 1 means the game converges, and we can’t get infinite Wizard level, but it allows one to estimate how our level will progress as we complete fields and get stronger.