 This is the third talk, Hackerself, which is the highest record now. Yeah, yeah. Five in the middle. Now, I always see that if I come to a meetup, I might as well give a talk so that, you know, make use of my time. Anyway, so I was preparing a class for Python beginners, and I wanted to use something interesting that they might find motivating. I thought there's this project that came out a couple years back from Microsoft called Project Malmo. Project Malmo is actually a Minecraft plugin. But it's interesting because it's a Minecraft plugin that comes with Minecraft. So if you install, it's an open source project. So if you install Project Malmo from its GitHub page, you also get a copy of Minecraft. No license required. But you can't play online. But you can play locally. Any case, the idea of Malmo is so that you can create an intelligent agent to play the game for you. But not play the game, the game, in Malmo you can design missions. So there's this XML format that they have created where in the XML format you describe the mission and you can write the, you know, the brain of the agent to solve the mission. So here I think there's this GIF, which is a mission to collect, to walk to the lapis lazoo block. The diamond is just to show you where the block you're supposed to go. So this is sort of a navigation mission. You start off as a certain point, you need to navigate the agent into the target destination. Okay, the problem being that this is a class for Python beginners, but the tutorial they have, so this is from the Malmo repository and this is their Python tutorial. So if you run, they have a PDF tutorial and the tutorial is in Python. So if you go through the tutorial, you have to run this tutorial one, which is a little bit hard for Python beginners, I think. Part of it is because they had to support both Python 2 and 3. You can see from the beginning, the first part is to do with the print statement. But also part of it is to do with sort of handling errors. So a lot of it is to do with, how it works is kind of as a server client architecture. So when you start the plugin, the plugin access a server and then this Python program is the client, you will connect and talk to the server. And then there's this C++ library at the back end that does the communications. So this is the Python wrapper around the C++ library. Yeah, so there's a lot of this error handling and then restart, if you connect to the server and then you need to wait, because when you connect to the server, it's got to build the level. You can instantiate all the blocks that takes a bit of time. So you got to wait until the world is ready. And then when the world is finally ready, then you can run your mission, which is the last part while the mission is running. And so when you get the world state, that is the observation, that is how the agent observes the world and then you perform your actions, right? The classic sense, plan, and act loop of agents. As you can see, this is like already, okay, but minus the big license at the beginning is quite a lot of code for a beginner. So the goal of the library really is to make it much easier. So let me show you the end result anyway. So this is the one. The goal is something like this, which is a little bit better, I hope. So we just load the mission, say which mission XML, and I think this is the really neat part. So instead of this while loop and all that to get the observations, we just use the standard Python iteration. So we iterate over the sequence of iterations, the sequence of observations, and then we inspect the observations. In this case, we're checking the floor. Is it air or is it not air? This is the left-hand rule. So you can do simple actions like move, dot move, and dot turn left. I think in original Malmo, it's not a tutorial. You had to do like the API is something called send command. So you say send command and give it a string. So send command string move one means move forward. And then I think something like turn minus one means turn left, and turn one means turn right, which is again a little hard for people to remember and type the string correctly and so on. So in the library, I just made it into like a single function. So like just turn left and turn right, literally, instead of saying turn minus one, which was the original C++ API. Yep, and then what else? Yep, that's pretty much it actually. So currently at this point, this is built mainly to support the course I was doing. So it doesn't have all the support for the full C++ API, because actually this also supports things like the continuous mode. So if you ever played Minecraft, you actually know that when you move, like you press W, it doesn't move in chunks of one meter. It actually moves in sort of like a car, right? But if you notice in this screenshot, actually it moves sort of in the discrete chunk, because I felt that for the course for Python beginners, it's easier to have them move and you move just like one unit and see how to remember like move and then stop moving after five seconds, because like a car, you would do that, right? You press the accelerator and then you stop pressing, which is a little bit harder for people at the beginning. So it doesn't support the continuous mode at this point. So right now it has just the basic abstractions for the ones I was using for the class. So there's always more to do to make it fully compliant with the C++ API. Okay, I think that's almost time, so which is good. It's just 10 seconds for questions. Yes. Question, what does turn zero do? So you said turn one. I have never tried that, but that's a good point, right? So what is zero? I think, I guess it just doesn't do anything if it doesn't matches any of the minus one or one. And I think the non, there's also continuous turns where it changes the angle continuously. So turn one is 90 degrees to the, yeah, 90 degrees to the left. One is 90 degrees to the right. Minus one is 90 degrees to the left, yeah. Don't say it was just like nothing. I guess you can think of it as not turning, right? Because it's not really turning, yeah. There's also move minus one, which moves backwards, but we really had to do move backwards in the missions. Yeah. How have your students found this, like, easier or harder? I think it's okay because I think, I personally think using the library helped a lot because it's a lot shorter. I mean, like, there's not a lot of busy work to do with error handling. I mean, it's all, it's still the same code actually. So I just took, what I did basically is I just took this code and just write Python methods around each of the things. And it's all hidden behind the Python library, right? So they've actually felt it was quite okay. But I guess trying to teach the left-hand rule in like a one-hour workshop was too much. So I guess they didn't really get to the left-hand rule part, yeah. But they could figure out like how to turn and move and stuff like that, yeah. Was the class like just, like, was the point of the, was it like was the goal, the objective of the class to teach them Python or to help them control Minecraft or to use it in one? The class was supposed to be after they did like a Python 101. So they know like Python, like list dictionaries and stuff. So this class was more like an applications class. Like what can we use Python for? So in this particular class I was trying to explain, like you can use Python to control robots. But I didn't want to deal with like hardware. So Project Mammal is sort of like a robot simulator, right? So we simulate this robot in this environment. And the environment's quite rich, as you can see. You can have things like, you know, lava pits and lapis lazoo and all this kind of thing. So, so it's just that. So in this, I think we're doing different examples. Like maybe you can imagine, like if you could program like a vacuum clean robot, that was one of the examples we had. How would you make it move around so that it covers all the tiles, right? But of course here is simplified. So when you move, you literally always move one meter forward and when you turn, you always turn 90 degrees. In the real world it's much more complicated. But even then we're just, we're focusing on the logical part of it. How would you design the policy of the agent in a logical way? Yeah. Okay, I think that's it. So I think, go check out Project Mammal. It's an open source project, MIT license, I think. Also same as my project, it's also MIT licensed. Yeah. So give it a try. Oh, actually by the way, it's actually meant to be used for, I didn't say, I mean to say a little bit about Project Mammal. It's meant to be used for, it's original design was meant to be used for human robot collaboration. So the idea is that you will have someone who plays it as the human and then you have another program which is the robot and the robot will help the human achieve whatever he was trying to achieve in the mission. That was sort of the grand goal of Project Mammal. This human AI collaborative environment. Do you think it succeeded? Not much. Well yes, because they ran a project which was, they ran a project actually which is to help the human agent corral a pig. So in Minecraft you have this pig. So they had this environment where there was a pig and there was two agents. One was human, one was AI. So the AI had to help the human trap the pig. So the AI had to observe how the human being was moving in the environment, right? And then you had to trap the pig in some kind of like a corner. So you can read more about it on the Project Mammal website. I think there was NTU student who won the first place and he published a paper on it. It's called Hock Rider, H-O-G-R-I-D. That's the, that's his agent. You can read out more about that in his paper. Yeah. Right? Okay, thank you. Thank you.