RasPi_ Attack of the PI Microrobots - Make a Voice Activated AI - Plus Build pyramids in Minecraft January 2018.pdf

(9208 KB) Pobierz
ESIGN
D
UILD
B
CODE
42
PI MICROBOTS
MAKE A
VOICE
ACTIVATED
AI!
ATTACK OF THE
+
Plus
Build pyramids in Minecraft
Welcome
The Raspberry Pi’s potential
for innovation in the field of
education is huge. We thought
we’d kick off our first issue
of the new year by taking a look at one
particularly innovative advance pioneered by
the Imperial Robotics Society from Imperial
College, London. Swipe towards the left a few
times and find out how Joshua Eldon utilised
Pi-powered micro-robots to teach robotic
behaviour classes providing multiple systems
for testing while using less space for
the arenas.
If that’s not enough ingenuity for you we have
some more that you can do yourself, such as
adding a voice-activated AI to your Google
Assistant and building pyramids in Minecraft.
Get inspired
Discover the RasPi
community’s best projects
Expert advice
Got a question? Get in touch
and we’ll give you a hand
Easy-to-follow
guides
Learn to make and code
gadgets with Raspberry Pi
Editor
From the makers of
Join the conversation at…
@linuxusermag
https
https://wwwfacebook com/LinuxUserUK
https //
f b k
Li
Linux User & Developer
U
D l
linuxuser@futurenet.com
Contents
Build Pyramids in Minecraft
Use Python to add 3D shapes
Pi Microbot
Tiny robots that teach
Google AI
Add an AI to Echo
Egg drop
Create a game with SenseHat
Warrant Canary
Protection from gagging orders
Handle multiple tasks
Do more than one thing with Python
Create 3D art pieces in
Minecraft using Python loops
Taking our Minecraft pixel art into the third
dimension, this time we’ll build pyramids with
Python loops
In previous issues, we started our series on
Minecraft pixel art, by coding some 2D art blocks.
This time we’re taking a different approach to
our art, by implementing an additional axis and therefore
bringing it into the third dimension. Well, technically,
everything is 3D in Minecraft, but previously we built some
rather convincing ‘flat’ pixel art. Now we’re taking it to the
next level.
We’re going to build a pyramid using while and for loops
in Python. This will save us typing lots of similar lines of code.
Spawning our coded creations is so much faster than placing
each individual block manually in Minecraft’s Creative mode.
If you’re using Minecraft Pi edition on a Raspberry Pi, no
additional software is necessary. We’ve also put together
a number of tools to ensure this hack works on Linux, with
a retail version of Minecraft. Therefore as a prerequisite,
we assume you’ve installed McPiFoMo from our previous
three issues. McPiFoMo includes MCPiPy by ‘fleap’ and
‘bluepillRabbit’ of MCPiPy.com; and Raspberry Jam,
developed by Alexander Pruss.
All Python scripts should be saved in the directory
THE PROJECT
ESSENTIALS
Raspberry Pi
Enviro pHAT
http://bit.ly/EnviropHAT
Minecraft
www.mojang.com/
games
Python
www.python.org
McPiFoMo
http://rogerthat.co.uk/
McPiFoMo.rar
Block IDs:
http://bit.ly/
MinecraftIDList
01
~/home/.minecraft/mcpipy/, regardless of whether you’re
running Minecraft Pi edition or retail Linux Minecraft. Be sure
to run Minecraft with the Forge 1.8 profile that’s included in
our McPiFoMo package.
Starter code and variables
Here’s the first block of code to start with.
from mcpi import minecraft
mc = minecraft.Minecraft.create()
pos = mc.player
.getTilePos()
x = pos.x + 2
y = pos.y
z = pos.z
height = 29
count = 0
blockID = 24
blockType = 1
Zgłoś jeśli naruszono regulamin