Today is a good day to code

Teaching my 7 Year Old Daughter to Code (Mazes)

Posted: February 5th, 2011 | Author: | Filed under: Lifestyle, Parenting, Teaching Coding | No Comments »

Today we advanced in our lessons.  I started teaching my daughter how to code about a month ago.  I started when I was about 7, so I thought it was about high time I got her going.  I bought her an Acer Netbook a while back.  Windows 7 Starter is a bit weird, but it does what we need it to.

I started teaching her JavaScript / CSS / HTML because I wanted for her to be able to see her work immediately, and  UI work is usually best for that.  We went through some basic typing, data structures, and some general information like number systems, hexadecimal, etc… She stayed with me.  We did that for a few lessons.

I typically keep her for about 1 hour per session.  Sometimes she wants to go for longer, sometimes she loses interest after about 20 minutes.  I always let her go when her attention starts to waver.

Today we started on our real project.  The first few things we built were simple, a list of her favorite things, some colored blocks, drawing some lines with the canvas element, but the end goal is to make a maze game for her brother, who loves mazes and is 3.

At first her suggestion was to make mazes manually, but after we thought about it a bit more, she realized that she would need to build many, many mazes to keep her brother busy.  So we started to think through how we could make the computer create the mazes.

My Daughter's Maze Generation Algorithm

My Daughter's Maze Generation Algorithm

Some of the problems we thought through were firstly how the machine should visualize the maze.  We thought through 3D constructs, which were crazy complicated and I suggested we do those later, and eventually we settled on a battleship style construct.

The next thing we started was to define the rules of movement through the maze for the computer while it is creating the path from the beginning to the end.  She decided that the computer should choose an entry point and an end point, and after some discussion we decided that they should be on the outside of the grid.

Then we thought about whether or not we wanted the entry and exit to possibly be the same.  My wife suggested we play simon says for a bit since we were talking about instructions, which was very helpful.  Then we decided that the computer, and her little brother, couldn’t move diagonally, but we needed a way to write a rule that the computer would understand.  The number and letter thing she came up with toward the end of the hour.

Teaching her how to hack is going surprisingly well.  I do not think that I have an overly gifted daughter, but I think that teaching coding by writing code is the best way.  For defining a set of rules though, a piece of paper is always a good first step.

The ultimate difficulty is that she wants to put the game on the iPad, and eventually in the AppStore.  We’ll see how far we get with that.  I suspect that most of the iOS coding will be done by me ;-).  I am hoping that this helps other software engineer parents who want to figure out how to teach their kids the art.  I’ll try to chronicle my setbacks, as well as my successes in subsequent posts.