The Mathematics of Old School Runescape

Games are a great way to explore math, logic, and problem solving! This goal of this Open-Source Python Project is to mathematically model the game Old School Runescape, and to use those models to optimize player decisions. This is a game that is played over the course of months or years, collecting items, fighting monsters, and leveling up skills (among many other things). As a result even small improvements can save people tens, if not hundreds of hours. You can check out my Reddit posts:

or check out my video series detailing these solutions:

The first problem I tackled was to figure out the optimal equipment for a player to wear to maximize their damage while fighting monsters. This required a model of the damage a player could do, which could then be optimized. There are an enormous amount of equipments available to the player and brute-force searching through all these combinations would be impossible! Instead we have to do what's called a search-space reduction which would eliminate redundant equipment choices. This reduced the number of considerations from 10^18 to about 250-500 choices, making this a brute force approach now feasible! Since this problem is such a common decision for players, I created a user interface in python (using PySide2) for it, as you can see below. Now players can easily determine what their (mathematically exact) best equipment choices are.

The second problem dealt with what order to train the player's skills to get to a desired level as fast as possible. There are essentially 3 skills that affect a players damage: accuracy, damage, and defence (which also allows players to use better equipment). From the players starting levels, they have to choose between which of those three skills to train first. After that decision, they have three more, and three more, ... So the question arises what is the fastest order? This series of choices constructs a graph where each edge corresponded to the time it would take to train the level associated with that edge. The optimization of this could then be done by using Djkstra's algorithm which is related to the famous traveling salesmen problem, and it finds the fastest route through these types of graphs. Below is an optimal path, where each fork represents the choice to train damage (left) or accuracy (right). The blue & green dots represent changes in equipment. The slight leftward tilt of the path suggests that having the damage skill higher is more efficient for the player.
And the projects continues on to more and more problems! In addition, because I found it difficult to find some basic information about the details of the game, I ended up writing a summarizing document about what I learned, which you can find at the bottom of this page. You can also checkout at the Github repository or the Reddit post if you're interested.

You can also download the document here.