Hardware Reference
In-Depth Information
2. Type in the following lines very carefully, making sure there are exactly the same
number of columns on each line. If you look very carefully at this data you
should already be able to see the structure of this maze! There are 16 numbers
per line and 16 lines, so perhaps use a pencil to tick off each line as you type it in
so you don't lose your place:
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,1
1,0,0,1,0,0,0,0,1,0,1,0,1,0,0,1
1,1,0,1,0,1,1,0,0,0,0,0,1,0,1,1
1,1,0,1,0,1,1,1,1,1,1,1,1,0,1,1
1,1,0,0,0,1,1,1,1,1,0,0,0,0,1,1
1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1
1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1
1,0,1,1,1,1,0,0,0,0,0,1,1,1,1,1
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
1,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1
1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1
1,0,1,0,1,1,1,1,0,1,1,1,1,1,0,1
1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1
1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1
3. Save this file. You will use it once you have written the Python program that
reads and processes the data in this file.
Building a Maze
Now that you have a data file describing your maze, the final step is to write the Python
program that reads data from this file and builds the maze in Minecraft using blocks.
1. Start a new file with File New File and then use File Save As to save it as
csvBuild.py .
2. Import the necessary modules:
import mcpi.minecraft as minecraft
import mcpi.block as block
3. Connect to the Minecraft game:
mc = minecraft.Minecraft.create()
4. Define some constants. The GAP constant is the block type that is used in the
spaces. This will normally be air but you could experiment with different block
types here to make the maze interesting. The WALL constant is the block type
that the walls of the maze will be built with, so choose this carefully as some
block types won't work very well as walls. The FLOOR constant is used to build
the layer that the maze stands on:
 
 
Search WWH ::




Custom Search