Atoms Game (aka Chain Reaction) an alternative C tutorial

This is a new tutorial series to teach you C programming.  It’s different from the others because I’m not going to cover all aspects of C programming (syntax and features etc) but instead deep dive into the Atoms game and start implementing it.  I’ll then explain how it works and what features of C I’ve used.

In this tutorial I’m just going to explain about the game design.

The Atoms/Chain Reaction game

We start with an 8 x 8 board that is completely empty. Like this

```1 2 3 4 5 6 7 8
. . . . . . . .  1
. . . . . . . .  2
. . . . . . . .  3
. . . . . . . .  4
. . . . . . . .  5
. . . . . . . .  6
. . . . . . . .  7
. . . . . . . .  8```

Now each turn we can add an atom to any of the 64 squares except those that are owned by the computer player.

```1 2 3 4 5 6 7 8
. . . . . . . .  1
. . . . . . . .  2
. . 1P. . . . .  3
. . . . . . . .  4
. . . . . . . .  5
. . . . . . . .  6
. . . . . 1C. .  7
. . . . . . . .  8```

Here, both the player and the computer have each added 1 to two cells to (3,3) for the player and (6,7) for the computer. We use columns across first then rows down. You can see the 1C is 6 columns across and 7 rows down.

The P and C identify which squares are owned by each player. If you were doing this with graphics instead then you might use colour instead of the P and C. Blue for the player and Red for the computer player. We’re not though, this will run in a console/terminal Window.

Bang!

So the first few turns are unlikely to be busy. But eventually you’ll add 1 to a cell containing 3 atoms and that will make it explode.  The cell itself is cleared to 0 and the four cells around it (or 2 at a corner and 3 along an edge) all have one added. Now if any of them have 3 atoms then they too explode in the same way and so on.

When a cell is incremented because of an explosion next to it it becomes owned by the player or computer player that made the move./ Here’s an example.

```1 2 3 4 5 6 7 8
. . . . . . . .  1
. . . . . . . .  2
. . 3P2C. . . .  3
. . . . . . . .  4
. . . . . . . .  5
. . . . . . . .  6
. . . . . 1C. .  7
. . . . . . . .  8```

This is the board before you add an atom to (3,3).

```1 2 3 4 5 6 7 8
. . . . . . . .  1
. . 1P. . . . .  2
. 1P0P3P. . . .  3
. . 1P. . . . .  4
. . . . . . . .  5
. . . . . . . .  6
. . . . . 1C. .  7
. . . . . . . .  8```

You can see that (3,3) is now 0P but the four cells around it have one added and become Ps. So you captured (4,3) from the computer player and it’s now a 3P. Next turn you might add 1 to (4,3) and it will explode.

The game continues until either the Computer player has been wiped out or the player has been wiped out. In the next tutorial, I’ll start by creating a small program to display the board.