Friday, September 28, 2012

A Roll of the Dice

Most gods throw dice, but Fate plays chess,
and you don't find out til too late that
he's been playing with two queens all along.
~ Terry Pratchett




I've mentioned before that I'm teaching Brandon how to design & program his own video games - if you can use the word "teaching" to cover trying to keep one chapter ahead of him in a "learn how to create your own video games" book...  ;)

One thing I like about the activity is that it calls upon both right-brain and left-brain skills.  On one hand, it requires creativity - which Brandon has in spades!  At the same time, it requires a certain amount of logical and systematic thinking.

Last weekend's lesson, for example, required me to introduce him to some basic notions in discrete probability.  The idea was to have demons (bad) and baby dragons (good) inserted into the game at unpredictable times.  The way this is implemented in the Game Maker software is most easily understood using the analogy of rolling a multi-sided die (singular of dice).  If one particular side comes up, the demon (or baby dragon) is created and put into the game, but if any of the other sides come up on top, nothing happens.

The game designer gets to decide how many sides the die should have.  I could have just told Brandon the rule - the more sides, the less often the event occurs.  But I wanted to give him a feel for this and an intuitive example that he could use later, if he ever forgets the rule.

So, we started with flipping a coin.  'Heads' means demon, 'tails' means no demon.  We set up a test with 12 flips and he took notes on the outcome of each flip.  We actually ended up with exactly 6 demons (not a guaranteed outcome by any means) - and there were some sequences where we went 2 or 3 rolls without a demon (yawn-time) and then some sequences when we got 2 or 3 demons in a row without a break (yikes!).  So this showed the unpredictability of it nicely.

Then I switched to a normal, 6-sided die.  We let a roll of 6 indicate that a new demon is created.  We talked about it a little bit before testing it and Brandon tentatively thought that maybe we'd get fewer demons than with the coin, but he was very uncertain and seemed to be mostly guessing.

Again, he set up the sheet to record the outcomes and I rolled the die 12 times.  

We did not get a single demon.

We talked a little bit more about why - the more possible things that could happen, the less often any one of those things was likely to happen.  Brandon actually put this rule into his own words unprompted, which made me very happy.  :)

Then we got into applying the idea within the game itself.  I had to explain that the computer could create a die with any number of sides that we wanted and also that it rolled die a lot faster than a person could!

The tutorial recommended rolling a die with 300 sides to create demons and a die with 500 sides to create baby dragons.  Brandon thought those numbers were very large, but was okay with trying them - by now he is comfortable trying things because he knows that he can always go back and change them if he doesn't like them.

I challenged him to figure out whether we'd end up with more demons (300 sided die) or more baby dragons (500 sided die) - he started to say "baby dragons" but then stopped, restated his rule (reminding himself), and got the answer right!

It may seem simple to us grown-ups, but it's a pretty foundational concept and I'm really happy with how he got the hang of it.  :)

So, I've touched on the logical bit of last weekend's lesson - how about the creative bit?  

Well, the player takes the position of the daddy dragon who is trying to kill demons and save baby dragons.  He shoots fireballs out of his mouth to kill the demons and, if he is not careful, he can kill baby dragons as well.

The demons make one noise when they die (like you have defeated a powerful foe) and the baby dragons make a pitiful, crying noise when you accidentally shoot a fireball at them.

Brandon wants to change these system-provided sound effects.  His idea is to have a human voice singing out "fried chicken!" when a demon is hit with a fireball and "I'm telling Mom!" when a baby demon is hit...  ;)

2 comments:

  1. As a geek that played these types of games, I'll tell you, the Dice Gods are like that.

    If he's not getting results with logic, there's a joke about putting the suckers in the microwave and making one into a pile of goo so the others will step in line.

    Or he can have my pink dice. They ALWAYS seem to give me whatever is the largest, meanest and most likely to kill the party monsters. (And added kitsch factor here, I've had them for almost 24 years.)

    ReplyDelete
    Replies
    1. Pink dice! Very cool! I'm jealous! ;)

      Delete