March 16, 2011

The Apprentice

“Always two there are, a Master and an Apprentice...”

My ten-year-old son told me over the weekend that he has a school project where to understand colonial life, they are supposed to find a master craftsman and learn a skill from that craftsman in the way that skills were passed on at that time. After mulling it over for about three, maybe four seconds, I offered to teach him a little bit of video game programming¹ if he’d be interested.

He thought about it and told me the next day that he thought that would be pretty cool, and he seems really excited about it. Tonight we sat down and filled out his apprenticeship contract.

The Contract

After that we talked about how apprentices sometimes got something that they would need for their trade from their masters when they started out, and I told him that probably the most important thing to me when I’m writing a program is to have a good notebook to keep my thoughts in, both to write down ideas as I get them and to keep track of things I still have to do. I happened to have a couple 5”x8” Moleskines with quad lining and so I gave him one of those and we wrote his name and the date in it.

I showed him the notebook I use for personal projects at home, with pages of checklists for various projects in various stages of development. So, the first thing he wrote down in his notebook was “make check lists and keep organized.” So proud!

Well, that was enough of preparation so we jumped right in and I showed him a little something I’m working on, which is a simple tool I’m writing in Javascript and HTML5 for a home project². I showed him the few things it does (I wrote what I have in an hour or so this morning) and then we cracked open the source file and I showed him the script that produced what he was seeing. Part of what it does is to present an image centered on a canvas and allows you to zoom in and out on it, so I showed him how the program responded to keypresses (this took us on a quick detour into ASCII, but only just) and updated a bit of data storing how much to zoom the image and then I went into the place where the image is drawn on the screen and came across this:

    w = picture.width;
    zw = Math.round(w * zoom);
    var x = (dimx >> 1) - (zw >> 1);

Oh, right. Centering on the screen, just wrote this ten hours ago or so not knowing I’d be using it to teach, and there’s bit-twiddling in my very first example.

As it turned out, it was a perfect example. They’ve covered decimals enough for him to understand shifting in principle... he just hadn’t ever been exposed to binary. So we jumped in with both feet and I wrote down the number 12. “So,” says I, “you’re used to this number when it’s written in decimal, what is it?” “Twelve.” “Correct! I can also write that number using only ones and zeros!” And I wrote down 1100 next to it.

“Wait, so, how is that twelve?” I explained that just like with decimal numbers, each column was associated with a value. In decimals, it’s ones, tens, hundreds, and so forth, but in binary it’s just starting with one and doubling as you go:

On your fingers?

He totally got it, which was really thrilling for me. I joked that you shouldn’t really trust someone who can count to a thousand on his fingertips and he gave me a quizzical look, so we moved along.

Next I explained that what I was doing in my little bit of code I showed him was called “shifting” and diagrammed out what was happening, showing the result

Shifting and dividing

He thought that was really cool. So I took the TV remote and the pad of paper and explained how I was figuring out where to start drawing my picture so that it would be centered. We worked through the steps in the math to figure it out.

As it turns out, the little tool I’ve been fiddling with is for rotoscoping some images I have and want to use in a forthcoming personal project, should it see the light of day³. I went up on YouTube and showed J some early examples of rotoscoping in videogames -- particularly Karateka, which was one of the first graphical games I ever played on my old Apple II, and Prince of Persia, which came along a few years later. I even showed him bits of Another World/Out of this World in silent tribute to Chahi, who reminded me of the technique at his GDC postmortem4. We talked about how natural the motion looked even though the graphics were really really simple, and he thought that was really neat. I explained how games had started even simpler, and showed him a video of Pong, too.

This led us to a little discussion of how much more powerful computers are now. I dug up a picture of an Altair 8800, and showed him how there hadn’t really even been monitors on some of those early machines. I explained how I wrote my first programs on something that didn’t even have a hard drive, just floppy disks. I showed him how much performance had changed by opening up the “About this Mac” window in Finder and comparing that with the memory and performance of that Altair 8800. We used our new understanding of binary together to show the big difference between the two -- doubling performance *how many times*?

We were starting to run out of time, and so I wanted to leave him with a basic lesson for the day, even though I had kind of come into the whole thing unscripted. I returned to my program and pointed out that there were really two kinds of things going on in it, functions and data. I explained that a program was really just a bunch of functions that took data and turned it into other data.

He knew it was important. He jotted it down:

What's a program?

I don’t know what kind of game we’re going to end up with, but I’m glad we’re getting a chance to do it. I hope that we’ll be able to finish something by the time he needs to give his presentation in May, and I think that’s ample time. My apologies to all of you working on or waiting for Skyrim, but I think whatever J’s game is, it’s the most important game I’ll work on this year.



¹His brother did this two years ago and learned how to cook a particular dish from his mother. I think the emphasis is on the master/apprentice relationship and not the historical appropriateness of the skill.

²I’m not convinced that Javascript is the best approach for him, but there are some features which make it nice and a constraint that makes it fairly convenient. First, it has a super quick iteration time, edit text and reload in browser, which I really like -- there’s no compilation step. It also has the virtue of being web-friendly, and the web is something he already sort of understands and sort of uses. As for constraints, well, he won’t be working on things just at my house, so having an environment that I can throw on a thumb drive for him (or even email easily, should it come to that), is really nice.

