Hello! My name is Minas, I’m a programmer and I enjoy creating stuff! My latest project is Movie Pal, an app you can use to discover movies, watch trailers, create shared watchlists with your friends and organize movie nights. Get it on Play Store.

Code Katas are a fun way to challenge ourselves to learn new things or improve our knowledge on what we already know. It’s also a good excuse to have the company buy pizza for everybody! 🍕

For this reason I decided to organize one at the company I work at.

Since we have grown a bit (we’re ~25 people), the traditional Code Kata where people work in pairs in turns didn’t seem like a good idea, as it would take too much time for someone to have their turn at the keyboard again.

The ideal situation would be for small teams to be formed and somehow come against each other in a competition.

Theme

So I came up with the idea of writing a small board game, played by 4 players (4 teams). On the board there are 4 pawns (red , green , blue , yellow ), each starting at a different corner of the board.

The game is turn-based. Each turn, the pawns need to move by 1 cell (it’s also possible not to move).

When a pawn moves, it paints the cells is passes from with its color.

Stepping inside a cell steals any previous color that the cell might had been painted with.

The game ends after 100 turns. The pawn that has painted the most cells with its color is the winner.

Challenge

Teams compete with each other on which one gets the highest score.

Given the current state of the board, each team needs to write the algorithm for the movement of their own pawn!

For each team, there already exists a “behavior” class with a dummy implementation:

public class GreenPawnBehavior implements MovementBehavior { @Override public MovementOffset getMove(Board board, BoardPosition currentPosition) { // TODO implement a better algorithm using the methods of the board return new MovementOffset(0, 0); } }

It’s also possible to save state in each behavior.

How to organize it

What you’ll need

Five (5) laptops – one for each team and one for you to run the game and count the scores Android Studio on all laptops One projector to connect one of the laptops to it 4 teams of 2-4 people Pizza

Execution

As said earlier, the teams will implement an algorithm to move their pawn in order to maximize the amount of cells painted with their pawn’s color.

It’s a good idea to let the team work on the problem, run an evaluation round, let them work again and so on. We suggested having 5 evaluation rounds so that there will be enough time to adapt the algorithms based on the algorithms of other teams.

Here’s are idea on how to organize the code kata:

Description Time ⏲️ Explain the rules and answer any questions: This is a turn-based game where each team needs to implement the moving algorithm for their pawn. As pawns move on the board, they paint it with their colors. Stepping on an already-colored cell, removes the previous color and applies the one of the pawn in it. The amount of cells for each pawn is their score. The goal is to have a many cells of one’s color as possible after 100 turns! It’s not possible to move on a cell which another pawn is inside. It’s not possible to move outside the board. Attempting to do so will result in non-movement of the pawn. 10′ Begin the 1st round! Because the teams will need to study the API a bit (Board class, Behavior interface) this round needs to be longer that the ones to follow. 20′ Evaluation time! Have the teams send you their code

On the PC which is connected to the projector, start the game and let it finish. Write down the scores.

Repeat once more

Repeat once more (in total, 3 runs) 5′ Begin the 2nd round! 10′ Evaluation time! Repeat the same as the first evaluation round, but multiply the scores of each team with a multiplier > 1.0. This makes later rounds more important than the previous ones. These are the multipliers we suggest: Round 1/5: 1.0

Round 2/5: 1.1

Round 3/5: 1.3

Round 4/5: 1.6

Round 5/5: 2.0 Repeat the cycle of working on the problem for 10′ and then evaluating the results five times. 5′ Pizza time! 🍕 ? Announce the winners and ask each team to explain their algorithms. 15′

Get the code

The code is available on github. Feel free to change it as you wish! 🙂