Tuesday, October 21, 2014


I just published the first chapter of my online coding book Koodikirja (in Finnish).

This is something I've been hacking on every now and then from the start of this year or so. It teaches some basic computer programming using my Turtle Roy learning environment.

Check it out! And watch out, this is only the beginning!

Monday, October 6, 2014

Turtles and Tanks

Last weekend we visited my friend in the beautiful town of Loviisa and her lovely daughter Amanda and played some board games.

We started with Robot Turtles, that I covered in my previous posting too.

The thing was, they had two cats. So we played Robot Turtles with Amanda while my daughters chased and petted the cats around the house. Turned out Amanda liked the turtle programming game a lot and quickly hacked how to capture the diamond with a "program" that's a sequence of moves. She also learned how to debug: try something, run it, then try again. 

Many times she decided to start her somewhat complected program from scratch instead of trying to fix it. That's what a programmer sometime has to do!

She also learned to use the LASER card to melt icy obstacles into harmless ponds of water.

Then something unusual happened.

Her turtle was surrounded by tanks.

Guess what she did?

Well, she calmly constructed a program that made her turtle eliminate all of the tanks with LASER. And she succeeded with her first try too. Each tank exploded with a huge BOOM!

So we switched to a hex board and gave her seek and destroy missions. Tanks a plenty were destroyed. 

Meanwhile my girls had messed Amanda's room quite badly. I ask Mila to have a look at what Amanda was doing and the joined their forces to take out a platoon of tanks with their flawless programs before we had nachos.

Who said girls can't destroy tanks?

Monday, September 22, 2014

Robot Turtles

Today Päivi from Sanomat borrowed me the Robot Turtles game.

The idea of this game is that kids "Turtle Masters" play Code Cards that guide their Robot Turtle toward a gem. Everyone who gets to their gem wins. An adult is the Turtle Mover who will move the players' turtles according to the code cards that the kids play. And it has a progressive set of rules where you introduce new features as the players seem to be familiar with the current ones.

After reading the rules I was a bit disappointed. Where's the game? Where's the challenge? But then I took a step back and realized that I had the perspective of a professional programmer who has played a lot of complicated board games like Puerto Rico. This is a game for kids starting from the age of 4 it says on the package. So we gave it a try. Me as the Turtle Mover and my 5 and almost-3 year old girls ad Turtle Masters. 

First we started with the basic rules where there are no obstacles on the board. You play a "forward", "left" or "right" card to move/turn the turtle accordingly. There's about 8 moves to the gem, involving one turn. It was dead easy for the 5 year old coder girl. Even the almost 3-year old wannabe coder girl made it to the gem after several tries. This was enought for her and she went to lay down some stickers instead.

But with the older girl we played some more. Next I put some obstacles on the board and she started planning her route to the gem. She planned the whole route almost instantly and we agreed that we won't play one card at a time. Instead, she wrote the whole program consisting of about 10 cards at once in about 2 minutes. And it turned out correct and was fun. As per game rules, I kept making funny noises for each move of the turtle and we had fun.

We played yet one more round, with a "laser" card that you can use to melt an obstacle made of ice. We also added some obstacles made of rock. The different to the ice obstacles is that you can't melt the rocky ones. This time the route was a bit tougher and she had to try like 4 times before getting the complete and correct program. But she made it and it was fun. I think the earlier coding lessons have paid off. Dunna. Should try with some other 5 year old to verify that assumption.

After the game I asked if it was fun and she said "tosi hauskaa", which means very fun or something like that.

- Do you find this game to be at all like coding?
- Yes, a bit like Turtle Roy
- Is it easier or harder?
- A bit harder
- Really?
- Daddy, this was the first time we played it!
- Do you want to play again?
- No.
- Really?
- I meant I don't want to play again right now.
- But later maybe?
- Sure!

So I guess the game works. And it's a brilliant idea to introduce game features gradually, so that you don't have to memorize too many complex concepts at a time.

And I think it'll be even more fun with 4 kids or so. Gotta try!

Still I have this feeling that we need a more hardcore coding game. With more control structures, memory access and such.

Wednesday, August 13, 2014

