Hardware Reference
In-Depth Information
CHALLENGE
There is a bug hidden in this program for you to find. If the last number on a line
is zero, then for some reason the maze builder still builds a gold block wall
there. Why do you think this happens? Try to fix this bug yourself. Hint: you
already solved a similar problem in the tipChat.py program.
In this adventure you have been using the readlines() and split() functions
to process CSV files. Python is a very large and established programming language
and has lots of features already built in. You could have a look at the built in CSV
reader module that is accessible with import csv as it is a more powerful
method of what we have learnt here. However, I like to build programs up in
small steps as it helps me understand how things work, which is why I have used
readlines() and split() in this topic.
Building a 3D Block Printer
Building mazes is great fun, but there is so much more you can do with data files now that
you know the basics! Why stop at building with only two block types on a single layer? You
are now going to use your maze program as the basis of your very own 3D printer and 3D
scanner that will duplicate trees, houses—in fact, anything you can build in Minecraft—
and “print” them all around the Minecraft world at the touch of a button! This is a block
builder really, but I like to call this a 3D printer, because of the way you can sometimes see
the blocks building up row at a time, just like how a computer printer prints onto a piece
of paper row at a time, or how a 3D printing machine builds up structures layer at a time.
You're getting quite good at building programs now and each new program you build is
larger than the last one. Just like in the previous adventure, where you built your pro-
gram out of functions, you are going to build this program up in steps.
The technique of writing the different features of a program as functions and then
stitching them all together into a bigger program is a very common development
technique used by professional software engineers. It relies on the principle that
a big program is just a collection of small programs. Providing that the design of
the overall program is correct from the start, the detail inside each of the support
functions can be filled in gradually as you build and test your program. I always like to
have demos handy so that if someone comes up to me and says, “Wow, what's this
great program you are writing?” I can very quickly show them something that works.
 
Search WWH ::




Custom Search