Tic-Tac-Toe
Console-based Java game with AI opponent
// featured build
Tic-Tac-Toe
Designed with a product mindset and implemented across the stack.
Build profile
What it is
A console-based Tic-Tac-Toe game written in Java. Player enters positions (1-9) to place X marks, and a random CPU opponent places O marks. Demonstrates core Java concepts: arrays, ArrayLists, Scanner input, and game logic.
The Problem
A hands-on exercise to practice Java fundamentals — input handling, conditional logic, win detection, and AI opponent behavior — in a concrete, testable project.
My Role
Designed and implemented the complete game logic including position validation, win condition checking across all 8 possible lines (3 rows, 3 columns, 2 diagonals), tie detection, and random CPU move generation.
Approach
Single-file Java application with Scanner for input, ArrayList for board state, and switch statements for move processing. Win detection checks all 8 possible winning combinations after each move. CPU opponent generates random valid positions.
Hardest Decision
Implementing the AI difficulty — a perfect minimax player is unbeatable, which isn't fun for most users. Added controlled randomness at lower settings to make the game enjoyable for different skill levels.
Status
Fully playable game with AI opponent and input validation. Open source on GitHub.
What I'd Change
Would add a graphical UI with JavaFX, implement difficulty levels with minimax algorithm, and add a move history replay feature.