Grade Levels: 3-5, 6-8

This lesson plan, adaptable for grades 3-8, features the game CodeCombat: Ogre Encounter, in which players use computational thinking and computer programming to solve puzzles  framed as mazes.

The hero of the game starts at a particular place and has to navigate to the goal without running into spikes or being spotted by ogres.

Some students may want to delete their code every time and only type the next step. Explain to them that the code must contain all the instructions from start to finish, like a story: it has a beginning, a middle, and an end. Every time you click Start, the hero returns to the beginning.

Lesson Plan Common Core State Standards Alignments

Students will:

  1. Use Python syntax.
  2. Call functions.
  3. Understand that order matters.

Materials:

Vocabulary:

syntax, objects, functions

Preparation:

This lesson plan features a game, developed by our partner, CodeCombat, designed to expose students to their first typed programming language. Students learn to create a basic command, and then expand this knowledge to cover objects, function, and variable definition in coding. By the end of the four levels, players will have successfully studied Python coding's basic syntax, as well as created coding arguments and strings.

Review the CodeCombat Quick Start Guide to familiarize yourself with the code editor. Play the game to plan how you will adapt it to your student's needs. If students will be working in small groups, review tips on Setting Cooperative Gaming Expectations.

Print out class sets of CodeCombat: Progress Journal and CodeCombat: Engineering Cycle Worksheet.

Build background or reinforce topics with these BrainPOP movies: Computer Programming, Video Games, Computers, Internet, and Logic Gates.

Lesson Procedure:

  1. EXPLAIN (3 minutes)

    Syntax is how we write code. Just like spelling and grammar are important in writing prose, syntax is important when writing code. Humans are good at figuring out what something means, even if it isn’t exactly correct, but computers aren’t that smart, and they need you to write with no mistakes.

    code example: hero.moveRight() vocabulary: (object) (function) read aloud: “hero dot move right”

    Objects are the building blocks of Python. They are things or characters that can perform actions. Your hero is an object. It can perform the moving actions.

    Functions are actions an object can do. moveRight() is a function. Function names are always followed by parentheses. The order of functions matters!

  2. INTERACT (5 minutes): Recycling Robot

    Practice giving written instructions using Python functions in order. You (the teacher) are going to be the robot that the class controls using functions. The goal of this exercise is for the class to collectively write a program like this:

    teacher.pickUpBall()

    teacher.turnRight()

    teacher.moveForward()

    teacher.moveForward()

    teacher.turnLeft()

    teacher.moveForward()

    teacher.dropBall()

    The experience should introduce them to Python syntax (including the dot between the object and function, and the parentheses at the end) and the importance of order in a sequence of instructions.

    At the front of the class, set some scrunched up paper balls on a flat surface. Place the recycling bin a few steps away. Explain that you are a recycling robot, and the class’s job is to program you.

    The robot is a Python object. What is your name in Python? Whatever you choose, make sure it starts with a lower-case letter. Write it on the board.

    teacher

    To make the robot perform an action, you have to call a function. Write a dot after your object name, then decide as a class what the first action should be. After the dot, write the function name followed by empty parentheses. Off to one side, draw a “Run” button.

    teacher.pickUpBall()

    Have a volunteer press the “Run” button to run the program and test that it works.

    It is important that you reset yourself and the paper balls every time the code is changed, and run the whole program from the beginning.

    Invite students to add code to the program one at a time. If there is an error in the syntax, make a funny beeping sound and stop. Have the class work together to write and rewrite the program until you successfully get a ball in the recycling bin.

  3. REFLECT (2 mins)

    Prompt students to reflect on the the Recycling Robot activity by asking the following questions:

    Why is syntax important? (It lets you be specific about exactly what you want to happen.)

    Does order matter? (yes)

    Can a human understand the directions even if there’s a mistake in the syntax? (sometimes)

    Can a computer? (no)

  4. CODING TIME (30-45 minutes)

    Have students play the game at their own pace either with a partner or independently. Distribute the Progress Journal and instruct students to take notes.

    Circulate to assist. Draw students’ attention to the instructions and tips.

    If students have trouble breaking the problem down, distribute the Engineering Cycle Worksheet to reinforce the steps to solving each puzzle.

  5. WRITTEN REFLECTION (5 minutes)

    Select appropriate prompt(s) for the students respond to, referring to their notes.

    Tell me how to play CodeCombat.

    You have to move to the gem without hitting the spikes. I learned that you have to type “hero.” then the moving code. You have to spell it right and put () at the end. But it shows you the things you can type and you can click on them instead. You click RUN to make it go. You can try as many times as you need.

    What’s the difference between an object and a function?

    The object is the hero and she has functions that are things she can do. The object has a dot after it and the function has ().

    How can you tell when you’ve made a mistake in your code? How do you fix it?

    Sometimes the code doesn’t won’t run because there is a mistake in it. They put a red ! next to the mistake and try to help you. You have to read the code to figure out what’s wrong.

    Why is your hero in the Kithgard Dungeon? What is your quest? Are you a good guy or a bad guy? (write your own backstory)

    I went into the Kithgard Dungeon to steal gems from the ogres. I need to get a lot of gems to pay the ransom for my village, otherwise a big bully monster will destroy it and my family will be homeless. I think I’m a good guy but the ogres probably think I’m bad because I’m stealing from them.