## Tuesday, December 20, 2011

### On the Enchantment Level - Bookshelf Dependency in Minecraft

[Editors Note: For those who do not play Minecraft, you should. You can play it in your browser here, but I strongly recommend downloading the client from here.]

[Another Editors Note: This post is outdated. Updated versions are available for the enchanting systems introduced in version 1.1 and version 1.3]

After watching episode 125 of Etho's Minecraft series, and listening to him complaining about how long higher level enchantments take to find, I decided to work out exactly what the distributions of the various enchantment levels are, and find the optimum number of bookshelves to use when looking for a specific enchantment level.

Because there is an increasing scale for the amount of experience required to obtain each level, a lot of experience is wasted if you spend your levels on more than one enchantment at a time. For example, if you start at level 0, and gain 10 levels and spend them on a level 10 enchantment, and then gain another 10 levels and spend them on another level 10 enchantment, you will have had to kill roughly 154 hostile mobs to obtain those two level 10 enchantments. But, if you gained 20 levels, and then spent all of them on two level 10 enchantments, you would have had to kill around 294 mobs for the same net result.

As a result of this, it is necessary to find an enchantment that will use up all (or almost all) of your levels in order to minimise the amount of experience wasted.

When enchanting an item, the player is offered three possible enchantments of random levels. The levels of the enchantments that are offered depend on two non-random and three random variables. The non-random variables are the slot in which the enchantment is offered and the number of bookshelves surrounding the enchantment table, and the random variables are integers uniformly distributed between zero and the number of bookshelves, zero and half the number of bookshelves (rounded up), and one and five. The three random variables are added together, and multiplied by a factor of 0.5, 0.66 or 1.0, depending on whether the enchantment is being offered in the top, middle or bottom slot.

This means that with 30 bookshelves around the enchantment table, the maximum level that can be offered in each slot is 25, 33 and 50 respectively. In other words, an enchantment of level 34 or above can only appear in the bottom slot. However, it is possible for a level 1 enchantment to be offered in any of the three slots.

Because of this, the distribution of the enchantment levels offered is skewed significantly toward the lower levels, with the first, second, third, and fourth groups of 10 levels appearing on average 8.0, 18.2, 9.3, and 3.4 times more often than the fifth group of 10 levels for 30 bookshelves.

The resulting probability distributions for the bottom slot are shown in Figure 1 below. For clarity, the numbers of bookshelves for which the graph is plotted match the combinations available using Etho's piston mechanism for the variable bookshelf enchanting room (built in episode episode 112 of his series.

Figure 1: Distribution of enchantment levels appearing in the bottom slot

The likelihood of being offered a level 50 enchantment is 0.04%, which means that the expected value for the number of attempts required to obtain this is 2 480. At two attempts per second, this means that it would take on average, over 20 minutes of clicking to get a level 50 enchantment. However, with some considerable luck (and faster clicking) this time could be much shorter.

Since the enchantment levels offered in the middle and top slots favour the same distribution, albeit squashed on the horizontal axis, it is apparent that lower level enchantments are much more likely to show up. For example, with 30 book shelves, a level 17 enchantment is the easiest to obtain. Obtaining an enchantment of exactly level 17 is likely to be quicker than obtaining an enchantment of any level from 38 to 50 (requiring on average 6.4 attempts, as opposed to 7.4 attempts).

This sort of behaviour will be familiar to all players who make use of higher enchantments. What is more useful is to use the distributions to calculate the optimum number of bookshelves to maximise the probability of being offered an enchantment of a specific level. This is quite easy to do, and the results are shown in Table 1. Oscillations in the distributions of the top and middle slots are caused by the rounding error after multiplying by the slot factor, and these play a small but important role in the calculation (for an example, level 14 is most easily obtained with 22 bookshelves, while level 15 requires just 21).

Table 1: Optimum number of bookshelves for specific enchantment levels.

 Level Bookshelves 2 and below 0 3 1 4 3 5 5 6 7 7 9 8 11 9 12 10 14 11 15 12 18 13 19 14 22 15 21 16 26 17 25 18 27 19 and up 30

This phenomenon is not present when using Etho's variable bookshelf design. In this case, the optimum number of bookshelves to use is 2 for levels 4 and below, 9 for levels 5 to 8, 16 for levels 9 to 12, 23 for levels 13 to 17, and 30 for levels 18 and above.

If you enjoyed this post, then don't forget to like, tweet, +1, or upvote on reddit. If you have any questions, comments or complaints, post them using the form below.
. . . . . . . . . . . . . . . . . . . . . . . .