Skip to content

salahchenikhar/tic_tac_toe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Autonomous Tic-Tac-Toe

A modern, polished Tic-Tac-Toe game built with Flutter. It features a sophisticated AI bot, a dynamic undo system, and a sleek dark-themed UI.

Features

  • Game Modes:
    • Human vs Human: Classic two-player local multiplayer.
    • Human vs Bot: Play against a smart AI with three difficulty levels.
  • Bot AI (Autonomous Logic):
    • Easy: Makes random moves.
    • Medium: Blocks you if you're about to win, otherwise plays randomly.
    • Hard: Prioritizes winning moves, blocks your wins, and makes strategic choices.
  • Fair Play Logic: The game automatically alternates who starts (X) after every reset.
  • Dynamic Undo System:
    • Earn "Undo Credits" by making moves.
    • Undoing in Bot Mode reverts both the bot's response and your last move.
    • Prevented from "undoing" the bot's initial move to maintain fair turn order.
  • Premium UI: Sleek dark mode, custom-styled buttons, and smooth board transitions.

Tech Stack

  • Framework: Flutter
  • State Management: Provider
  • Logic: Custom autonomous board mechanics and bot simulation.

AI Logic (The "Brain")

The bot uses a simulation-based approach to decision making:

  1. Victory check: It first checks if any available move would result in its own immediate win.
  2. Block check: It then checks if any player move would result in a player win and blocks it.
  3. Randomization: If neither condition is met (or for lower difficulty levels), it picks a move at random from the available squares.

Installation

  1. Clone the repository:
    git clone https://github.com/your-username/tic_tac_toe.git
  2. Install dependencies:
    flutter pub get
  3. Run the app:
    flutter run

Project Structure

  • lib/models/board.dart: Pure board state and win/draw logic.
  • lib/models/bot.dart: AI simulation and move selection.
  • lib/models/game.dart: High-level game orchestration (modes, resets).
  • lib/Providers/game_provider.dart: Reactive state management and undo tracking.
  • lib/screens/game_screen.dart: Polished UI and settings.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors