Thursday 13 June 2019

Minecraft Pi - Creating a beautiful world to explore

I have two Raspberry Pi Model 3B at home, just collecting dust until recent months. Have tried configuring many SD cards to enable different operating systems to run on the Raspberry Pi, from NOOBS, Ubuntu Mint, Raspbian to Retropie. Each have their own features, as well as pros and cons in terms of complexity. That is a topic for another post, another day.

The focus today is on the Raspbian system. It comes with pre-installed programs such as Python IDLE, Minecraft Pi, Scratch, as well as many other useful softwares. Decided to work on Minecraft Pi to entertain my kid, so that I would not have to buy the app on Android for around 10 dollars. This version of Minecraft can be quite educational for the little ones. The aim was to satisfy some of his wants while testing a way to motivate him to learn more about computers. We built many buildings in this game together, over the local network. Here is an example of a house with a chimney and a huge castle next to it. Still a work in progress as we are digging an underground level for rooms.


Imagine having a whole city full of different buildings for different purposes, as well as pathways and natural landscapes. The job would be too big for two of us. Thankfully, this version of Minecraft also comes with a Python library to allow extra features that the GUI does not grant access to. To summarise, it is possible to search for other players, teleport to them, blow up dynamite as well as choose special blocks for special effects e.g. lava and water. The library allows the use of mathematics and logic to produce very interesting structures very quickly. Wrote a library in Python to allow customized buildings to be produced quickly, so that we can work on interior design manually. The library allows the use of different materials, as well as parameterized structures to fit in different spaces. It also has automatic routines to enable the levelling of land around the player, in order to build something on it (kind of like urbanization). Here is an example of what it looks like on the inside of the house that was built using a Python function, after the manual work involved in interior design.


Now we fly to the sky to have a look at some simple structures. The Python functions can produce  buildings that look like Stone Henge, as well as pyramids and glass domes. It is really all just mathematics. Notice the houses partially hidden by the fog. These were built using functions as well. One of them is a greenhouse.


Now we go back to the ground to have a look at the landscape. Managed to grow some nice plants in the greenhouse, Built a nice hedge around the greenhouse for completeness. Notice the dirt track on the ground. That was built using a function too. Just activate, and walk around the map from one part of the city to another, and that dirt track follows you.


Now we teleport to another part of the city. Wanted a castle on top of a hill (this is the first castle I built). The second one is a lot bigger (see first image). Castles are essentially made of modules. Just needed to put a few functions together to get it done. Materials can be chosen based on aesthetic preferences. The glass tower below is essentially made from the same function as the 4 towers in the castle. The nice looking red power ranger and spiral staircase were made manually. My kid managed to make the power ranger all by himself. Job done training his dexterity and creative mind.



Notice the gold building on the right. The dome below was created using the same function used to create the glass dome in another part of the city. The top part was built manually to look like a flower tower. Notice the link bridges. These were built and decorated by hand. Suspect my kid is going to become really good at First person shooting (FPS) games in future.



Now, back to the ground. Took much longer to decorate the castle than building the main structure. After observing my kid digging his way around the map and laughing to himself, I decided to dig a moat around the castle, as well as dig hidden tunnels around the castle. See the nice lighting effects produced by the torches. This tunnel leads to a corner of the castle where a cliff is.


Finally, the view of the exit of the tunnel, where there are waterfalls. The water can flow for real, and it can be quite difficult to navigate the waters in the moat. Enjoy the view. This setup costs around 200 dollars in total, including peripherals. Would recommend doing this with a kid to hone our programming skills instead of spending on expensive game consoles.