Lesson 61 - Board Games

What about an educational board game for learning programming? I haven't heard about anything else than Robot Turtles which I still haven't ordered because of the high shipping fees. Silly me.

We made our own today. I mean, made the first prototype. The idea had been growing in my head for a few days. 

Not going to go to details but the key thing is that you'll be programming a simple computer with assembly language. Programming instructions are given using Code Cards, each of which does a simple thing like reading a value from memory to a register or writing a value to "standard output". Of course, you'll have flow control cards like IF and JUMP. The players together will simulate the computer that runs these instructions.

I did my best to come up with a simple instruction set, some game rules and a "garden" theme, to make it less scary. Replace binary numbers with fruit and the computer memory by a garden. Represent a minimal instruction set as drawn symbols and the program and memory pointers with a robot and a gardener. I tasked my little girl to draw some of the graphics of course.

We had a nice hour or so drawing, cutting and gluing things together while discussing games and computers. In the end, we had 2 board games. Mine/ours and hers. We played both. Her's was better, partially because it was the classic Memory game with a twist: instead of two pictures, you have to connect a picture and a starting letter. Nice for teaching the alphabet for the younger girl! In fact, even the 2-year old had fun playing it.

So here's her game.

And here's mine.

What worked well was that it was fun to simulate the computer using the Code Cards and a pointer. What didn't work so well were my game rules. You've got to appreciate actual game designers. There's a long way from a nice idea to a well balanced, enjoyable board game.

I'm not saying it wasn't fun though! And I think the main concept is valid, it just needs some more game design. Good times!

Lesson 60 - Physical Turtle

It's summertime! 

So no wonder we haven't been coding much lately. A while ago we got a couple of Lego Mindstorms boxes from Reaktor though. Me and my friends built a "turtle robot" that can be move and turn and draw with a blue marker. The mechanical part was quite challenging and rewarding. 

The software part wasn't so much. The graphical development environment from Lego was really bad. Graphical and "easy", but practically impossible to code anything interesting. I mean code in the sense that you can write and refactor code the way a coder is used to. Well, it took until 3 AM or so to finally get the firmware (LeJOS) and the development environment (Eclipse) working together. Then we had an environment where you can actually code something. Yes, it's Java.

But doesn't the robot look pretty cool? It had two independently controllable wheels and a pen that you can lift and put down. And you can turn it around 360 degrees around the pen. Amazing mechanical engineering required :)

The next day, I wrote a simple API so that you can issue commands similarly to Turtle Roy. For instance, you can tell the robot to turn 90 degrees to the left, or move 100 units forward. Then we did some programming with my daughter. Like this.

You can imagine my little girl (5 years as we speak) being quite excited when her commands made an actual physical ROBOT MOVE and DRAW ON THE FLOOR. Yes. The floor. First we tried paper but the result was the robot messing up the paper quite badly. Fortunately the marker was water-soluble.

I wish someone sold wifi/ble capable robot turtles that had a pen and an open API. Then I could make Turtle Roy control a real robot. That would be huge!

Friday, July 4, 2014

Lesson 59 - Fanbase

Today we were going to recap on geometry. She was busy building animals from some kinda semi-eatable stuff I don't know the name of in any language, so we agreed to start when she was done. Then she started to play with a small battery-operated cooling fan she had tricked me to buy earlier today. I asked her if she wanted to know how the thing works. Guess what.

We started discussing batteries and motors and drew a schematic of the thing. Two batteries and a motor connected as a closed electric circuit. I happened to have a battery and a motor nearby so we tried what happens when you connect them. Rotation! But that wasn't quite convincing yet, so we made a fan out of cardboard. We punched a hole trough it and she connected it to the motor. You can imagine how happy she was when the fan actually worked!

Then I asked what's missing in the picture. And why isn't the fan rotating all the time. And she told me the button was missing from the circuit. Well, I happened to have a Fritzing Creator Kit I got from Reaktor at hand (I was planning to start electronic experiments with her and the Arduino much later...) so we constucted a thingie with a button.

