Hey there! Welcome to Code Bytes, where today we’re diving into a fun and educational adventure in a place called Monster Town. In this lesson, we’ll explore how a virus can spread among the monsters and learn how computer science can help us understand and control outbreaks. I’m Mike Harvey from code.org, and joining me is my awesome co-programmer, Taylor!
Hi, everyone! I’m Taylor, and I’m 11 years old. I’ve been coding for about four years, and I love creating web pages. Today, I’m excited to help you learn about coding and simulations.
This week, we’re celebrating the Hour of Code, where millions of students worldwide are learning the basics of computer science. It’s a huge global classroom, and we’re thrilled to have you join us!
In Monster Town, everything was peaceful until one day, a monster caught a virus. This tiny germ started spreading as the monsters continued visiting their friends. Soon, more monsters got sick, and everyone began to worry.
Luckily, the monsters discovered that wearing masks could slow down the virus spread. With this knowledge, we can use computer science to simulate the outbreak and find solutions.
We’ll use a tool called Sprite Lab to bring Monster Town to life. In Sprite Lab, sprites are like characters in a game. We’ll create healthy and sick monster sprites to simulate the outbreak.
First, we need to create 10 healthy monster sprites and one sick monster sprite. We can adjust their size and make them move around the screen to mimic real-life interactions.
In coding, an event is something that happens in response to an action, like clicking a mouse or pressing a key. We’ll use events to change what happens when a healthy monster touches a sick one.
When a healthy monster touches a sick monster, it becomes sick too. This helps us understand how quickly a virus can spread. By running the simulation multiple times, we can observe patterns and learn more.
To help the monsters, we can add masks to them. By clicking on a monster, we can change its costume to show it’s wearing a mask. This can slow down the virus spread, just like in real life.
Simulations like this one help us understand complex systems and test ideas safely. They show us the importance of acting quickly to control outbreaks and how small changes can make a big difference.
We’ve learned a lot today about coding, events, and simulations. If you want to try this activity yourself, visit code.org/outbreak. You can create your own simulations and share them with friends and family!
Thanks for joining us on this adventure in Monster Town. Keep exploring and coding, and we’ll see you in the next episode of Code Bytes!
Imagine your own version of Monster Town. Draw a map and design different areas where the monsters live. Think about how the monsters interact with each other and what might happen if a virus spreads. Share your map with the class and explain your ideas.
Using Sprite Lab, create a simulation with 10 healthy monster sprites and 1 sick monster sprite. Observe what happens when they interact. Try running the simulation multiple times and note any patterns you see in how the virus spreads.
Add masks to your simulation by changing the costumes of the monster sprites. Test how the spread of the virus changes when some monsters wear masks. Discuss with your classmates how masks can help control outbreaks in real life.
Learn about coding events by creating a new event in your simulation. For example, make a sound play when a healthy monster becomes sick. Experiment with different events and see how they change the simulation.
Write a short reflection on what you learned about virus spread and coding through the simulation. Share your thoughts with the class and discuss how simulations can help us understand real-world problems.
Sure! Here’s a sanitized version of the provided YouTube transcript:
—
Hi everyone and welcome to Code Bytes! In today’s lesson, we’re going to visit a fictional place called Monster Town, where a virus outbreak is about to happen. We’ll be using computer science to understand how quickly a virus can spread and what can be done to slow it down and help all the monsters get healthy again. My name is Mike Harvey, and I’m a curriculum development manager at code.org. Here with me is Taylor, my sidekick and co-programmer for today.
You want to say hi, Taylor?
Hi everyone! I am in sixth grade, I’m 11 years old, and I’ve been coding for around four years now. Most of my recent projects have involved learning how to make and code web pages.
Excellent! Thanks for sharing that, Taylor. Now, this week, as you already know, we’re celebrating the Hour of Code, and millions of students are learning basic computer science. Our code just passed 1 billion student engagements, reaching students in every city and every country around the world. We’re joined today by all of you and so many other students who want to learn to code in this huge global classroom.
It looks like even more students are joining us as we speak! We have a little map that some of you may have had a chance to flag yourselves on, so let’s see if we can pull that up and see where people are calling from today.
Take a look at this, Taylor. This is where all the people who are joining Code Bytes today are coming from. We have people all over the United States, and we’ve got participants from Europe and Asia as well. We even have someone up in Alaska! Taylor and I are calling from our homes in Maine today, which is in the northeastern United States. It’s 11 a.m. here, but it could be earlier or later depending on where you live.
Now, getting to the episode for today, we’re going to do three things. First, we’re going to learn to code naturally using a fun tool called Sprite Lab. We’ll be creating an outbreak simulator using events. If you watched Code Bytes yesterday, you had the chance to program your own dance party, and that activity also used events, so you’ll have a little bit of a head start. Don’t worry if you weren’t there for yesterday’s episode; we’ll let you know everything you need to know today. Finally, we’re going to learn how simulations can help us understand the world around us.
Feel free today to just watch and learn with Taylor and me, or if you want to try and follow along at the same time, you can do so by going to code.org/outbreak, and that will bring you right to the same activity that Taylor is going to be going through on her computer screen right now.
Taylor, do you want to share your screen and give us the lowdown on what’s going on in Monster Town?
Monster Town was usually a happy and healthy place. The monsters in Monster Town loved to wander around and visit their friends. One day, one of the monsters started feeling sick; the monster had caught a virus. A virus is a tiny germ that can make you sick. The other monsters were not too worried, so they kept visiting their friends. Soon after, two more monsters got sick; it was the same virus, and it seems they got the virus from their friend. The virus slowly spread to the other monsters who were nearby. The healthy monsters began to worry that they were all going to get sick, and the sick monsters began to worry that they were going to give the virus to everyone else.
Fortunately, after studying the virus, the neighbors of Monster Town made an important discovery: they realized that they were less likely to spread the virus if they wore masks over their mouths. With face masks on, sick monsters were less likely to give the virus to healthy monsters.
Thanks, Taylor! That worked really well as a story, but one of the great things about computer science is that we can actually make Monster Town come alive by writing some code. As I said a minute ago, we’re going to build a simulation of that story that Taylor just read using Sprite Lab.
Taylor, do you want to go ahead and click continue to move on to the next step?
Once it’s loaded, let’s see what we’ve got here.
Just a little bit of quick orientation: there’s a big green square on the left, and that is our space where the simulation is actually going to run. You can stretch that out with those little dots. In the middle of the screen, there’s a gray box that’s our toolbox, and if you click on those three labels, you’ll see there are different blocks inside. Finally, this big white area on the right is our workspace, and that’s where we’re going to be writing the code.
Taylor, where’d you go? Do you want to turn your camera back on so we can see you while you’re coding?
Let’s see what we need to do first. We’re going to start putting together the pieces of the simulation. Taylor, you’re in the driver’s seat for writing the actual code that we need.
To make Monster Town come alive, the first thing that we need are sprites.
What are sprites, Taylor?
Sprites are almost like our characters. They are our characters, essentially, but sprites are what we’re going to be using in this experiment to demonstrate what’s going on in Monster Town.
Great! If you’re using a computer game, you might think of sprites as being the characters, obstacles, or things that you’re trying to collect—anything like that, the little images that are controlled by the code.
We need 10 sprites to represent the healthy monsters—those are the purple ones—so let’s bring that block out and connect it underneath. Just like that, they appear! Unfortunately, we also need one monster that’s going to be sick, so we’re going to represent that monster with another sprite that has a different costume. We call these little pictures that show up for each sprite costumes, and that’s going to be a really important way for understanding how the simulation is actually working.
They’re looking kind of crowded. Is there anything we can do to make them smaller?
Let’s take a look and see if there are any other blocks we can use to change their size.
This one might do it! It says “set all size to 50.” Let’s bring that one out. In this case, 50 means 50, so it should change them to about half their size.
That’s going to give them a little bit more room.
There’s one really important thing that I feel like isn’t happening yet: they’re not really moving at all.
That’s the last thing we want to do here to get this feeling like a simulation instead of just a picture.
We have this block that says “all sprites begin wandering” in Sprite Lab. We can control our sprites with behaviors like wandering, and that’ll make them start to do things all on their own.
Let’s snap that in and see what happens!
Now, what are you doing there?
You hit the run button, and they’re wandering around the screen just like that!
Awesome! Why don’t you stop screen sharing for a second so we can talk to everybody about the next thing we need to understand to keep going?
There’s a computer programming concept that I mentioned earlier that we’re going to need to keep going with this project, and that’s called an event.
An event is when we code a computer program, and we can ask the computer to change what it does when the user clicks with their mouse or types a letter on their keyboard. Each button click or key press is called an event. An event could also be when something else happens, like two things touching on the screen.
We’re going to use this concept of events all the time as people too when we respond to different signals. For example, I’ve been enjoying taking my dogs out for hikes, and when I’m walking down a trail, if I see other people coming, that’s a signal that reminds me to make sure my mask is on straight, just to be respectful and courteous to others.
So, audience, we have a quick question for you. You’re going to need your clicker fingers in just a moment here. We’re going to put a poll up on the screen to see what you think.
Computer scientists need events if they want to change certain things to happen in response to other actions or to make programs more interactive. Which of these do you think is an example of an event?
We’re going to give you just a few more seconds to answer. The choices are: going to a birthday party, singing in a school concert, or tapping an icon to open an app.
Taylor, do you think you have a guess which one might be the right answer?
Personally, I think it’s probably tapping an icon on the app.
Let’s close the poll and see what the audience said.
Most people agreed with you! It’s interesting to see things like birthday parties and school concerts; don’t we sometimes think of those as being events too?
When we’re not talking about computer science, those would be great examples of events. In computer science, when we say event, usually we mean something happening in response to something else. In this case, when you tap the icon on your smartphone, the app opens up, and that’s the kind of event we’re talking about here.
Let’s see if we can take this idea back to Sprite Lab.
Taylor, do you want to share your screen again and move on to the next level?
Once it loads, we want to make something happen when a healthy monster touches a sick monster.
What do you think should happen when this healthy monster touches the sick monster?
I think we should definitely have the healthy monster get turned sick.
Right! It’s kind of strange saying we want that to happen, but that’s what we’re trying to model with this simulation.
I’m noticing there are a couple of new blocks of code down at the bottom. We have this block that says “when touches.” This is a new event block that says when the healthy monster touches the sick monster.
It looks like the next block of code that we need is already ready to go.
It says “change costume.”
Remember before we were saying that the costumes are really the thing that makes the simulation work? When we change the costume of the monster, it changes the appearance, but it also changes what happens in the simulation.
We don’t want all the healthy monsters to get sick; we just want the subject of that event, the one that actually did the touching.
So this code is exactly what we need!
What should happen differently now, Taylor?
When we run the simulation, the sick monster should turn the healthy monster sick.
Okay, let’s give it a try!
Let’s run that and see if your prediction is what happens.
As you can see, none of them are starting to get sick, but as more and more get sick, it’s harder to control the monsters from getting healthy once they’re sick.
Now, audience, if you’ve done coding before, you might have done a tutorial where you go through and solve puzzles. If you get the right code, you finish the puzzle and move on to the next one. I want to point out that what we’re doing today is really pretty different. We’re running a simulation, and the cool thing about simulations is they don’t happen exactly the same way every single time.
We’re not going to hit continue quite yet. What we’re going to do is keep playing, run the simulation again, and see if we can start to notice any patterns.
Taylor, why don’t you walk us through running this a couple of times and give everybody your thoughts on what’s happening? Is it the same this time, or is it a little different?
It’s similar, but with the coding, as you can see, if there are healthy monsters in clumps and a sick monster touches one of the healthy monsters, they can get sick, just like we modeled in the beginning of this activity.
Great! Let’s run it one more time and hit keep playing and reset it.
I heard you just say that when the healthy monsters are kind of clumped together, they can get sick much more quickly. This reminds me of real life, where we know that larger groups can potentially get each other sick more quickly than people who are spread out.
Good news: the simulation is working! It’s doing what you expected it to do. Bad news: the monsters are just getting sick, and there’s no way we can make them better yet.
Or is there? I think we’re ready to continue. Taylor, why don’t we see if we can help them out?
I remember you read the story at the beginning of the episode, and you were telling us about a discovery that could help the monsters of Monster Town. Can you remind everybody what that was?
Maybe we could help stop the spread by putting masks on the sick monsters or even the healthy monsters.
Great! It looks like there’s some extra code here.
Taylor, I think you might have already added some of the code that we need. Can we back this up real quick so that we can have everybody see what you’re doing?
Actually, do you see the purple stripe in the middle of the screen where it says workspace and then there’s a version history button? Can you tap on that version history button and then hit start over?
There we go! Okay, this is what we’ll see at the beginning.
Now let’s take a look and see what new blocks are in the workspace if you scroll down.
Cool! We have these new blocks that say “when clicked.” That’s another kind of event that can happen when the user clicks on something on their computer screen, like a sprite.
Taylor, can you walk us through how we can use these new event blocks to give the monsters masks?
If you see right here, we could put the blocks in, and when something’s clicked, it will change to different things.
I think we might actually be missing a block here.
Yeah, we need that change costume block again, don’t we?
Similar to the third round, we’ll use the block to make it so that when the sick monsters touch the healthy monsters, they get sick.
In this case, we’re going to change the monsters from what they were to a monster that has a mask on.
Let’s run this, and we want to go kind of quickly since we’re a little short on time.
Taylor, what are you doing with your mouse as you’re running the simulation?
I’m clicking on the sick monsters right now, and since they have masks on, they are not infecting our healthy monsters.
But we can actually put masks on the healthy monsters as well.
Cool! You did that pretty quickly, and it seemed to help the spread of the virus because you put masks on them right away, and only four monsters got sick.
If we tried this again and waited until half the monsters got sick and then started putting on masks, do you think anything different would happen?
I think if we waited, as you can see right now, the monsters are getting sick. If I start a little bit later when these monsters get sick, it’s going to be harder to get the other monsters to get masks on because a bunch of them will get infected faster.
I think we’ve heard from scientists too that when something like this happens, it’s really important that we all work together quickly to bring things under control.
Even though this simulation is pretty simple, it is showing us that the faster we act, the better the outcome.
We also saw earlier that the idea of clumping the sprites together could change the way things work out too.
This simulation is pretty simple and basic; it’s only about 10 lines of code, but we can learn something from it.
We’re a little short on time. If you’ve got to go, that’s totally okay, audience. But for those of you who are able to stick around, we have a couple of quick wrap-up questions for you.
In this activity, we programmed using events, so let’s think about other scenarios that work the same way.
Taylor, you can stop screen sharing now.
Great! We’re going to put up a quick poll. Which of these might be controlled by events?
The choices are: playing the same game three times in a row, when someone gets tagged that player becomes it, and a baseball team practicing before a tournament.
You’ve only had a little bit of time to answer, but look at that! 78 percent of people agree that when someone gets tagged, that player becomes it.
It’s kind of like the simulation we just saw, right? Where something changes about one of those objects when something happens, and that’s an exact connection to how events work in computer science.
One more question! We also created a simulation today of the virus outbreak at Monster Town. Last question: how can simulations be helpful in the real world?
The choices are: simulations can help us understand the world around us, simulations let you test out ideas quickly, cheaply, and safely, and simulations are a way to model complex systems in an interactive way.
What do you think, Taylor? Do you have any guesses here?
I think all of these are kind of accurate, but for me, I think it’s probably that simulations can help us understand the world around us because it feeds into the other questions.
Let’s see what people thought!
It’s interesting; it’s very evenly spread.
This is a trick question because all of these answers are valid. These are all potential benefits of simulation, so no matter what you picked, you picked something good in this case.
Great job, everyone!
That’s the end of our show for today. I want to give a big thank you to you, Taylor, for joining and being such a great co-teacher with me.
To everyone who has been joining us on the call, we hope you’ll finish this tutorial yourself too! Remember, it’s code.org/outbreak. You can go even further than we did and continue improving your models and simulations. By the time you finish, you’ll be able to share your creation with friends and family or even share a message about how to stay healthy when an outbreak happens in your town.
We hope you’ll continue joining us for Code Bytes episodes. One last quick thing just for fun that we thought we’d share: Taylor and I have known each other for a little while because about three years ago, I was one of her teachers when she was in third grade.
Taylor, I wondered if you could take 30 seconds or less and just show us what you’ve been working on.
Sure! This is an example of how computer science can help make our world a better place. I created a website recently, and this is just one example of things that you can do. On the left, there’s the code, and on the right is the result. I created a page with things you can do to contribute to helping to save the planet.
That’s such
Code – A set of instructions written in a programming language that a computer can understand and execute. – Example sentence: “We learned how to write code to make a simple game in our computer class.”
Bytes – Units of digital information that typically represent a single character, like a letter or number, in a computer. – Example sentence: “The image file was too large to send because it was over a million bytes.”
Monster – A character or object in a game or program that can be interacted with, often used to create challenges. – Example sentence: “In the game, we had to write code to defeat the monster and move to the next level.”
Town – A virtual environment or setting created in a computer program or game. – Example sentence: “We designed a town in our simulation game where each building had a different function.”
Virus – A type of malicious software program that can harm computers by copying itself and spreading to other files. – Example sentence: “We learned how to protect our computers from a virus by installing antivirus software.”
Coding – The process of writing instructions for a computer to perform tasks. – Example sentence: “Coding can be fun because you get to create your own programs and games.”
Sprites – Images or characters in a game or program that can be moved and controlled by code. – Example sentence: “We used sprites to create animated characters in our video game project.”
Simulation – A computer program that models a real-world or imaginary situation for learning or entertainment. – Example sentence: “The flight simulation helped us understand how pilots control airplanes.”
Events – Actions or occurrences that a computer program can respond to, such as a mouse click or key press. – Example sentence: “In our game, different events like clicking a button would make the character jump.”
Masks – Tools used in graphics and coding to hide or show parts of an image or to protect certain areas from changes. – Example sentence: “We used masks to create special effects in our photo editing project.”