³If it does, it releases Father’s Day. You heard it here first.

4Well, me and hundreds of others. :)

Posted by Brett Douville at 09:31 PM | Comments (13)

August 24, 2008

A Moment in the Life

I was up tonight working on a (gasp!) post¹ when I heard some talking going on upstairs. It's nearly ten o'clock, and since my kids are generally in bed by 8:30, I knew this to be sleep-talking.

Sleep-talking, in Luc's case, is often followed by sleep-walking, so I went upstairs to keep an eye out for anyone risking life and limb on a closed-eyes descent. I got up there and heard further tossing, turning, and mumbling.

Wait for it... wait for it..., I'm telling myself.

I hear him get out of bed, and wait patiently in the hall until he appears. He comes to the door, and mumbles something, even though he's clearly not actually awake. So I hesitate, but he's waiting, and so I say, "What?"

He says, "What happens now?"²

I say, "You go back to bed." And wonder of wonders, he does. Not a peep since.



¹It's true! I was also reading a book and considering some other moment-in-the-life stuff from today, but really, a real post is coming! Like soon! Maybe even tonight! Even though having two posts on my blog in one day courts some sort of enormous chaos, like dogs and cats living together, I might be ready. I've started so many posts in the last six months that didn't materialize, though, so don't hold your breath. Still, it could happen, dear Reader. (back)

²I am tempted to attribute this to this afternoon's bit of fun: introducing my kids to Dungeons and Dragons. Luc is hooked, I can tell, and Jordan is hooked mostly because his brother is (he hates to miss out). We had fun, they started to get the hang of it, and managed to kill an NPC put entirely in the adventure to be of help to them. :) They want to play again tomorrow night, so we must have done something right. (back)

Posted by Brett Douville at 09:52 PM | Comments (1)

February 26, 2008

Three Stars

So, yesterday I was describing my recent trip to California to the boys, and recounted my very excellent meal with Jen and Andrew at The Village Pub. Luc asked me if it was a four-star or a five-star restaurant, and I said that I thought it was really quite good, probably five-star (and quite pricey). I said that I thought it was certainly better than anything I myself can cook. He said that he'd "give me three stars", whereupon Jordan piped up that he'd "give me three and a half stars."

I'd be prouder of that, I suppose, if not for the aforementioned review inflation.

Posted by Brett Douville at 02:05 PM | Comments (0)

September 23, 2007

Take Me Out to the Ball Game

It's not too often that I use this space for talking about my personal life, but I can't just keep the story of the last week or so to myself.

My sons each play baseball in little league here in Olney, Maryland. This fall, my elder son Luc graduated from the machine-pitch leagues that he's played in for the last couple of years into the first kid-pitch league. The first kid-pitch league shares some similarities with the earlier leagues -- a five-run limit per inning (except the sixth) -- but mostly it's real ball, with a live ball and stealing (except for home, there you have to be batted in), and of course, the kids have to pitch.

Now pitching is not an easy thing. Many many years ago I did it myself, and though I don't remember being particularly bad, I don't remember being particularly good, either. It takes a lot of practice to be a good pitcher -- my father always said that hitting a baseball is the toughest thing to learn to do in sports, but I think for me, pitching comes in a close second. Especially when you're nine years old.

Luc's team is pretty lucky in that they have a fairly deep bench when it comes to pitching. In the first game, a little over a week ago, we fielded five pitchers for an inning each, and they all did pretty well -- in fact, they won that game largely on the strength of their pitching. Luc didn't pitch that game, though; due to the league actually being a little larger this year and some scheduling issues, we were only able to get in one official practice before the season began.

But we knew he was going to have to pitch. So, last Sunday we went over to his elementary school so he could start to get the feel for pitching. He did alright -- nothing spectacular, to be sure, just getting one or two out of every five pitches over the plate, with another one or two being fairly wild. But he kept at it, and by the end of an hour he had both a sore arm and the beginnings of a fast ball.

Tuesday we were able to get out again, this time after karate. His arms were probably tired, but he was pitching decently, probably around 50% strikes or so, and with fewer wild pitches. By the end of the hour, I think he was probably pitching wild less than 10% of the time -- not great, but good enough that I felt like he would be okay to pitch in a game, not hitting kids left and right or having bases constantly stolen out from under him. I even kept a count to give him a sense of that, and while he had quite a few walks, he also had a few strike-outs -- well, counts where he had three strikes before he had four balls.

Wednesday night, Jordan had a game, and Luc's coach turned up to deliver baseball caps and things to the coaches. (I help out with the coaching on both teams, even though my knowledge of baseball could barely fill a thimble. Mostly, I'm there to keep the kids focused on the task at hand and try to leave the deep lessons of the game to the head coaches.) His head coach, Jim, and I talked about whether Luc could pitch on Sunday, and I said that I felt like while he wasn't going to be the best they had, he certainly wasn't in a position where he was going to be hitting batters or anything.

