Giter VIP home page Giter VIP logo

connect4-ai's Introduction

Connect-4 AI Game

Introduction

Connect-4 is a classic two-player strategy game where players alternate turns dropping colored discs into a seven-column, six-row vertically suspended grid.

The objective is to be the first to form a horizontal, vertical, or diagonal line of four of one's own discs.

Connect-4 is a solved game, with the first player being able to force a victory with perfect play.

This project implements an AI to play Connect-4 using a neural network to evaluate game states, making it a challenging opponent for human players.

Features

  • AI that evaluates game states through a trained neural network.
  • Strategic game play, requiring players to think both offensively and defensively.
  • Graphical user interface using Pygame to play against the AI.

Getting Started

Prerequisites

  • Python 3.8 or higher
  • PyTorch
  • Pygame
  • Pandas
  • NumPy

Installation

  1. Clone the repository:

  2. Install the required packages:

    pip install torch 
    pip install pygame
    pip install pandas
    pip install numpy

Training the AI

Before playing against the AI, ensure that the neural network model is trained:

  1. Run Con4Train
    python3 Con4Train.py

This will train the neural network and save the model's state for use by the game AI.

Launch the Game

To start the game, run the Con4Main.py script after training the AI:

  1. Run Con4Train
    python3 Con4Main.py

connect4-ai's People

Contributors

julianjburgos 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.