- Looking around the room I can see up,
there is a read first instruction,
and I guess that's what I was supposed to read first.
So I'll close and actually show you how play the game.
So let's get started.
(upbeat music playing)
- Hi, welcome back to "Coding with Qiskit." This is Ab.
In today's episode, we'll be talking about games.
So games tend to be the first application
in almost any new type of technology.
For example, we've seen games
like CryptoKitties developed in blockchain.
We've seen, competitive gaming, like AlphaGo,
in artificial intelligence, and quantum is no different.
The nice thing about quantum is that the field is so young
that this is great opportunity for you to develop games.
So if you're interested, there are generally two ways
that people have been building these games.
Where you take OpenQASM code, you populate a string
with, the blocks that you're creating,
and then run that string with a simulator.
And, another way to do it is to write the game entirely
based on Qiskit.
So, using Python to generate the circuits
instead of using OpenQASM.
Generally people have found that
because the simulators are more readily available,
they're much easier to integrate into games.
In this episode we'll be covering,
a particular game called QiskitBlocks.
And this game was developed
by one of our star developer advocates, James Weaver.
So QiskitBlocks uses this Minetest,
as an opensource voxel game engine.
And Minetest is essentially like an open source version
of Minecraft, that you can then use
to play any voxel type of game.
So voxel just in this case refers
to those block looking objects in Minetest,
and those are units of graphic information
that define a point in three dimensional space.
So to give you an idea of what you need to do
to install QiskitBlocks,
the instructions are found
in the readme of the GitHub repository for QisketBlocks
and this, is a James Weaver's GitHub page.
So, you can look at that, readme, and we'll put a link
to that file in the description below.
But effectively,
what we're going to do is install Minetest first,
and then install the QiskitBlocks world.
To download it and install Minetest, the website
that you go to is https://www.minetest.net.
Once you have mine test installed you can open it.
And I have Minetest installed already.
This is what it looks like.
Once we're here, the first order of business is
to download, QiskitBlocks World.
So, we'll go to content,
and we'll say, browse online content,
and type in QiskitBlocks, and hit search.
And you should see the QiskitBlocks option here.
I already have it installed,
so I only see how to install it,
but in your case, you'll be able to install from this page.
Once the installation completes,
click the back to main menu button,
and now you should be able to go to start game,
and switch to the QiskitBlocks world.
So once you're at this world page,
you can now uncheck all of these options.
Click new here, to create a new world.
You can type in a name for the world
and that is something
that has to have, alpha and underscore character.
So something like, Ab_world works here.
Choose zero for the seat,
and choose flat for the mapgen,
and choose QiskitBlocks for the game,
and you can click the create button.
In my keys I've already created a world called,
"Coding with Qiskit world" here.
So, what I'll do is click on that world, and say, play game.
So now that we're here, we can start playing the game.
At any point, you can learn more about the game controls
by pressing the escape button on your computer,
which will take you to this screen
that shows you the keyboard shortcuts.
So, as we begin we're in the starting room,
and this starting room has all the quantum operations
that we've been seeing throughout this video series.
And in fact if we want to learn more about each one,
we can right click this question mark button here.
So to get closer to it,
I can use the navigation buttons, W, A, S and D.
So pressing W takes me closer,
and I can right click to learn more
about what that particular gate does.
Looking around the room I can see up,
there is a read first instruction,
and I guess that's what I'm supposed to read first.
So let's get closer going to this page, tells you
how the game works.
So you can read through this instruction to find out
what the objectives of the game are,
and what the structure of the game looks like.
So I'll close and actually show you how to play the game.
So let's get started.
So what I'm going to do is start by walking around this room
and seeing what's available around me.
So in this world, there are three main areas,
and they are quantum cat's sandbox,
the quantum circuit garden, and the puzzle rooms
in this particular building where we are.
So there are also some areas under construction
with a few quantum circuits in them,
and some minecarts that will take you to them quickly.
So let's go to the puzzle room.
Okay. Going back here, it looks like there's a hidden room,
and there's a ladder.
The ladder wants us to go down.
So I'll get close to the ladder, and hit Shift to go down.
So clicking Shift, I'm at the ground floor now,
and it looks like we have a series of boxes to play with
and what looks like a quantum circuit.
So let's figure out what we're being asked to do.
So there is a chest here
with a question mark sign above it,
and we see, this one out of 16 sign
which tells us that we're on puzzle number one.
So let's right click the question sign
and it tells us, this circuit, consisting of only one wire,
leverages is the X gate also known as the pauli-X, NOT
or bit-flip gate.
So, let's look at the circuit.
So the objective of the circuit is to take us from zero,
to, the state one here, and to do that already we've seen
that this is done using the X gate.
So where is the X gate?
The tool for the X gate comes from this chest.
So I'll get closer to the chest,
and hit the right click button,
and now it gives me this tool.
So I'll add X to my toolkit,
and walk toward circuit and,
place X.
That's a nice sound. That means I did something good.
You can see that the bloch sphere has also changed
to reflect the state
that has changed from, up here to down here.
So that's mission one out of 16.
Let's go forward to another room, and find another circuit.
Again, let's look for the question mark.
It's right here. It's number two out of 16.
Question mark says this circuit consists of two wires,
demonstrates that one or more X gates may be leveraged
to create a classical state.
Let's see what it looks like.
So we're trying to go, to the one zero state.
So in Qiskit the way the state is read is
by putting one here, and zero here
so, I'll apply an X gate here.
So let's pick up our tools again.
So I'll hit right click and, get my X tool,
and then place it on to this particular box.
So, one thing I should also point out is,
you see this blue box here?
You'll see that the intended solution
for this problem is up here,
and you also see another blue box.
The idea here is that the amplitude,
the probability amplitude of the circuit
in its current state, is shown in blue here,
and the phase is represented by this arrow.
So we intend to make this box look like the box above.
So, let's put an X gate here.
At this point, the box looks like the one above,
and we've created the state that we desire,
which is one, zero.
And you see the block sphere shows us
that this qubit has gone from the zero state,
down to the one state.
That's two out of 16.
Let's go forward.
(Abraham mumbling)
But I'd like to give you some tips, in particular
so, let's walk back out of this room.
And, one thing you might have noticed
I've been walking very quickly so far.
It's because I have fly mode enabled.
You can enable and disable fly mode
by clicking the K button on your keyboard.
So you can see, I have it enabled, and disabled now.
So, if I disable it, the walk will be fairly slow.
So let me speed it up and, go back to the first level.
So I enable fly mode.
(Abraham mumbling)
So I'm stepping outside of
that very first room where we were.
And the place I'm taking you to will allow us
to play the quantum teleportation circuit in a QiskitBlock.
So, you see these yellow boxes,
we're going to follow those yellow boxes.
So, teleportation is hidden in this space.
So you see this fence. I'm going to walk toward it.
And in particular, once I get close,
you see this box with this series of elements,
so that's our circuit.
I'm going to hit Shift to go down,
and try to land close to the circuit.
Let's go back a little so we have a better view.
This circuit should look very familiar to you
from our quantum teleportation video.
It shows you a teleportation circuit.
These are the two qubits
between which you're creating entanglement.
And, you're teleporting the state on this qubit
onto the third qubit.
So to complete the circuit, you need to insert a block here,
and, you have the measure Z, the measure Z up here,
and you're applying a Z gate
and you're applying an X gate also
depending on the measurement, of those two qubits.
So this is a very familiar teleportation circuit,
that you might remember from our video.
So we have the two qubits
between which we have our entanglement,
and we're teleporting the state from this cubit
onto this third cubit.
So instructions for solving this particular circuit
can be found here.
So again, right click,
and you'll see this circuit
demonstrates quantum teleportation.
To complete the quantum teleportation circuit,
grab a classically controlled IF block.
So the trick here is that you have, this missing box here,
which tells you that you need to apply a Z gate conditioned
on a classical result.
So you'd find that classical block there,
and place it into its respective space.
So I'm going to go back to the chest,
right click it, I see a series of tools here.
So in particular, I want the classical control here,
and I'm going to take that and the control tool as well.
So I'm going to move forward,
and place, the classical control tool here.
And you see now, that there is an indicator here,
which tells you the line, which corresponds to the qubit
where that control is coming from.
So you see for the X gate,
you have the second line activated,
which means that X gate is conditioned
on the second qubit being one.
This is Z gate has the first qubit, so that's correct.
But the condition says, if it's equal to zero.
So let's right click again,
and if we change it to, if it's equal to one,
you see we've solved this particular puzzle.
That's exciting.
So now let me show you something really cool where we learn
how this game actually works.
You see this Q picture here,
so, what I'm going to do is get closer to it
and then, right click.
When I do, you see the QASM code
that's generated from the circuit,
and this is the QASM code that's being run,
to check whether or not you have the right circuit.
So in fact, if I take this QASM code,
so I'm going to copy it to my clipboard, close it,
take Minetest out of full screen mode,
and then go to my browser
and go to https://quantum-computing.ibm.com,
and go to the composer.
I can click create new circuit.
I can go here and paste in the QASM code
from that circuit we saw in Minetest
and indeed you see that the circuit
that's generated is exactly the one we had there.
So here's your controlled gate that you inserted for.
So this is the control on a classical bit.
So this bit is coming from measuring this particular qubit.
So this is exactly how that game checks
if you have the right answer or not.
So this is probably the first time
that you're seeing OpenQASM code.
So you can think of OpenQASM
as a simple text-based language,
to describe quantum circuits,
and QASM stands for Quantum Assembly Language.
So there's a nice paper here,
that describes the entire OpenQASM assembly language,
and gives you an idea of the details involved
in describing quantum circuits
and different components, in this kind of way.
So let's take a look at how QiskitBlocks works.
So I'm at I'm back at the GitHub page for QiskitBlocks.
If I go to the QiskitBlocks folder,
and go to the mods, and in particular what I'm looking for
is the Q_command folder,
and this file called init.lua,
and you can see that these are the instructions
that are building the quantum circuit out of, the blocks
that we're putting down.
So to find out exactly how this code interacts with QASM,
you can look for, compute_circuit, on this page.
So it looks like this compute circuit function,
takes it in the parameters of the circuit,
and then populates this string qasm_str,
with, first, it starts with this line,
and then builds on it
by adding different components from the circuit.
And eventually, it takes this QASM string
and runs it on an IBM Q simulator.
So let's remind ourselves what we've done today.
So, we downloaded Minetest,
which allowed us to have then a QiskitBlocks world.
And that's where we've played our games.
And, in that game play, we learned
how to solve several different quantum circuit puzzles,
and in particular, we also learned how that game works
by integrating OpenQASM into its functionality.
So, we saw that the OpenQASM code that it creates
can be pasted, into the IBM quantum experience
and, you can see the circuit that it's building
and the runs that it's doing in the back to simulate,
and find out the puzzles that you're solving.
Hopefully this inspires you to then think of ideas
that allow you to build your own games based on OpenQASM.
If you'd like to see some of the games that have already
been built using Qiskit and OpenQASM,
take a look at the link that we've placed
in the description below.
So this was our ninth, and last episode
of "Coding with Qiskit" on YouTube.
But, the good news here,
is that we're just getting started here,
and we plan to have more videos coming your way.
So please like this video and subscribe to our channel
so that you don't miss out on any of our new videos.
I personally would like to thank you for your attention,
as we presented all these videos,
and for your comments that allowed us
to take in your feedback,
and improve them as we went along.
And I hope you do enjoy our next videos.
This is Ab. Checking out
(upbeat music playing)