Code
#collapse-hide
import pandas as pd
import plotly.express as px
from IPython.display import HTMLA Deep Dive into the Distribution of Blocks in Minecraft
To answer this question we must first collect data. To do this I created a minecraft mod that randomly teleports the player, samples a 500x50x500 (X,Y,Z) set of blocks around the player and logs those blocks into a csv. It repeats this a total of 10 times creating 10 samples of 500x50x500 blocks
The mod can be seen here: https://github.com/JPrier/MinecraftBlocksDistribution
With this we get 128 million blocks from a single seed, doing this on multiple seeds will explode the data size
Here we will use Pandas to read in the data to be used to visualize distributions.
X Y Z Block sample playerX playerY playerZ
0 -5831 0 6935 bedrock 0 -5581.0 50.0 7185.0
1 -5830 0 6935 bedrock 0 -5581.0 50.0 7185.0
2 -5829 0 6935 bedrock 0 -5581.0 50.0 7185.0
3 -5828 0 6935 bedrock 0 -5581.0 50.0 7185.0
4 -5827 0 6935 bedrock 0 -5581.0 50.0 7185.0
... ... .. ... ... ... ... ... ...
128010505 13966 50 -10793 water 9 13720.0 50.0 -11043.0
128010506 13967 50 -10793 water 9 13720.0 50.0 -11043.0
128010507 13968 50 -10793 water 9 13720.0 50.0 -11043.0
128010508 13969 50 -10793 water 9 13720.0 50.0 -11043.0
128010509 13970 50 -10793 water 9 13720.0 50.0 -11043.0
[128010510 rows x 8 columns]
Here we want to visualize the blocks and their frequency
#
# Adjust samples to be same distance from player
df["XFromPlayer"] = df["playerX"] - df["X"]
df["ZFromPlayer"] = df["playerZ"] - df["Z"]
# Get blocks that we care about
importantBlocks = ['coal_ore', 'gold_ore', 'iron_ore', 'diamond_ore', 'lapis_ore', 'redstone_ore', 'emerald_ore']
specialBlocks = ['diamond_ore', 'lapis_ore', 'redstone_ore', 'emerald_ore']
df_blocks = df.loc[df['Block'].isin(importantBlocks)]
df_special_blocks = df.loc[df['Block'].isin(specialBlocks)]
# Get blocks for only 1 sample
df_blocks_sample_0 = df_blocks.loc[df_blocks['sample'] == 0]
df_special_sample_0 = df_special_blocks.loc[df_special_blocks['sample'] == 0]