Slay Tutorial One – How to implement Slay for Linux

Slay gameSlay is a commercial, albeit low cost game for Windows by Sean O’Connor.  It’s a convenient way to demonstrate game creation and in this and following tutorials I will show how to create a Slay clone- I call it Onslaught. It will be written in C + SDL2.

Onslaught uses the same hexagon map and unit structure as Slay. The game mechanics are as follows.

It’s a turn by turn game. Each turn, you get an income from each hexagon in every area that you own (an area being a contiguous group of hexagons all of your colour) that is free of trees or wasteland. You can use these points to buy new pieces or a castle and place them in an area.

There are four sizes of units (2, 6, 18 and 54) each 3x bigger. In combat a big unit destroys a smaller unit by being placed in its hexagon. You cannot put a unit in a hexagon occupied by a same size or bigger enemy units. Also only the 18 and 54 sized units can destroy a castle.

At the end of a turn any area that has units that exceed its support capability are destroyed and replaced by grave symbols. Next turn those hexagons if not occupied turn to wasteland. Support capability = count of hexagons in an area owned by the player plus reserve from previous turns. Each turn Reserve = Income – Cost of units + Previous reserve. It costs 10 to buy an army and 15 for a castle.


You do this by eliminating the computer players. In Slay there are six players. In Onslaught I’ll allow this to vary so between 3 and 8. When the total hexagons owned by one players exceeds by 3x the total amount of the remaining players (ie one players owns 75% or higher of the hexagons), the other players will offer surrender. The player can continue playing or accept victory.

Map generation

In Slay there are several hundred pre-generated maps. In Onslaught all maps will generated. There will be several game play modes.

  1. Single map game. Play on any map against a number of players on small, medium or large maps. Map sizes are defined as 20 across by 15 deep (small), 30 x 20 across (medium) and 40 across x 30 deep (large).
  2. Play a campaign of 8, 12 or 16 battles. Some maps will have a “Defeat the enemy in x turns” victory condition instead of the usual “Force the enemy to surrender” or “Occupy 75% of the map”.

Computer Opponent A.I.

In Slay there are four levels of Artificial Intelligence with even the Very Clever toughest AI capable of making stupid moves, leaving areas vulnerable to splitting by moving one piece. I shall try to devise strategies to let the computer player play very well but also variably on a scale of 1-10 where 1 is feeble and 10 is supremely clever.

Here is a list of proposed tutorials.

  • Tutorial One.  About the game (This article!)
  • Tutorial Two. Draw hexagon maps using SDL.
  • Tutorial Three. Devise and code up a map generator.
  • Tutorial Four. Add All pieces and initial hexagon ownership/Starting position.
  • Tutorial Five. Add a turn structure to the game and add hexagon selection by mouse.
  • Tutorial Six. Let the player add units to the map and attack enemy players.
  • Tutorial Seven. Add computer AI.
  • Tutorial Eight. Add game structures for Single map and Campaign games.
  • Tutorial Nine. Polish the game and finish off. Add Raspberry Pi specific code.

Some of the code will come from the Empire game (See on GitHub).


(Visited 506 times, 1 visits today)