[main]

Articles

Finding slime chunks in Minecraft 1.20.2

by Steven Baltakatei Sandoval

Created on 2023-10-09T01:44+00 under a CC BY-SA 4.0 License. Updated on 2023-10-09T01:48+00.

Abstract

For Minecraft 1.20.2, an equation is provided to calculate the probability of finding a slime chunk within n chunks. A table is provided that lists acceptable probabilities of finding a slime chunk and the corresponding number of chunks that must be checked.

1Background

Minecraft is a sandbox video game developed by Mojang, a game development studio owned by Microsoft. As of 2023-10-09, the Java Edition of the game is at version 1.20.2. The game's virtual environment consists of a 3-dimensional world in which the landscape and physics-like interactions utilize voxels known as “blocks”. The position of each block is defined by three integer coordinates on a cartesian grid: x, y, and z. The four cardinal directions are defined as: north (-z), south (+z), east (+x), and west (-x). Elevation is defined as: up (+y) and down (-y). The game engine divides the world into groups of blocks known as “chunks” which are volumes defined by 16×16 areas of blocks in the xz plane, extending up and down for all y. Chunks themselves form a non-overlapping contiguous 2-dimensional cartesian grid in the xz plane.

This game world is populated with dynamic non-voxel entities known as mobs with positions defined by three floating point numbers that map to the 3-dimensional block grid. One particular mob of interest is the slime. Any particular chunk has a small probability, ps, of being capable of randomly generating (i.e. spawning) slimes at y40 according to a spawning algorithm. Players have an interest killing slimes because they drop useful items upon death. Therefore, players have an interest in identifying chunks that are capable of spawning slimes.

However, often players lack the random number seed that defines the procedurally generated environment, including which chunks are designated as slime chunks. A player may determine whether a chunk is a slime chunk or not by excavating a significant amount of underground space below y=40 and seeing if slimes occasionally spawn or not on the ground in that volume. However, excavation of blocks in Minecraft is a time-consuming activity requiring significant in-game resources. Therefore, a method is desired to estimate the number of chunks that must be checked and associated probability of finding a slime chunk.

2Methodology

ps = 0.1 (1)

Equation 1 gives the probability of a chunk having a slime (i.e. 10%) which is defined by the game code. To find the probability of at least one of multiple chunks (i.e. n chunks) being a slime chunk, the problem may be broken down into simpler cases. In Minecraft, one may assume the algorithm that determines whether any particular chunk is a slime chunk does so independently for every chunk. Therefore, a tree of binary events may be drawn that describes all possible outcomes.

An event is when a chunk is checked for the slime generating property. For n=2 events, the probability tree (see Figure 1) results in four possible outcomes in terms of the states si=0 (chunk si is not a slime chunk) or si=1 (chunk si is a slime chunk):

Figure 1. A probability tree of two binary events, resulting in four possible outcomes.

The question “How many outcomes result in at least one chunk being a slime chunk?” is the same as asking “How many of the {s1,s2}'s have at least a single 1 in them?”. In the simple case of n=2, the answer is 3 of the 4 outcomes: {0,1}, {1,0}, {1,1} . The fourth outcome, {0,0}, results in no slime chunks.

However, in order to answer the original question “What is the probability of at least one chunk being a slime chunk?”, final outcome probabilities must be calculated. This may be done for each outcome by tracing a path from the tree root to the outcome's leaf, multiplying together the all the relevant probabilities at each branch point.

Figure 2. A probability tree describing two events with probabilities of each outcome.

Figure 2 lists the individual probabilities for each outcome. Therefore, the answer to the original question is the sum of the probabilities of the three outcomes: {0,1}, {1,0}, {1,1}:

Pslime=p{0,1}+p{1,0}+p{1,1}=(1-ps)ps+ps(1-ps)+psps (2)

However, since the probability of all four outcomes must sum to 1, a simpler method for calculating Pslime is:

Pslime = 1-p{0,0} (3)
= 1-(1-ps)(1-ps) (4)

Equation 3 says you don't have to calculate and sum up probabilities of nearly every single outcome; instead, you only have to calculate the probability of the single outcome where you never get a single slime chunk. In other words, if one knows the probability of not getting a slime chunk, then the remaining probability is that of getting at least one slime chunk. In the n=2 example, the probability of never getting a single slime chunk is p{0,0} which is the probability of failing to get a slime chunk twice. For higher n cases, p{0,,0} still only involves multiplying the same (1-ps) figure again and again, one for each event n.

Pslime(n=2) = 1-(1-ps)2 (5)
Pslime(n=3) = 1-(1-ps)3 (6)
Pslime(n=4) = 1-(1-ps)4 (7)
Pslime(n) = 1-(1-ps)n (8)

Therefore, Equation 8 is the equation defining Pslime(n), the probability of n randomly selected chunks containing at least 1 slime chunk among them.

This equation may be useful in order to minimize the amount of work required to find a slime chunk. Slimes can spawn at elevations below y=40, but they require open space that must be excavated. In order to reduce excavation work, an equation can be used to estimate the number of chunks that must be prepared in order to achieve an acceptably high probability of finding a slime chunk.

Pacc < Pslime(n) (9)
Pacc < 1-(1-ps)n (10)

Where:

Pacc : Acceptable probability of finding a slime chunk. Pslime(n) : Probability of finding a slime chunk among  n  chunks. ps : Probability of a single chunk being a slime chunk. n : The number of chunks

Solve Equation 10 for n:

Pacc < 1-(1-ps)n
Pacc-1 < -(1-ps)n (11)
(-1)(Pacc-1) < -(1-ps)n(-1) (12)
1-Pacc > (1-ps)n (13)
ln(1-Pacc) > ln((1-ps)n) (14)
ln(1-Pacc) > nln(1-ps) (15)
ln(1-Pacc)ln(1-ps) < nln(1-ps)ln(1-ps) (16)
ln(1-Pacc)ln(1-ps) < n (17)
n > ln(1-Pacc)ln(1-ps) (18)

For example, in the case of Pacc=0.95, the number of chunks that must be checked is:

Pacc = 0.95 (19)
n > ln(1-Pacc)ln(1-ps)
n > ln(1-0.95)ln(1-0.1) (20)
n > 28.43316 (21)
n 29 (22)

In other words, in order to find a slime chunk with at least 95% probability, one must check at least 29 chunks. In Minecraft terms, that's a roughly 5×6 chunk area. For Pacc=99.7% probability, 56 chunks are required (roughly a 7×8 chunk area):

n > ln(1-0.997)ln(1-0.1) (23)
n > 55.13586 (24)
n 56 (25)
Pacc n Area 1.000 0.99999 109 10×11 0.997 56 7×8 0.950 29 5×6 0.900 22 5×5 0.750 14 4×4 0.500 7 3×3

Table 1. The number of chunks n that must be excavated in order to find a slime chunk with at least probability of Pacc, according to Equation 18. An approximate area of chunks is provided. The calculations are valid for Minecraft version 1.20.2.

3Conclusion

The number of chunks, n, to be checked for the slime generation property in Minecraft is Equation 18, a ratio of logarithms that is a function of Pacc, the accepted probability of any of the chunks being a slime chunk and ps, the probability of any particular chunk being a slime chunk. Table 1 gives a list of various values of n and Pacc for Minecraft version 1.20.2.