Hardware Reference
In-Depth Information
Depending on where your player is standing when you build your houses, and
how much other terrain is around, like trees and mountains, you might get some
interesting effects on some of your houses. One of them might chop off half of
a tree, or be partly built into a mountain. You might even get some interesting
subsidence if your houses end up being built on top of the sea! You might like to
modify your house() function to build a layer of bedrock under the house so
that it is always on solid ground.
Adding Random Carpets
At this point, you should have a huge number of houses inside your Minecraft world
and things will be looking pretty awesome. From a small number of lines of Python
code, you've built some large engineering structures already!
However, you're probably thinking that having a street of identical houses is starting
to look a little boring. How can you make the houses slightly different to add interest
to your street?
One way to do this is to write a few different house() functions like cottage() ,
townHouse() and even maisonette() , and modify your program to use these dif-
ferent functions at different places to add some variety to your street designs.
Another way to make your structures more interesting is to slightly change part of
them, such as the carpets, in a way that is different every time you run the program.
This way even you, the programmer, won't know quite what you have created until you
explore all the houses!
Generating Random Numbers
Computers are very precise machines. In many aspects of everyday life, we all rely on
computers to be predictable and to do the same thing every time a program is run. When
you pay £10 into your bank account, you want to make sure that exactly £10 makes it
into the part of the computer's memory that holds your balance, every time, without fail.
So the concept of randomness might seem quite unusual to such a precise system.
However, one area where randomness is really important is in game design. If games
did everything exactly the same every time, they would be too easy to play—not fun or
challenging at all. Almost every computer game you play has some kind of randomness
in it to make things slightly different each time and hold your interest.
Fortunately for your Python programming, the Python language has a built-in module
that will generate random numbers for you so you don't have to write the code for
this yourself, just use this built-in random number generator instead.
 
Search WWH ::




Custom Search