So Jim called Luc over and asked whether he'd be okay to pitch on Sunday, and Luc, who is ever the serious child, said, "Yes, I think I'm ready." Jim said, "What do you think about pitching the first inning?" and Luc said, "I think that'd be okay."

So, it was set. I knew I wanted to get Luc out on the mound again to give him a little more time and see if we couldn't get the most egregious wild pitches out of his system. Friday, we hit the field again.

It was like a different kid entirely out there, and not in a good way. He was finding it more or less impossible to find the plate -- I'm talking less than 10% strikes. That may be charitable. There were certainly a lot more wild pitches, balls which even this adult catcher couldn't get to and in some cases, I didn't bother to try, they were so far off. And of course, the more he pitched and was throwing wild, the more frustrated he would get. In this way, I think the apple has not fallen too far from the tree.

We threw a few sets of balls and I went out and talked to him, and he was a mess. He was getting very worked up about the whole thing, and I was starting to really worry about him. I told him to take a little walk out to the outfield and back, just to rest his arm a bit and give himself a little time to cool down and find his center again or something. Jordan and I tossed a ball around for ten minutes until Luc came back and started pitching again.

But the balls were still completely wild; in fact, they may have been worse than before his little walk. So I walked back out to him and I could see he was starting to tear up a bit, the frustration was so extreme.

I had been telling him a lot about letting go of each pitch, just worrying about the next one that you're going to throw. We had a kid on his team in the spring who would get really really mad at himself if he botched a play -- and you have to remember, we're talking about eight-year-olds, botched plays are pretty much the norm. I reminded Luc of what I used to say to D: "Baseball isn't about the past. It's about the future. It's about what you're going to do now, when he hits the ball, not about anything that happened to get you there. Worry about right now, not about what you think you ever did wrong." I had been telling Luc to breathe before each pitch, and to not worry about the count, and to just relax and throw the pitches we both knew he could throw.

But that wasn't working, even though it had worked before the pressure of pitching in Sunday's game. Here was a kid who was completely strung out and upset about pitching.

First, I told him he didn't have to worry about pitching on Sunday. As soon as I got home, I said, I'd email Coach Jim and straighten that out. Luc, courageous young man that he is, said, "Maybe I could pitch in the third or fourth inning," and I felt such love for that bravery, in the face of what he was going through.

Having gotten the pressure off at least a little, I started talking about things I've been doing lately in karate to improve¹. I talked about visualization, imagining in your mind the steps of what you're going to do before you do it. I talked about how I would think about a front kick before I threw it in training, and went through those steps for him, lifting my knee high, extending the foot, pulling the toes back, all the things I did. I talked about side kicks too, which are quite a bit trickier, and all the things that I would think about before throwing a side kick. I told him that Master Roberts had actually complimented me on my kicks since I had started doing that, and so I knew it was having some effect.

Then I talked about major league pitchers, and how every time they're up on the mound, before every pitch, they take a moment to think about the pitch they're going to throw. They stop, they take a deep breath, and they work through the motions in their minds. This may not be true of all pitchers, but I know certainly some of them do, and all of them are at least thinking about something up there.

So I told him, "You know what to do out here. Just think about what you're going to do before you do it, and you'll do fine. I know from the other days we've been out here that you know how to pitch the ball. Take a little time, and throw each pitch the way you know how to throw it."

I went back down behind the plate, and I'll be damned if that little man didn't throw nine out of the next ten right over the plate, and even that odd one might have caught someone swinging. I could see him out there, talking himself through the pitch each time (literally -- his mouth was moving, though he wasn't talking loud enough for me to hear), pointing his arm all the way back to second base and letting fly at just the right point in the arc.

I already felt like a million bucks, and I felt so glad for him that he'd found his way through, and hadn't even let that one ball phase him (it was the third pitch -- plenty of time to get in his head). There he was, my little nine-year-old boy, suddenly a pitcher.

But the real capper came right after we finished out the last few balls (I have thirteen we practice with -- I guess I'm not superstitious). He turned to me from the mound and said (and this is a direct quote from my serious boy), "Thank you, Daddy. What you said really helped me. I don't think you need to send Coach Jim any email." One's heart bursts with pride. I know what that means now. My kids have always made me proud, but this just took the cake.

You know, it doesn't even really matter how he pitched today -- the end of the story was really on Friday, when he made a mental move from frustration to confidence, when he learned not to give up when the chips were down, when he found a way through the difficulties that physical endeavors present.

But I'll tell you anyway.

Luc pitched his first inning of baseball today, the second inning -- Coach Jim had forgotten that he had already promised the first to another pitcher. He gave up two runs (comfortably below the five run inning limit). He had two strike-outs. He threw a total of three balls to seven batters, and only one of them got past the catcher.

I guess it's good he learned how. Because I have a feeling he's going to be pitching again.





¹It's only fair to note at this point that I had gotten these pointers from a book recommended by Jamie, Mastery by George Leonard. (back)

Posted by Brett Douville at 08:59 PM | Comments (7)