GithubHelp home page GithubHelp logo

moncefzer / tic_tac_toe_ai Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 3.06 MB

This is a Tic Tac Toe game implemented in Flutter, featuring an AI opponent powered by the Minimax algorithm.

Kotlin 0.27% Swift 0.81% Objective-C 0.08% Dart 35.88% HTML 3.74% CMake 20.19% C++ 37.56% C 1.48%

tic_tac_toe_ai's Introduction

Tic Tac Toe with Minimax Algorithm

This is a Tic Tac Toe game implemented in Flutter, featuring an AI opponent powered by the Minimax algorithm. The Minimax algorithm is used to determine the optimal moves for the AI player, making it a challenging opponent to beat.

Game Description

Tic Tac Toe is a classic two-player game played on a 3x3 grid. The players take turns marking X or O in empty cells, with the goal of getting three of their marks in a row, column, or diagonal. The first player to achieve this wins the game. If all cells are filled without a winner, the game ends in a draw.

Demo

Screen_Recording_20230626_132224.mp4

Minimax Algorithm

The Minimax algorithm is a decision-making algorithm used in two-player games with perfect information. In our Tic Tac Toe game, it is employed by the AI opponent to determine the optimal moves.

The basic principle of the Minimax algorithm is as follows:

  1. The algorithm explores all possible moves and evaluates the resulting game states.
  2. Each game state is assigned a score, representing how favorable or unfavorable it is for the AI player.
  3. The algorithm assumes that the opponent plays optimally and selects the move that minimizes the AI player's score (worst outcome).
  4. It recursively explores deeper by simulating the opponent's moves and backtracks to assign scores.
  5. Finally, it selects the move with the highest score as the optimal move for the AI player.

By employing the Minimax algorithm, the AI opponent in our Tic Tac Toe game becomes more challenging, as it strives to make the best possible moves and maximize its chances of winning.

MinMax demo

Installation

  1. Clone the repository:

    git clone https://github.com/moncefzer/tic_tac_toe_ai.git
    
  2. Navigate to the project directory:

    cd tic_tac_toe_ai
    
  3. Install the required dependencies:

    flutter pub get
    
  4. Run the app:

    flutter run
    

License

This project is licensed under the MIT License

tic_tac_toe_ai's People

Contributors

moncefzer avatar

Stargazers

Zakaria Tikialine 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.