Thinking about future C tutorials

Image by Anand Kumar from Pixabay

The tutorials I’ve done have followed a fairly “standard” model. Learn a feature, learn a new feature and so on. But what if this isn’t the best way to try and teach C?

I can’t remember how I learnt C. I’m not actually sure that I did which sounds weird but I learnt C++ nearly 28 years ago (I bought a book on C++ programming while on a weekend holiday in York). I learnt more C++ four years later when I was working on a football game. That project lasted six months and then the designer of the game decided to visit India and never came back and the whole thing fell though.

Fast forward to 2006 when I started writing the About C, C++ and C# column for Because I knew C++, I sort of knew C without explicitly having learnt it, Back then C++ was a superset of C. It still mostly is but there is the odd divergence.

This morning I was reading this thread on reddit. “What do you guys think its the best way to improve your coding?” and it got me thinking about the C tutorials. I know that I like to learn by working on small projects. Most games are too big for a tutorial (heck you can get a book out of them).

So I got to thinking, what is a simple game that would make for a good set of C tutorials? I even dug out the two books BASIC Computer games and More BASIC Computer games for inspiration. However in the end I decided on the game atoms. Here are the rules.

Rules for Atoms (aka Chain Reaction)

This takes place on an 8 x 8 board. Each turn you and then your opponent. Add 1 to any cell on the board. At the start all cells are empty with a value of 0. When you add 1 to a cell, it turns red or blue if the computer is playing. If a cell reaches 4 then it is cleared to 0 and all four cells around it (horizontal and vertical) have 1 added to them and become the player’s colour.  Cells in the corner only need to reach 2 to explode while cells at edges need 3.

When there are enough atoms on the board, a chain reaction can take place and you win if your atoms replace your opponents or lose in the opposite case.

To keep the tutorials simple this will be a console game. Each cell will be blank or show the number of atoms in the cell followed by a C (for computer) or P for Player instead of colours.  I’ll start the first tutorial tomorrow.