Well, actually a potentiometer. The Arduino board in the picture is not really in use. Just the motor-fan, the potentiometer and the battery. Use the Fritzing kit we were able to connect the thing into a 9 volt battery with fixed wiring. And with the 9V battery the fan was FIERCE. Fortunately the potentiometer let us somewhat tame it. But there was a lot of room for improvement. She wanted a button. I wanted a stabile base for the motor so that no-one would get hurt. We got both.

We used a match box and some playdough to construct a stable "fanbase" for the motor and included a push button into the circuit. And our adjustable 9V push-button fan totally kicked the ass of the lame green 3V fan from the shop (you can see part of it in the photo).

While we were hacking, I was also making some whipped cranberry porridge (I have no idea what you call it in English, we call it vispipuuro). The final phase of the recipe is mixing with a handheld mixer. Like this.

She was really exited to discover that the mixer has the same main parts as our fan: a motor and a switch. She beamed when she told me that it has a power adjustment controller too, just like our potentiometer. Later tonight she pondered whether a vacuum cleaner has the same internal structure. And the electric toothbrush! So many electric devices that have the same simple architecture!

While she was eating, I rewired our concoction into the Arduino board. With minimal programming and some wiring, we got ourselves an automatic fan apparatus that changed rotation speed periodically. Everyone was fascinated and she wanted to start re-coding it so that it would play Twinkle Twinkle Little Star with the motor. In fact, that might be our next task.

Yesterday when hacking with the Arduino myself I had doubts whether electronics hacking would be interesting for a 5 year old girl. No more!

EDIT: It was lingoberry, not cranberry :)

Sunday, June 29, 2014

Lesson 58 - Back to Geometry

There's been some time since our last computer lesson with my daughter. Meanwhile we've been doing a lot of other stuff together, like laying bricks, riding bikes, playing music and making concrete and food. She's asked for a computer lesson a few times, but it's been inconvenient at those occasions so we've ended up having quite a long break. 

And I think it's good. I've been having the feeling that she's pretty much reached the limits of what she can learn at her age, at least with the methods we've used. She's still a 5-year old after all.

Anyway, a few days ago Sanna Salo and her colleagues at Linja published a Koodikoulu (Code School) video on Youtube. My daughter is the narrator on the video :) I think the publication of the video inspired her to ask me for a computer lesson today.

Today my plan was to practice problem solving from the point of view of Geometry. We started with basic shapes. She easily drew a triangle (kolmio in Finnish) and a square (neliö). She wasn't quite happy with some of the lines so I thought her to use a ruler. We also discovered that using an angle ruler (is that the right word?), you can easily make right angles (90 degrees!) and create a nice looking squares. Then she drew me another shape and I asked her if that's a square. She corrected me and told me that it's in fact a rectangle (suorakulmio).

She didn't think that squares are rectangles too, which they in fact are. And we agreed that a rectangle is a square if it's edges have the same length. Then we measured the lengths of her square to be almost exactly 3 centimeters each.

Then I showed on the paper how a turtle would draw a 90 degree circle segment and asked her to show what would happen if it repeated the same trick. She correctly showed how the turtle would complete the second segment. Then we repeated that until a whole circle was covered. And concluded that if you do 4 turns of 90 degrees each, you'll end up with the full circle.

Then we practiced splitting the circle (or a pie!) into 3 segments in the same way. You can see how it went in the picture above. Then we first concluded that if you split a pie into 4 segments, you'll get 90 degree angles. And when asked, she demonstrated me that when you split it into 3 segments, the angles are bigger. But how to calculate the angle?

At this point (30 minutes later or so) she was getting tired and her concentration was slipping. You can see that on the pictures too, I guess. So when we started doing the math (360 / angle) she was eager to get to the computer. So we had the computer calculate the angle of an equilateral triangle.


Big numbers for a 5-year old. Yet with my help she was able to parse the result into a word "satakaksikymmentä". 

And we managed to draw the equilateral triangle using Turtle Roy. A lot of giggling was involved. 15 minutes later, she's asleep.

And I think that geometry and turtle graphics are a fun way to learn programming.  Next time we'll hopefully return to the same subject and see how she can decompose a problem and formulate it as a computer program. Then recognize and eliminate duplication using the sequence and repeat commands.