Table of Contents

Parallelization in Minecraft

In this lab you will program robots to play Minecraft and optimize their operation by using multiple threads to control multiple robots. You are provided a modded version of Minecraft which allows you to connect to a running game world to obtain a robot called a “turtle”. When you close the connection, the robot disappears. You may also open multiple connections to obtain multiple robots which can then work in parallel.

The setup is based on the turtles in the mod ComputerCraft and as such provides the same API. A small example demonstrating some of the turtles' functions is included in your files.

Even though most tasks can be solved using only one turtle, parallelization is the key to do them quickly. This introduces a few synchronization issues that you need to deal with: how to divide the task among the turtles and how to prevent turtles from crashing into each other.

Don't worry, if you've never played Minecraft before. There is a lot of content to the game, but for this lab you just need to know that the world is made of a 3D grid of blocks, which can be mined (“dug”) to obtain them as “item” in one's inventory, allowing one to place them somewhere else.

Setup

Exercise 0

Run and read through the example program (“TurtleMain”). If you can't find the turtle moving about, try printing its location using System.out.println(turtle.getLocation()).

Hints

Exercise 1

Your first real task is to build a simple 3x1x3 grid (i.e., horizontal, height 1) of blocks at height y = 90 centered right above the spawning location. The goal here is to get accustomed to the API. Keep in mind that turtles need to collect some blocks before being able to place any!

Hints

Exercise 2

Setup: Copy /home/lab/local-data/turtles/exercise2/ComputerCraft.cfg over the existing file of the same name in /home/lab/.minecraft/config, and restart Minecraft.

Now that you have understood the basics, it is time to add some parallelization! Build tower hollow of height 10 with a 5×5 area and a few holes in the side (see whiteboard). The tower should be made of cobblestone only (block name minecraft:cobblestone). Again, the tower should start at y = 90 and be centered around the spawning location.

Try to complete this task as quickly as possible by using as many turtles as you can handle! On world seed qwer 60 seconds is a good time. The assistants' record is 43.1 seconds.

Hints

Exercise 3

The room will be divided into two teams, each of which will be provided a server. The goal is to collaboratively build a cobblestone pyramid larger than that of the other team!

This is a very open-ended task. Feel free to focus on smaller parts of the problem, such as the efficient harvesting of cobblestone from the game world.

General Hints