# Wizard101 PvP Power Conversion Calculator

This calculator is designed for experimenting with different Power Conversion formulae. It is based on Javascript and uses jQuery and jQuery-UI.

## How to Use It

For each team, select the number of players, then set their levels and ranks. Use keyboard arrow keys for fine control of the sliders. Results are displayed below the sliders. A good match is indicated by the "%Diff to" column showing close to 100%.

The default values show a typical puppet team match-up.

See below for explanations of the different methods and how to customize this page.

Team A: Number of Players, Level, and Rank

Formula | Level | Rank | Spread | Total | Diff to B | % Diff to B |
---|---|---|---|---|---|---|

Team B: Number of Players, Level, and Rank

Formula | Level | Rank | Spread | Total | Diff to A | % Diff to A |
---|---|---|---|---|---|---|

These sliders adjust the values of C for each formula (see individual descriptions below):

LRS - KI(?): | |

LRS Spread - digem: | |

Sum of Years - Chogath: | |

Sum of Squares - Termagant: | |

Sum of Squares - shadestorm: | |

Sum of Squares - Nesogra: | |

Hybrid - Nesogra: |

## Formulae

In each formula, there is a constant 'C' which can be adjusted (using the sliders above).
**LRS - KI(?)** **L**evel/**R**ank **S**core is an attempt to
replicate the formula currently used by KingsIsle. The details of the
formula are not known, so the results here are based on guess-work. Note
that the default values (from initial page load) show the two teams having
very similar LRS scores.

It is currently (default C = 20):
```
Total = Σ ( L * C + R )
```

**LRS Spread - digem** is a method suggested by digem. It adds a factor
derived from the spread between all the team members. abs() is the absolute
value function (converts negative to positive). Note that Pi - Pj for all
i and j adds each spread twice. Consequently, to make the spread factor
50%, we divide by 4.

It is currently (default C = 25):
```
for each player: P = L + ( R - 500 ) / C
```

Total = Σ P + Σ abs ( Pi - Pj ) / 4

**Sum of Years - ChoGath** is a method suggested by ChoGath. It is
borrowed from depreciation accounting. Team members are sorted from low to
high, then the level/rank is multiplied by the index + 1 within the sort.
index + 1 is refered to as 'Y' (for 'Year'). Nesogra suggests we divide
the rank term by C and add it to the level to get the total.

It is currently (default C = 50):
```
Level = Σ Y * L
```

Rank = Σ Y * R

Total = Level + Rank / C

**Sum of Squares - Termagant** is the method I am proposing. The first
step is to constrain the rank with a ceiling at 1000 and a floor at 400.
Ranks above 1000 are simply truncated down to 1000 and below 400 are
brought up to 400. Next, subtract 400 to shift it down to the 600-0 range.
Then this number is divided by 600 to get a number from 0.0 to 1.0.
Multiply this number times C to get a number ranging from 0 to C. Now add
1 to get a number from 1.0 to C + 1.0 with commander/overlord being C,
privates are 1.0. Call this number E (for experience). Finally we
multiply E times the square of the wizard's level (as in the Sum of Squares
method). Add all of these numbers for each team member to get the total
team score.

It is currently (default C = 1.0 which makes constrained rank range from 1.0 to 2.0):
```
E = 1 + ( ( constrain ( 1000 > R > 400 ) - 400 ) * C / 600 )
```

Total = Σ E * L * L

**Sum of Squares - shadestorm** is a method offered (with reservations)
by shadestorm. It is similar to **Sum of Squares - Termagant**, but
includes a normalization factor made up of the sum of the constrained rank
times the level. shadestorm analyzes this method (see post #102 on
this page) and demonstrates a
problem: "The higher the ranks of the lower level wizards, the lower the team score will be."

It is currently (default C = 1.0 which makes constrained rank range from 1.0 to 2.0):
```
E = 1 + ( ( constrain ( 1000 > R > 400 ) - 400 ) * C / 600 )
```

Total = ( Σ E * L * L ) / ( Σ E * L )

**Sum of Squares - Nesogra** is the method Nesogra is proposing. The
first term is the sum of the squares of the levels, divided by the sum of
the levels. The second term is the sum of the squares of the ranks divided
by the sum of the ranks. The rank term is further divided by C. Then add
the two terms.

It is currently (default C = 50):
```
Total = ( Σ ( L * L ) / Σ L ) + (
Σ ( R * R ) / Σ R ) / C
```

**Hybrid - Nesogra** is an alternative method Nesogra is proposing. The
first term is the sum of the squares of the levels, divided by the sum of
the levels. The second term is the sum of year times rank (rank is sorted)
divided by the sum of the years. The rank term is further divided by the
constant C. Then add the two terms.

It is currently (default C = 20):
```
Total = ( Σ ( L * L ) / Σ L ) + (
Σ ( Y * R ) / Σ Y ) / C
```

## Customization

Once this page loads, all calculations run in your browser, there is no further interaction with the web-server. This means you can copy this page to a local file on your computer, edit it, then reload the file to view your changes.

## Copy this page

Right click anywhere in this page to get the context menu, and click on **Save
Page As...**. In the window that opens, browse to where you want to save
the file and click **OK**.

## Making Changes

Use any text editor (Notepad, VIM, etc - but not Word or other word
processors) to edit your saved file. Search for the comment that says
**Power conversion functions** around line 30. These functions accept
the values provided by the sliders and produce the text for the results
Make any changes and save the file.

## Running Your Local Copy

In the address bar of your web browser, enter the `file://`

protocol followed by the fully qualified file name. If you saved your file
to your desktop, it is probably something like:

```
file://C:/Users/your_login_name/Desktop/Wizard101 PvP Pairing Calculator.htm
```

If you have trouble finding it, you can browse for it by entering:

```
file://C:/Users/
```

and searching for it.

Linux users should use something like:

```
file:///home/your_name/...
```

## Debugging

Javascript is designed so web-pages don't crash your browser. In practice, this means that if there is a problem in the Javascript, the code just stops and you get whatever the browser manages to render without the code running. What you don't get is help figuring out what is wrong with your Javascript.

## Firebug to the rescue

If you would like to experiment with this code, you should get the FireBug
extension for Firefox. From the Firefox **Tools** menu, select
**Add-Ons...**. Enter **Firebug** in the **Search** box, and
click **Install**. You will need to restart Firefox to load it.

Firefox will now have a new button with a little bug on it. Click the
bug to start Firebug on the current tab. Near the top of the Firebug
page are tabs for `HTML`

, `CSS`

, `Script`

,
`DOM`

, and maybe some other things. Select the
`Script`

tab, and reload the page. Javascript errors will
appear in the Firebug `Script`

window.

Note that Javascript errors can occur during initial page loading, or when the Javascript is invoked (when moving the sliders).