Git Product home page Git Product logo

connect4's Introduction

Connect 4 with AI

Overview

This project implements a classic Connect 4 game in Python, featuring a graphical user interface provided by Pygame and an AI opponent powered by a minimax algorithm with alpha-beta pruning and iterative deepening. The AI's strategy is based on evaluating the game board to make intelligent moves against the player.

Installation

Prerequisites

Python 3.x

Pip (Python package installer)

Dependencies

Install the required Python packages using pip:

pip install pygame numpy

Running the Game
To start the game, navigate to the project directory and run the following command in your terminal:

bash
Copy code

python connect4.py  

Make sure to replace connect4.py with comparison and my_connect4_ai to use those instead.

Game Rules

The game is played on a vertical board consisting of 6 rows and 7 columns.
Two players take turns dropping colored discs into the columns of the board.
The first player to align four discs vertically, horizontally, or diagonally wins the game.
If all columns are filled and no player has achieved a line of four, the game is a draw.

Features

Graphical User Interface: Utilizes Pygame for rendering the game board and handling user interactions. AI Opponent: Employs a minimax algorithm with enhancements such as alpha-beta pruning for efficiency and iterative deepening for improved decision-making.
Dynamic Board Evaluation: The board is dynamically evaluated after each move to update the game state and determine the winner.

Contributions

Contributions to the project are welcome. Please ensure that you submit a pull request for review before merging your changes.

License

This project is open-sourced

Credits

Base code adapted from Keith Galli's Connect 4 repository.
Project maintained and extended by Tung Nguyen.

connect4's People

Contributors

ragnaorok avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.