Introduction: A Rainbow of Fractals in Minecraft
I made a bunch of Python scripts to generate colorful fractals in Minecraft. To run them with the desktop version of Minecraft, you need my Raspberry Jam Mod (there is also a version for Android Pocket Edition), and many of my Python scripts should work with Minecraft for the Raspberry Pi without any mod.
My instructions will assume Windows. If you have Mac or Linux, installing mods will be somewhat different, but everything should work.
Step 1: Install Raspberry Jam Mod
To communicate with Python scripts, install Raspberry Jam Mod. This has three steps:
1. Create a Minecraft 1.8 profile in Minecraft and start up Minecraft with that profile once.
2. Download and run the latest Minecraft Forge for 1.8 Windows installer.
3. Download and run my latest Raspberry Jam Mod .exe installer for Windows (you need the scripts included in 0.40). Install all the options. (Potentially, Windows will give you some kind of a warning about a file that hasn't been downloaded very often. You can either trust me, or you can download all the zip packages and install manually if you prefer. You'll also need to install Python then. See the instructions here. For some reason, too, Windows 8 antimalware takes a very long time to check my installer.)
To test the installation, switch to the Forge profile that the Forge installer will create, start Minecraft, create a single-player world and type
If all goes well, a glass donut filled with water will be drawn.
Technically, what happens is that any Python scripts in the %appdata%\.minecraft\mcpipy directory can be executed with a /py command. In your Windows Start Menu, you should also have a Raspberry Jam Mod entry wtih the IDLE Python environment. You can use that environment to edit all the .py scripts.
Step 2: Mandelbrot and Julia Sets
while standing on the ground of a flat world (or flying in the air above a less flat world) generates a colorful Mandelbrot set. The area you're in at the start is black. Just fly or run and you'll get to some colorful regions.
(I designed the fairly smooth color sequence for this set by taking clay, wool and redstone blocks and solving (approximately) a traveling salesman problem in colorspace.)
You can zoom in on any region by grabbing a sword and right-clicking with the sword on a block you want to zoom in on. (Yes, that's weird, but Raspberry Jam Mod is based on the Raspberry Pi's Minecraft interface, and that's how it works.) To go back to the original view, you can just right-click with the sword somewhere outside the Mandelbrot set.
To stop the script, just type
You can also specify the iteration formula that's used. The default is
for the quadratic Mandelbrot set. For the cubic, you can do:
/py 640 z**3+c
(the 640 is the size of the drawing; the formula "z**3+c" must not have any spaces in it).
You can also do Julia sets, by replacing c in the formula with a complex number (remembering that Python uses j for the imaginary unit). For instance:
/py 640 z*z-0.8+0.156j
(I got the -0.8+0.156j coordinate from the Wikipedia article.)
Step 3: Mandelbulb
The Mandelbulb is a 3D version of the Mandelbrot set. Being 3D, they take an order of magnitude more time to generate.
My default Mandelbulb is an eighth-power one and is generated with:
It will slowly rise near the player and above. As with the Mandelbrot set, you can zoom by right clicking with the sword, but this isn't as convenient as in the 2D case. Screenshots don't do it justice: fly around it to get a better picture.
You can also customize with:
/py mandelbulb size power
The size is the size in blocks (default: 100, maximum about 250). The power is the power of the Mandelbulb, default being 8. You can try 2, 3, and so on.
Finally, it's really fun to see the cross-section, so you can add a final argument to the command: south, north, east, west, up or down. This specifies which half of the Mandelbulb to draw. For instance, you can do:
/py mandelbulb 150 8 south
to view the southern half of the 8th power Mandelbulb. The cross-sections are really pretty and colorful, especially while being drawn.
To explore dark caverns in a Mandelbulb, you might want to turn on night vision: the Raspberry Jam Mod provides the /nv command to toggle night vision.
Step 4: Sierpinski Tetrahedron and Menger Sponge
The Sierpinski tetrahedron is generated by taking a tetrahedron and then replacing it four tetrahedra (three on the base, and one stacked on top), and repeating. I colored each tetrahedron according to which stage the top vertex was generated in. To generate:
The Menger sponge, on the other hand, is made by drawing a cube. Then the cube is divided into 27 cubes (3x3x3), and the subcube in the center of each face as well as in the center of the whole cube is removed. This is repeated. You can generate this with:
The result is fun to run around in, but not very colorful. So I added an option to set the number of stages and fill in the holes with different rainbow-colored stained glass depending on the stage at which the block was removed.
/py mengersponge 4 c
For greater fun, I added an option to slice the cube in half diagonally, which shows some really nice starry structure:
/py mengersponge 4 cs
Step 5: L-system Fractals
L-system fractals are made by first generating a long string of letters/symbols using some rules for rewriting strings, and then interpreting that string as a sequence of commands for a drawing turtle. To make them more colorful, I cycled through colors periodically. Some fun ones to try:
/py hilbert 4
We have a be nice policy.
Please be positive and constructive.