-
Notifications
You must be signed in to change notification settings - Fork 6
Calculation
On this page I’ll walk through the calculation process TopFit uses, both for others to understand it better, and for me to check the code while doing it.
TopFit gathers a list of all equippable items in the player’s inventory and bags, and saves them in a table indexed by inventory slot where the item can be equipped. Then these items are assigned a score based on the weights of the set in question. The list is then reduced to throw out any unnecessary items.
In what is basically a recursive calculation, we then travel around the “tree” of all possible calculations, calculate a total score whenever we hit a node where all caps are fulfilled, and save the combination with the highest score — which will be our final result.
The inventory of a World of Warcraft character has a total of 19 slots (not counting ammunition). If, for example, we had two different items available for each slot, there would be a total of 2^19 = 524288 combinations to go through. This would take a considerable time of about 35 seconds if we calculate 500 combinations per frame at 30 FPS.
Throwing out even one of these items cuts the total time in half! The same goes for reducing the number of relevant slots.
- Forced Items
- If the user forces an item for a slot, any other items for that slot don’t need to be factored in the calculation, and are therefore removed.
- Useless Items
- If an item has a score <= 0 and none of its stats contribute to any caps, it is considered useless and removed from the item list. This usually includes things like tabards and shirts, effectively decreasing the number of slots we need to check for our calculation to 17.
- Binds-On-Equip Items
- Unbound BoE items are removed because otherwise we might accidentally equip an unbound item. The user will still be asked for confirmation usually, but this is both unintended and prone to causing problems.
- Items With Superior Alternatives
- For each item we check all the alternatives of the same type. If we find an item that is definitely superior, the original item is removed. This should get rid of things like skinning knives and style items.
- An item is considered superior if it has both a higher score than the original, as well as higher values in all caps.
- For weapons, rings and trinkets, we actually only remove the item if there is two superior items – since there is usually two slots where those can be equipped. If we removed all but the best ring for both ring slots, there would be no second ring to wear.
Even though in theory, we are doing a recursive calculation, it is not practical to actually do so. The calculation might take a while for a full inventory, effectively locking up the game for that duration, causing a noticeable pause for the user, or even a disconnect if it takes too long.
Therefore, we split the calculation between frames, only simulating recursiveness.