Wishful Coding

Didn't you ever wish your
computer understood you?

Where to dig in The Nether

Spoiler: Don't

You remember my other Minecraft post? A lot happened since then. Victor Engmark took my hack and made a nice tool out of it that runs way faster as well! Notch released the Halloween update with a new world that is at the moment called The Nether. And last but not least, I ported Mian to Clojure to form Clomian, to compare it to the Python version and to analyze The Nether.

There are still some issues with the code, and I might actually have found my first bug that is actually in Clojure and not in my code. Therefore I will talk and compare in another post, and for now just show you the results.

The bug:

(reduce #(map + %1 %2) (partition 5 (range 1e6)))
java.lang.StackOverflowError

(reduce #(pmap + %1 %2) (partition 5 (range 1e6)))
(99999500000 99999700000 99999900000 100000100000 100000300000)

The graphs:

Where to dig in The NetherWhere to dig in The Nether

As you can see The Nether is an unfriendly place with nothing but Bloodstone, Lava, Fire and Mushrooms.

Unlike the normal world, The Nether is 100% enclosed by Bedrock and in the middle, half of everything is still Bloodstone.

Unlike the normal world, there aren't any minerals and there isn't a clear distinction between above and below.

The only valuables I see are mushrooms and Lightstone, and these are somewhat uncommon and scattered across the whole level.

Conclusion:

The Nether is an interesting world, but it's not worth getting killed for, unless you desperately need any of those special blocks or shrooms.

How to be a good programmer

Get back to work.

Published on

Where to dig in Minecraft

I have been playing Minecraft a lot lately, and I was wondering where to dig for certain minerals. I knew Redstone was only found in lower layers of the level, but I knew nothing concrete.

I pulled together Gnuplot and a Python lib for reading NBT files and analyzed a level. Here is the result, the code and some notes.

Where to dig in Minecraft

I suspect the sea level is around 60, because of the clay there. Coals is rare and Iron very rare above sea level.

Both Diamond and Redstone stop at 20, while gold can be found a little higher. There is no noticeable decline in Coal and Iron near the bottom, so best is to dig below level 20.
Where to dig in MinecraftAs can be seen above, there is a lot of Lava, Water and Obsidian around and below level 10, so stay above level 10 for safe mining.

The code:

from nbt import nbt
from itertools import izip_longest, repeat
import glob
import Gnuplot

files = glob.glob("/Users/pepijndevos/Library/Application Support/minecraft/saves/World2/*/*/*.dat")
output = "minecraft.png"

col = []

for file in files:
    print file
    file = nbt.NBTFile(file,'rb')
    
    col.extend(izip_longest(*[iter(file["Level"]["Blocks"].value)]*128))

    file.file.close()

layers = zip(*col)

minerals = {
    #'Bedrock': '\x07',
    #'Water': '\x09',
    #'Lava': '\x0B',
    #'Sand': '\x0C',
    #'Gravel': '\x0D',
    'Gold': '\x0E',
    'Iron': '\x0F',
    'Coal': '\x10',
    'Obsedian': '\x31',
    'Diamond': '\x38',
    'Redstone': '\x49',
    'Clay': '\x52',
}

names = minerals.keys()
hexes = minerals.values()

def count_minerals(layer):
    def filter_mineral(mineral):
        count = len([block for block in layer if block == mineral])
        return count
    
    m = map(filter_mineral, hexes)
    return m

g = Gnuplot.Gnuplot(debug=1)
g('set term png')
g('set out "%s"' % output)
g('set style data lines')

data = zip(*(count_minerals(layer) for layer in layers))

data = (Gnuplot.PlotItems.Data(list(enumerate(mineral)), title=names[index]) for index, mineral in enumerate(data))

g.plot(*data)

I regret doing this thing in Python. My coding style is strongly influenced by Clojure, and I had to do a number of hacks that would be trivial to do in Clojure. I might do a comparison in a future post if I ever do a Clojure version.