Back to Projects

Tic-Tac-Toe

A browser-based Tic-Tac-Toe game built with HTML, CSS, and JavaScript, featuring single-player AI and two-player modes.

2023

Duration

Sep 2023

Team Size

1 people

Technologies

3+ tech

Tic-Tac-Toe

Project Overview

A web-based Tic-Tac-Toe game developed with vanilla HTML, CSS, and JavaScript. The game supports both single-player mode against an AI opponent and local two-player mode. The AI uses the minimax algorithm to play optimally, with difficulty levels adjusting the search depth. A save and load feature persists game state to localStorage so players can resume at any time.

Features

  • Classic Tic-Tac-Toe gameplay with a clean, intuitive interface
  • Single-player mode against an AI opponent using the minimax algorithm
  • Two-player mode for competitive local play
  • Multiple AI difficulty levels to suit all players
  • Save and load game functionality via localStorage for resuming play

Challenges

  • Implementing a minimax AI that plays optimally in vanilla JavaScript
  • Designing a difficulty system that feels meaningfully different across levels
  • Persisting game state to localStorage cleanly without a backend

Solution

Implemented minimax with alpha-beta pruning for the AI. Difficulty levels reduce the AI's search depth to introduce imperfection at lower settings. Game state is serialized to JSON and stored in localStorage on every move.

Architecture

Single-page vanilla JavaScript application. Game state is managed in a plain JS object. DOM manipulation updates the board after every move. localStorage handles persistence. GitHub Pages hosts the live demo.

Results & Impact

  • Live demo playable directly in the browser via GitHub Pages
  • Minimax AI is unbeatable at maximum difficulty
  • Save/load feature works entirely client-side with no backend required
Technologies

Frontend

HTMLCSSJavaScript

Backend

Database

localStorage

Tools

GitGitHub Pages
Team
  • Ismail ZAHIR
License
MIT

Free to use, modify, and distribute with attribution.

Project Tags
HTMLCSSJavaScript

More Projects

NexoWorld
2024
An AR mobile game where players explore real-world locations to earn in-app currency and complete challenges — built on a Spring Boot microservices backend with real-time location sync.
Spring BootFlutterMongoDB+5
Kolchi.ma
2024
A full-featured Moroccan e-commerce and repair marketplace connecting buyers, sellers, and service providers on a polyglot microservices platform with real-time messaging.
DotNet CoreSpring BootNestJS+6