 Okay, so hopefully you're ready for more Pokemon, so I'm going to talk about the Pokemon data structure. So before I start, there's the pet slide that everyone must have. And I want to tell you a little bit about me, also, so I've been playing Pokemon since 1999. I've written papers on Pokemon in undergrad. I spent 400 hours playing Pokemon on just one game. So I'm one of those children who never recovered. Okay, so what is Pokemon? Well, Alex already covered this yesterday, so thank you. I get to spend more time on content. So Pokabank was an app that was released by Nintendo, which is a company that makes Pokemon, initially only opened to Japan. And so many, and the app is used in order to store Pokemon, so users can upload their Pokemon onto Nintendo servers. And the servers were so flooded with Pokemon just by Japanese Pokemon by players in Japan that they had to close down the servers and then delay the worldwide release for several months. The thing is, Pokemon are tiny. So we can count in units of Pokemon. So let's say that one hour of a Netflix stream is 792 megabytes of data. And one Pokemon is about 232 bytes currently. So if you do a little bit of math, that's 3.4 million Pokemon that you can stream using the same data as Netflix, it's one show. So let's get into what Pokemon are and what sort of data is stored in them. So Pokemon have stats because they battle each other. They have characteristics. They also have species. So you can see here are some examples of what that looks like. And also here is the UI of the display of all the Pokemon's information. So there's a lot on here and you can see that. And there's actually more pages. So that's quite a bit. So now that we kind of know what a Pokemon is, let's look at the actual data structure. So I'm going to start on binary and we're actually going to get into the hex. Put everything on a computer stored in binary, don't panic, it's going to be okay, but this is a Pokemon. This is a second generation Pokemon. And you can't really read this unless you're new from the matrix. So let's make this easier for us. So eight bits, eight binary numbers make up one byte and that's usually how computers store information. So we can divide this up and it looks nicer, not really. This is not easy to read at all. So don't panic, don't panic. So we're going to change this into a hex, which is hexadecimal. It's another counting system that's in base 16. Basically take the first four binary bits and we take loss four, we transform them into hex numbers. So this is zero three in hex. We can do that with every single byte in here. So I've done that for you. So this is the Pokemon now. Still not easy to read. So the way that we can change this into something that's parsable by humans is through encoding. So basically we represent letters of the alphabet and characters as bytes. Just like Unicode. Thanks, Marissa, for talking about that yesterday. So we humans can use an encoding table to figure this out. So this is just from Bulbapedia and we can do that with a string right here. And this is a Pokemon's nickname. So we'll see how this works. So if we take the string, these bytes, we can map them out onto the table. So we take the first byte right there, 95, and we can just line it up with the table. So we take the nine, we align it with the vertical axis, and then we take the five and we align it with the horizontal axis. We figure out where it meets the middle. That's a V. And then we just replace it right there. So we can keep on doing that for the whole entire string. So evinosaur, 50 right there, 50 the byte is just a control character that says the string is ended. And then after that, the rest of it is junk. So this turns out to be very hard to figure out on Macs if you're trying to use a hex editor. As I found out, when I read these instructions and thought it was easy and then I got into encoding systems and then I downloaded Homebrew, I'm not a programmer, so this is very difficult for me. I started using Xcode and just kept on going and then I was up at 4 a.m. the day before work. Don't tell my employer. Okay, so going back to where these bytes were, so we noticed that the string was actually a lot longer than needed to be. And this is because Pokemon are stored in the structure where the location of the bytes matter. So no matter what the nickname of the Pokemon is going to be stored in the same number of bytes, it's going to be stored in the same location. So you can see the different areas that store different things and different colors. So you can think of the Pokemon as like a network packet. So this is like a packet map and everything is stored according to location. But how can we encode everything in such few bytes? Because we saw before that Pokemon had all this information plus more. So let's focus just on the species of the Pokemon and all the information stored with that. So the Pokemon species has a species name, a number based on that species moves. These are all the same for all the Pokemon of the same species. So how do we do this? Well, we can just use pointers, which makes it easy because a pointer is a value that is an address to a different location that stores the information that you need. So for example, you can store the species information, all of it in a different place and have pointers that point to it in the Pokemon data structure. So that's kind of like a Pokedex, right? So basically the species information stored in one byte right there and it just points to the Pokedex entry right there, so Venusaur, so we got it. So that makes it easy and the extra benefit is if you add more information to the Pokedex, you don't have to change the data structure at all, which is also great because we have like 700 Pokemon and more. Okay, so now that we know how the Pokemon data structure sort of works, let's see how it's changed over the years because the games have continually updated. So generation one, generation two mappings are pretty much the same. There are a few changes, a few things have been shifted around and it's been improved, but they're pretty much similar. So generation one, generation two, you are forwards and backwards compatible. You can trade Pokemon back and forth as long as you're not trading stuff from generation two into generation one where it doesn't exist. And then bad things happened, well not necessarily bad things, but a new console was introduced, so the Game Boy Advance, which is in 32 bit instead of 8 bit like the previous games and consoles. So you can no longer trade Pokemon from generation one and two over to three because there are issues with the hardware, there are also data versioning issues and also Pokemon, the Nintendo company added encryption because they don't actually want you looking at these fights. So you can see all the yellow stuff is new in generation three mapping compared to the generation two mapping. So nothing was compatible anymore and that caused issues initially. But after that everything was pretty great because everything is forward compatible from that point on because they thought about the Pokemon company thought about how they would make things work for the future. So for example, you can catch an Onyx, a shiny Onyx on your Game Boy Advance and Pokemon Fire Red, transfer over to your Pokemon Diamond, transfer, change that and evolve your Pokemon into a Steelix, transfer over into Pokemon Black, transfer that into Pokemon Bank, PokeBank, which we talked about earlier, transfer that over to Pokemon X and then transfer it to Pokemon Sun. So this Pokemon is 10 years old, actually, which is great. So you can have a data structure from several, several years ago that's compatible with all forward games, which is really cool. So I have two minutes left, so I'm actually going to show you how this works in a hex editor. So I have a Pokemon here that I've created through a Pokemon editor online. I wanted to show you a Generation 3 Pokemon, but unfortunately because of the encryption that didn't work. But before you could actually edit the hex code in a game and put in this Pokemon, you could insert it into the game. So this is a Pokemon in the hex editor with the mappings associated with it. So you can see if I highlight this, this is a Pokemon's nickname and you can see that I've also included the encoding in here, so you can actually read it. So with that, we can also create a new Pokemon. So someone shout out a Pokemon that they want. Okay, I heard Squirtle. And we're also going to say the owner is Bing-Bing-Con. What should we name it? Anyone? Okay. I heard of that. So now we just save this, hopefully. Okay. That was not the right spelling. And then we can open it in a hex editor like this and we can see all the information here. So this isn't really helpful unless we have the mapping over it. And we can see that we have in fact successfully created a Squirtle name squirt and it is owned by Bing-Bing-Con. And that's it. Thank you.