Project thumbnail

Toguz Korgool

16 December 2018
A computer version of Toguz Korgool game, designed for practising

This project was an assignment at King's College London and the goal was to digitalise an unknown game. The idea was that players would play against the computer and thus improve their skills for the competitions.

The game we were given to design was Toguz Korgool which is a two player game usually played in Central Asia.

Initial setup
Initial game setup. This is how the board looks like in our application.

What the game is about

The board consists of two rows of nine holes, one for each player, and 162 stones, called "korgools". Each move consists of picking up korgools from one of the holes on your side and redistributing them around the board. The goal is to collect more korgools than the opponent.

Exact game instructions are explained in the video below which was also our main source when researching and designing our game.

What we did

We implemented a game which adheres to all of the instructions in the video and also visually resembles the physical board. Some additional features we implemented were:

  • A player can save the current game and restore it next time they open the app.
  • A player can specify a custom board configuration which lets them practice from a particular game situation onwards.
  • We found out that if the computer player only selects a random hole it already makes the game sufficiently hard for practising.
  • All korgool movements are animated so that the player can see what exactly is happening. The speed of animation is adjustable.

My responsibilities

Initially, I worked on the core logic of the game. This consisted of encoding a game state as arrays of numbers and correctly applying the changes in the game according to which hole was selected. I then wrote extensive unit tests to ensure all of the game rules were implemented correctly and that we covered all the edge cases.

While I was working on that, the other team members started working on the basic Graphical User Interface (GUI) and the link between the GUI and the game logic. Seeing that the progress was good and that the core features of the assignment would be covered without problems, I started designing a better-looking GUI.

Firstly, I started designing the elements that represented holes on the board. I wanted them to be scalable, adjustable (colour, borders, etc.), and easy to integrate with the current design. Hence, I created the Oval Button class which was an extension of JButton class. OvalButton enables easy creation and usage of capsule or oval shaped Java Swing buttons which are highly customisable. However, there are a few other important improvements I added. Such oval button is only triggered if the user clicks within the borders of the ellipse and not anywhere around it (but still within the bounds of the Swing element). In the final version of the game, we decided to use capsule shaped holes as they more accurately reflected a real board.

This class turned out to be very useful and I also received some good feedback about it on Stack Overflow.

When this class was completed, the board quickly started looking much more appealing and realistic. I then added some images of wood in the background and in the holes to reflect the look of a real board and to separate the holes of a black and white player. I also wrote a short script that took care of correct tiling when the window was resized.

The second big challenge, and one of the main additional assignment features, were the animations of korgools. The goal here was to show how all korgools are collected from one of the holes and then distributed one by one to other holes. You can see an example of these animations on the video below:

There were a couple of challenges I had to tackle to make animations look good. First, korgools in holes actually had to look like they are in the holes, i.e. they had to be draw within the ellipses. Second, korgools are randomly positioned in the holes to look more natural – but they also cannot lie directly on top of each other. To ease the calculation of these random positions, I first found an inscribed rectangle for each ellipse and position the korgools within that rectangle. Thirdly, animation speed can be adjusted by the player – more experienced players can speed up the animations, and beginners can slow them down to see exactly what the process is. Last but not least, animations should not be broken if the window is resized. To achieve this effect, I calculate the scaling factor by which the window size and position has changed and use that to reposition each of the korgools.

This was a very fun and interesting project which also focused on agile style development, software testing, and high quality code which you can find here.