Connect4






3.31/5 (7 votes)
The turn based classic game Connect4 with computer AI

Introduction
This is a Connect 4 game based on Silverlight. It contains computer AI that uses the Alpha Beta algorithm (a better alternative of Min Max algorithm).
Play the game here.
Background
The Alpha beta algorithm can be used in any turn based strategy game. A detailed explanation of these algorithms can be found in the following articles:
- Min Max: Connect4 using MIN-MAX algorithm
- Alpha Beta: Connect4 using Alpha-Beta Search algorithm
Using the Code
The solution contains the following projects:
GameThinking
A class library that contains the alpha beta algorithm. It’s implemented using generics so that this algorithm could be used with any game in the future.
Connect4Core
This is a library for connect4 games. It only contains data and logic and doesn't contain anything specific to Silverlight. It could be useful if you want to port it to another platform.
Contains the following classes:
-
Game
: The main class that represent the connect4 game which contains a main board, thinking board for computer AI usages and list of players. Board
: It’s the class that contains a board state with the current turn and moves history.
-
Connect4
This is the main Silverlight application. It has Silverlight user controls that provide the presentation logic of the above data classes.
History
- 11th April, 2009: Initial post