Simple 1-2 player Reversi game for Windows, implemented in GameMaker.
About this game
I built this game in 2008 over the space of a few days. It was a personal fun project, with some additional artwork kindly provided by Tommy Kraft of Project[N]ReSource. It can be played in 2 player mode, or against the computer at 3 difficulty levels. Novice players tend to find the AI quite challenging, but it’s actually really easy to beat when you figure out a decent strategy!
The AI is implemented using a combination of techniques. It starts with a pre-defined set of ‘weights’ for each square of the board, each weight being the general desirability of that square under most circumstances. These were determined manually from playing the game myself, and also by consulting strategy guides on the Internet, but it generally marks the four corner squares as extremely desirable. The squares adjacent to the corner squares as undesirable (as they enable your opponent to take the corners), and everything else is given a weight which favours the squares closer to the middle. (It is wise to avoid spreading your counters too far out early on in the game… try this strategy yourself and you’ll probably beat the AI easily).
Next, the game looks at every possible move it could make, and identifies which would grant the highest score for the AI, and the lowest score for the human player (essentially a single-depth minimax algorithm). The potential score is then combined with the weights to determine the final desirability of each square. The different difficulty settings handle the information in their own way:
- Easy – picks any legal move at random
- Medium – uses a roulette-wheel method of random selection based on desirability (basically, it’s more likely to choose a strong move, but there’s a chance it won’t)
- Hard – same as medium, but omits the weaker moves from the selection (so there’s almost no chance it will pick a weak move unless there is nothing else to do)