Click here to Skip to main content
15,867,453 members
Articles / Programming Languages / C#

Connect4

Rate me:
Please Sign up or sign in to vote.
3.31/5 (7 votes)
11 Apr 2009CPOL1 min read 55.1K   1.8K   20   4
The turn based classic game Connect4 with computer AI
Image 1

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader Link Development
Egypt Egypt
IF YOU WANT TO IMPROVE YOUR SOFTWARE, DON'T TEST MORE; DEVELOP BETTER.

http://bishoylabib.blogspot.com

Comments and Discussions

 
GeneralMy vote of 5 Pin
Fiwel16-Feb-12 5:22
Fiwel16-Feb-12 5:22 
QuestionNo tutorial? Pin
elvingpr28-Jan-10 9:01
elvingpr28-Jan-10 9:01 
GeneralMy vote of 1 Pin
Alberto Venditti19-Apr-09 22:53
Alberto Venditti19-Apr-09 22:53 
GeneralLooks good but more is needed Pin
spoodygoon11-Apr-09 14:42
spoodygoon11-Apr-09 14:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.