Working example + reusable specification
Tic-Tac-Toe AI Coding Prompt
Build a complete browser Tic-Tac-Toe campaign with four difficulty levels, tactical and minimax opponents, persistent records, and guarded asynchronous turns.
01 / What it builds
A complete interaction, not a loose concept
Copy a complete AI coding prompt for a responsive Tic-Tac-Toe game with four computer opponents, minimax AI, accessibility, persistence, and tests.
- Four computer difficulty levels
- Progressive campaign and persistent records
- Keyboard, touch, and screen-reader support
- Deterministic rules and AI tests
02 / Complete prompt
Copy the build specification
Project: Tic-Tac-Toe Arena Objective Build a complete, responsive Tic-Tac-Toe game in which one player competes against four progressively stronger computer opponents. The experience must be playable with mouse, touch, or keyboard and preserve validated progress between sessions. Functional Requirements - Let one local player play as X against a computer opponent as O. - Include Easy, Medium, Hard, and Expert AI difficulties. - Use tactical win/block logic for Medium and full-depth minimax for Expert. - Add a progressive campaign that advances after two wins at each difficulty. - Track wins, losses, draws, streak, campaign progress, and preferences in localStorage. - Prevent player input while the computer is taking its turn. Technical Requirements - Use semantic HTML, responsive CSS, and vanilla JavaScript with native modules. - Keep game rules and AI independent from DOM rendering. - Guard delayed computer turns so stale timers cannot modify restarted or abandoned matches. - Validate persisted data before restoring it and fall back safely when data is malformed. Accessibility and Responsive Behavior - Support touch, mouse, keyboard, roving grid focus, screen-reader labels, reduced motion, and 44px minimum targets. - Build responsive portrait and landscape layouts without horizontal overflow. Acceptance Criteria - Every match ends in a player win, computer win, or draw according to standard Tic-Tac-Toe rules. - Expert difficulty does not lose from a legally reachable board state. - Restarting or navigating away prevents pending computer turns from changing the game. - Reloading restores valid records and preferences while rejecting malformed stored data. - Automated tests cover rules, AI decisions, persistence, navigation, and accessibility. Deliverables - A complete playable experience as the primary screen, not a landing page. - Modular application source and focused automated tests. - Concise instructions for running and testing the project locally. Provided by www.my-ai-prompts.com