Set Theory and Far Cry 4

Identify the best weapons in Far Cry 4 using Partial Orders

Dimitri Papaioannou
Level Up Coding

--

When the lockdown started, I found myself with some extra time which I judiciously invested in playing video games. One of them is Far Cry 4 (FC4), an action game in which as you progress you accumulate various weapons. The catch is that you can carry a limited number of weapons at a time, so you need to choose carefully.

Needless to say, there are numerous websites and YouTube videos arguing which are the “best” weapons in FC4. Although a lot of it comes down to personal preference, the weapons do come with numerical statistics that can be used to make quantitative choices. The idea occurred to me to try to identify the best weapons relying entirely on the statistics provided. After all, once you come up with a system to rate them, the answer should become pretty easy.

Weapons in FC4 come with some standard stats ranging from 1 to 10: accuracy, damage, range, fire rate, and mobility. If we were primarily interested in only one of these attributes, say damage, we could easily sort all weapons by damage and then choose the ones that have the highest value. But how can we compare weapons if we care equally about all their attributes?

Orders In Set Theory

In a previous article, I introduced relations in set theory and in particular the very useful Equivalence Relation. This post is also about relations, but this time I will introduce orders.

To recap, a relation R on a set A is a set of ordered pairs {(x,y)|x,yA}, or in other words, a relation is simply a subset of A×A, the Cartesian product of A with itself. The elements x and y are related if (x,y) is in R, in which case we write [x R y] (x is related to y)

A relation is transitive if [x R y] and [y R z], implies that [x R z]. Note that the definition does not require that all elements in the set are related. A set A is totally ordered if there exists a transitive relation R such that for any two distinct elements x and y, [x R y] or [y R x]. In this case, the relation R is called a Total Order on A.

For example, in a set of people, the relationship “X is taller than Y” is transitive and it is also a total order because people can be ordered by height. The relationship “X is taller and skinnier than Y” is also transitive, but it is not a total order because Xerces may be taller but also fatter than Yana, which makes the two of them non-comparable with respect to this relation.

A set with a transitive relation defined on it is called a Partially Ordered Set and the relation is called a Partial Order¹. A partially ordered set is also called a Poset. It is fairly common to denote a partial order by so instead of writing [x R y] we simply write x ≥ y.

An element m of a poset A is called maximal if there is no other element x in A, such that x≥ a.

¹ Technically, a (weak) partial order is also required to be reflexive and antisymmetric. The partial order we will discuss here is reflexive but not antisymmetric. However, we can easily work around this technicality.

Simply The Best

Let W be the set of weapons in FC4. If w is an element of W, we denote by w(i) the ith attribute of w, where 1 is accuracy, 2 is damage, and so on. We define a partial order on W as follows: Weapon w is better than weapon v if w(i) ≥ v(i) for each i.²

Now that we have a partial order, we can find the maximal elements. In fact, we want to take this a step further. Since not all weapons are available from the beginning, we need a pictorial way to order the weapons so that we can choose the best available weapon at any time.

For example, consider the subset of sidearms below. The Rebel, the 87 shotgun, and the Autocross are not comparable because they have different strengths and weaknesses. On the other hand, the Autocross bow is better than the Sixer and the Sixer is better than the Mark IV.

Any relation R on a finite set can be represented by a directed graph. The vertices of the graph correspond to the elements of the set. The directed edges link two elements that are related, so that if [xRy], then there is an edge between vertices x and y.

I wrote a little program that reads the weapons stats and arranges them in a graph by creating edges based on the partial order I defined. To draw the graph I used Graphviz, which is a popular graph visualization tool. I created separate diagrams for sidearms and two-handed weapons since they go in different slots.

Here is the graph for the sidearms. The maximal elements, and therefore the best weapons, are the ones that do not have any edges going into them: Autocross, Rebel, 87, D2, D50, and Stinger. The worse weapons are the ones that only have edges going into them: Mark IV, M-712, and Skorpion.

Here is the graph for two-handed weapons.

To simplify the graphs, I applied transitive reduction, which means that I only kept the edges between neighboring nodes and removed the rest. By transitivity, we already know that since the Autocross is better than the Sandman and the Sandman is better than the 6P9, then the Autocross is also better than the 6P9.

² As we mentioned in footnote (1) this is technically not a proper partial order because two distinct weapons may have the exact same statistics. We can easily work around this technicality though by resolving the tie arbitrarily in favor of one of the weapons.

The Source

The code can be found in GitHub in Python and Kotlin. The python code is short enough to post in its entirety:

--

--

I am a software scientist, applied mathematician, and physics enthusiast . My passion is to develop solutions at the intersection of software and mathematics.