# Code.org Stage 10: Conditionals or Minecraft isn’t a total time-waster…

Queen of Hearts set some conditionals

Good news! I stumbled onto a great discovery today.  Apparently Coding is a lot like knitting.  I found this great article that compares the patterns in knitting instructions to coding.  If you’re someone that has a vague idea of how to knit, but can’t understand all this javascript goobily-gook, you MUST read this article:  Knitters & Coders: Separated at birth?   You’ll have a light-bulb moment, because I certainly did!  The article comes from the website Computers Science for Fun (CS4FN) from Queen Mary, University of London. There are a lot of good articles at this site explaining concepts in Computer Science levelled “for dummies” (my interpretation and when I say “dummies”, I’m really meaning ME 😉  )  It looks like a good resource for newbie teachers and newbie students.

Bad news!  Knitting is my Waterloo. 🙁  It’s one of the things I’ve tried in life multiple times where I am an epic failure at!   One of the big problems has always been that I could never “get” how knitting instructions read.  So, if Coding is like knitting instructions, I’m in big trouble! 😀

• Knitting instructions for ribbing (Ribbing is the part on the cuff of your sweater that is very stretchy):  K1, P1, rep
• Knitting instructions for ribbing in computer coding: ((kp){x}\n){y}

How is this easier in computer coding?  I have an idea!  Why don’t we turn computer coding into knitting language?!  😉

Today’s Stage 10 Lesson on Conditionals has students creating rules for a card game. I couldn’t believe it but my 9 & 12 year old were able to turn our rules into Javascript because of their experience playing Minecraft.  I guess Minecraft teaches them to use Javascript!  I had NO idea.  Perhaps it might not really “run” in a computer, but they know where all the spaces and brackets need to be.  I’ll show you their javascript further down this blogpost…

Concepts covered include:

• Conditionals
• If statement
• Else
• Function
• Increment
• Decrement
• Nested Statements

As I said in my prior post, students really need a personal dictionary where they can write down definitions for all these new words and concepts.  It really is like learning a new language.  The unplugged activities (not needing a computer) have been very valuable for discovering and learning new vocabulary and concepts.  Unfortunately, none of my 4 children seem to be able to remember the definitions even though we review the words each time we sit down for the next unplugged activity.   I’ll keep on using the words and showing them examples or asking them for examples.  One day, it will “stick”.  I have to re-visit my notes over and over to keep the new vocabulary straight so I can’t expect them to remember them any faster.

The definition of Conditionals is the key of the lesson.

• Conditionals: A statement that is either true or false according to the situation [and then the computer acts accordingly]

As we learned in Lesson 1, computers  understand instructions in terms of “Binary” or what I call “Yes or No”.  So, the computer will evaluate whether something is true (yes) or false (no) and then act accordingly.  Another way of saying this is a conditional statement, “If  yes something happens, else no something else happens”

If you look at this link for Stage 10, there is a lesson plan you can download that will explain the finer details of creating a game based on conditional rules.

The basic idea of a Conditional is a statement that says:

• If________, else __________.

So, the example the lesson plan gave was, “If you draw a red card, you get 1 additional point.  Else, you lose 1 point”.    When you get an additional point, it’s called an Increment.  If you lose a point, it’s called an Decrement.

So, we invented a game with our own Conditional rules.  In keeping with the silly nature of my boys, their Conditional went like this:

• If you draw an even-numbered card you get a punch, else I get a punch

Then, the elder proceeded to rig all the cards so there were only even-numbered cards on top 😉

After they got this out of their system, we created four rules for our game.  To my real shock, my 9 & 12 year olds proceeded to show me how the rules would look like in javascript.  They learned all this on their own through playing Minecraft. I guess Minecraft really is not a total time-waster.  They spend far too much time on it and I have to kick them off it all the time but it seems they’ve learned javascript along the way.   Their reward for turning our game rules into javascript was a bit of Minecraft time. 😉

Rules for our Card Game

Here are the rules that we created for our card game. Underneath is the Javascript version:

1. If you pick up a joker you get double the points, else you get nothing
2. If your card is less than 5 you skip your next turn, else continue the game
3. If your card colour is red you get 3 points, else you lose 3 points
4. If your card is either a Queen or a King go again, else nothing

In Javascript:

<Game=>

</Game=>

(repeat?X)

1. If (joker.X=2

If (card.==jocker.X2){points

.,else=nothing};

{

2. If (card.==<5) skip.turn{if

(card,==>5)continue}

{

3. If (card.colour==red){points+=

3;){card.colour==other)

{points+=0;)

{

4. If (?card.==Royalty)}

+=1.and.Go.Again)}

If (card.==-royalty)} == .,else =nothing}

{

After typing all that out, I’m now going to lie down for a long time… 😉

~Vivian

Vivian @ChezVivian is a Canadian-born Chinese, currently living in Switzerland. She has also lived in Hong Kong and Indonesia. She holds a M.S. (focus: Educational Technology Integration), B.Ed and a B.A. and graduate studies in Kodály and Orff music pedagogy. She is an elementary school classroom generalist, but has also taught as a music specialist, ESL/EAL and also in Learning Support. Most of her teaching career was in International Schools in Hong Kong. She is excited about the IBPYP and the possibilities of using technology to Inquire. Recently, she has been looking at the opportunities that computer programming gives to put #TECHXture back into the hands of children. In other words, technology need not be just about looking at screens. It can be about building things with our hands; and computer programming levels-up what children can do with the things they build---encouraging higher thinking skills. She is a Coetail Post-graduate Certificate grad ('13-'14), a former Coetail Coach and one of the co-founders of #CoetailChat. Her blog home chezvivian.coetail.com curates her assignments for Coetail and her M.S. graduate studies about Educational Technology integration and anything else educationally-related that she feels inspired to write about. Her twitter tagline sums it up: "Mom to 4, Mentor, Educator, Musician (in that order)".
This entry was posted in 20 Hours of Code, Coding, Digital Literacy, Minecraft and tagged , , . Bookmark the permalink.

### 4 Responses to Code.org Stage 10: Conditionals or Minecraft isn’t a total time-waster…

1. Jeff Utecht says:

Look you go! Let me know when you’ve coded your first app. Once you know Java all the other languages feed off of it. Great work!

2. Vivian says:

Hi Jeff @jutecht

IF I make a million dollars off my app I split the money with you, ELSE I get your air miles forever