Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Connect4

0.00/5 (No votes)
11 Apr 2009 1  
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:

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

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here