The Mathematics of Old School Runescape

Links:

Reddit Posts:

Video Series:


The goal of this Open-Source Python Project is to model the game Old School Runescape for the purpose of exploring optimization and game theory. In this large online game millions of players collect items, fight monsters, and leveling up skills (among many other things) over months, years, and even decades. This means that even small improvements can save people significant huge amounts of time.
In addition to seeking out optimal player decisions, the elegance of the mathematical solutions is always surprising and results in really interesting graphs and visualizations that can provide useful insight.

For example, you can take a flattened list of quests in the game, and render them to show which quests are required to do which other quests. This creates a complex graph that describes the Runescape Universe. To obtain the Quest Cape, players need to complete every quest, essentially solving a difficult graph-theory problem. Players en-mass solve this problem heuristically and share results to prepare guides/routes for other players to do it more efficiently. Setting this up as a graph offers a new perspective / tool to tackle this problem for players.



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.