Mahjong solitaire and hidden complexity

I don't know how, but for some reason my mind wandered into Mahjong solitaire a couple days ago.

I used to play it probably on my first MSDos computer, and it brought back fond memories. The rules are simple, yet the amount of blocks makes it rather challenging to solve.

Mah Jongg Solitaire from 1987

The game is genius in its way of having simple rules — much like with Minesweeper or other solitaires — but implementing a good Mahjong is much more nuanced than what you'd think.

Let's look at the Minesweeper for a moment. When you start a new game, you have a grid of unopened boxes that may contain mines at any point. But clicking on a single tile and immediately finding a mine is rather bad UX for the player.

Image about losing on the first mine

Rather you want to create the board based on the first click of the player. It's even better if the first click always hits an empty block that opens a bit bigger area than just the single tile.

Ending a game of Minesweeper is also a challenging task to implement. While most of the gameplay is based on pure logic, you can sometimes get to a situation where the only solution is to guess with 50% chance. Exploding at that point is probably the most frustrating thing in the game.

Image where there's 50-50 chance to guess which square has mine

As a game developer we can of course avoid these luck traps, and invalidate a randomized board state if it contains these only-solvable-by-chance situations.

And that's the beauty of these games. They seem so simple when looking just from the player's perspective — and if the game has been developed not to contain these bad situations, you'll never even experience the hidden complexity.

Play the game

These findings come from creating a Mahjong solitaire game in 2 hours. As always you can play the game for free:

Play Simple Mahjong Solitaire