Monday, May 25, 2015

Home construction and guessing game (5th and 6th grade programming)

Who: Baan Pathomtham 5th and 6th grade classes
Where: at school
When: Monday morning

We had our first class of the near year today! This term, we have an hour for each grade; initial impressions are that this will work well.

Fifth Grade

We started the new class slightly differently than last year (notes here). Our agenda for the day:
  1. talk briefly about what we will be doing in the class
  2. get everyone set up with a computer and account
  3. start playing with code based on this worksheet.
What will we be doing?
None of the students seemed to know what we would be doing, so I got to set the agenda:
  • telling computers what to do
  • playing and making games
  • experimenting and exploring
  • learning about programming, geometry and algebraic thinking
  • creating art
I'm sure there are other things, but this is enough to anticipate now.

Setting up
Pretty mundane, but a reminder for anyone who wants to follow along at home:

  1. open a browser
  2. go to pencilcode.net
  3. click the New Account link in the upper right part of the page, enter your username, make up a password, and you are running. 

We experimented with dragging in blocks of code and typing directly. You play (run) your code by pushing the blue triangle button in the middle of the screen. during the class, I showed a couple of examples of typing commands into the test panel, but will flag that more explicitly next time.

Don't forget to save your work! Just hit the handy save button on the top of the page.

Our play
The essential structure of our class is that we give everyone selected code or concepts to explore, usually with some mini-project as an organizing objective. As the kids play, we will flag ideas that someone has discovered or highlight difficult points. During this class, three of these came up:

  • computers are dumb. Sure, they can do calculations precisely and quickly, but they only do exactly what you tell them. If you try to tell pencilcode pen pank to set the pen color, the machine won't know what to do, even if your friend could read that and understand you meant pink.
  • Order matters. getting dressed and then taking a bath is not the same as taking a bath and getting dressed. Similarly, these two snippets of code don't do the same thing, even though they each have the same lines of code:
First Version
Second Version
fd 100
rt 90
rt 90
fd 100
fd 50
fd 50

  • Some angle chat: How many degrees in a circle? What does it mean to turn right (clockwise) 90 degrees? What about left (counterclockwise) 180 degrees?
5th Grade Homework
The homework is to do the third and fourth exercises on the worksheet:
  1. make a sailboat
  2. draw and code your own picture

Sixth Grade

All four students are with us once again, so we are continuing their studies from last term. We will be reinforcing concepts such as if-statements, for loops, and functions (love, love, love functions!) Of course, there will be a lot of mathematics in the work as a natural part of their programs. The other area we will discuss explicitly is the process of writing developing a program. I'm not dogmatic about a set recipe, so mostly we practice different strategies, tools, and concepts.


Guessing Game
One initial focus will be building and extending a simple guessing game. I gave them this sample output:
Guess my number.
You get 5 guesses.
⇒ 25
Too big!
4 left.
⇒ 10
Too big!
3 left.
⇒ 5
Too small!
2 left.
⇒ 7
Too small!
Last guess!
⇒ 8
Too small!
Game over.
It was 9.
Their challenge: figure out the rules for this game and create a program to implement it.
This is a simple game, but a great review as it necessarily uses if statements and loops. If you want, you can even throw in a function.

Where will we take the guessing game?
We will also follow the ideas that the students have, but here are some of my plans:

  • helping game 1: as long as the user makes sensible choices based on the feedback (Too small!, Too big!) then you always let the user win on their last choice. You can choose whether it is possible for the user to win earlier.
  • cheating game: you always lose. The computer keeps track of your guesses and then tells you that the real answer was something you didn't choose. Of course, this would be easy for them to do with pencil, paper, and a friend, but how do you code it?
  • Visual game: create a way to show, visually, which numbers have been guessed. Some easy choices are list, number line, grid, but I'm sure there are other fancy things we can do.
  • Helping game 2: make the hints more detailed. Is the number even or odd, a multiple of 3, a square, etc. This will involve creating a collection of interesting facts about the numbers.
  • Pico-Fermi-Bagel/Mastermind: we've written about this type of game in our math class posts. It seems a reasonable project given the general theme of "guessing" games.

6th Grade Homework
Two homework assignments:

  1. Everyone is going to choose a project for this term and write a brief description
  2. Win is going to review his game from last term and explain to the class how to create a loop that will ask the user to keep guessing. (This opportunity to explain an idea will rotate through the class)

No comments:

Post a Comment