3D Slime War Board Game (Source Code Included)
This board game is called 'Slime War' or Splat. To many of you this sounds unfamiliar, but it is a popular board game.
The rule is simple. Each player begins with 2 pieces at the corners of the board and takes turns. When one makes a move they can either 'duplicate' their piece by moving it one square from its original position OR they can move it two squares away from its original position WITHOUT getting an extra piece.
Wherever the piece lands the adjacent opponent's pieces are turned into mover's. By definition 'adjacent' means any square immediately next to the moved piece.
In the end the player with more pieces wins. It is incredibly easy to learn, yet incredibly hard to master.
I developed this board game in the C programming language with OpenGL API. The game is three dimensional with nice graphics. Its computer player has six intelligence levels.
I pitted the computer player against human players online. I remember I played about 30 games and only one person managed to win 25 to 24, with AI level set to 4 :-)
You have to understand level 4 is not a high level considering computer's computing power; level 6 is much more sophisticated but each move takes a longer time.
There are some games that human just can't play well, and I believe Slime War is one of them.
The game is quite simple to implement. The AI player is more sophisticated but is still easy to write. I use the popular artificial intelligence algorithm called Alpha Beta Pruning and it works like a charm!
Here's how the artificial intelligence algorithm works. When it's the computer player's turn, the program would collect every possible move.
The program would simulate making every possible move, and in each resulting configuraiton the program would further collect every possible move. Each level of collecting moves is an additional level of computation and 'intelligence'.
When the program reaches the configured level of depth, the program assigns a score to each unique configuration, and the configuration with the highest score wins.
The way a score is assessed is critical and it defines how 'smart' the computer player is. In the Slime War (or Splat) game the way to assign a score is simple: the more the computer player's pieces on the board the higher the score.
In other games you may not be so lucky. For example in the Chinese five-in-a-row board game it's hard to tell whether a board configuration is better or worse than another board configuration.
Here are some screen shots of this game:
Here's the Windows executable so you can play this game on your Windows PC.
Windows Executable for Splat Game with OpenGL
Here's the entire source code. Use at your own risks.
Source Code for Splat Game with OpenGL