COMPUTERS DON’T THINK. They aren’t capable of having any thoughts at all; they can only ever do what programmers tell them to do. You can, however, make computers look like they are thinking and making decisions by themselves. By programming your computer to “understand” what’s happening and giving it rules to “decide” what to do next, you can open a door to a lot of fun.
In this adventure, you are going to program a block friend who will follow you around, provided you don’t get too far away. You are also going to create a flying saucer that chases you until it can get above you and beam you aboard.
You will learn how to make a block move and follow the path it decides is best, as well as how to use the Python random module to make it look as if the computer is thinking. You will also create shapes using the MinecraftShape functions in the minecraftstuff module (which is included in your starter kit).
Your Block Friend
Minecraft can be a lonely world. But your player doesn’t have to be alone—you can create a block that will follow him around, talk to him and be his friend (see Figure 8-1).
To program a block friend you need to think like her! She will be happy if she’s near your player, ...
Get Adventures in Minecraft now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.