i.ZAHIR
Loading0%
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

Contributors

1 contributor

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
Contributors1
License
MIT

Free to use, modify, and distribute with attribution.

Project Tags
HTMLCSSJavaScript

More Projects

ngx-auth-client
2026Current
A published npm package that exposes Angular authentication as signals instead of getters, ships a Keycloak adapter behind a provider-agnostic port, and keeps tokens out of localStorage entirely.
AngularTypeScriptKeycloak+6
ngx-api-client
2026Current
A published npm package extracted from the same api.service.ts I had copied across four Angular projects — configurable versioning, RFC 9457 error normalization, retry with backoff, and zero UI dependencies.
AngularTypeScriptRxJS+5