Project briefing illustration for tictactoe rules: a flat tactical intelligence sheet in the style of Star Fox Assault.
ACADEMIC PROJECT / CSCI 2251 - Computer Science Course

Java TicTacToe Game

I built a reference from the recovered TicTacToe requirements, resolved conflicting coordinate rules, and checked all 255,168 completed legal move sequences after the original final source could not be recovered.

JavaTicTacToestate machinesexhaustive testingreconstruction
TRY THE IDEA

Interactive demonstration

A new browser adaptation made in October 2026 using sample data. It illustrates the concepts; it is not the original submitted program.

X to move

Two players take turns. A row, column, or diagonal of three wins. Invalid and post-game moves are rejected.

Why I reconstructed the rules

I used TicTacToe to work through validation, turn order, and termination in a state model small enough to inspect completely. With the final source missing, I built the reference from the surviving requirements and submission evidence.

I had a June 13, 2022 submission record and recovered requirements, but no final source archive. In October 2026, I built the reference implementation described here, resolved the conflicting coordinate conventions, and checked its rules and console behavior.

THE CHALLENGE

The challenge: resolving the coordinate conflict

I began with the concrete structure in the recovered requirements: TicTacToe.java, Main.java, a private 3×3 board, and an enum containing X, O, and EMPTY. I also had requirements for move validation, board printing, and the status values WIN, DRAW, and CONTINUE.

I used EMPTY as a deliberate enum value instead of treating null as an ordinary board state. I filled all nine cells in the constructor, kept the array private, exposed a text representation through a small accessor, and separated console formatting from rule transitions.

The surviving requirements gave me a real conflict to resolve: the prose suggests coordinates greater than zero, while the tests require indices 0 through 2. I followed the tests in the reference implementation and labeled the console consistently as zero-based. Making that decision explicit kept two incompatible coordinate systems from leaking into the same interface.

How I made rejected moves leave no trace

PROJECT STEPS

How I control a move transition

Project briefing illustration for tictactoe rules: a flat tactical intelligence sheet in the style of Star Fox Assault.
STEP 01 OF 04
Validate the move

For my new 2026 TicTacToe reference, I accept a move only if its row and column are valid, the square is empty, and the game is still running. I check the coordinates before reading the board so an invalid position cannot cause an array error. Because the surviving written instructions and tests disagree, I follow the tests and number rows and columns from 0 through 2.

Select a step to follow the project.
Read all step descriptions
  1. Validate the move

    For my new 2026 TicTacToe reference, I accept a move only if its row and column are valid, the square is empty, and the game is still running. I check the coordinates before reading the board so an invalid position cannot cause an array error. Because the surviving written instructions and tests disagree, I follow the tests and number rows and columns from 0 through 2.

  2. Reject or commit

    I check each move before writing a single square in my 2026 reference. If the coordinates are invalid or the square is occupied, I leave both the board and current player unchanged. This means an unsuccessful attempt cannot be used to skip a turn.

  3. Evaluate status

    After accepting a move, I check all eight possible winning lines: three rows, three columns, and two diagonals. I require three matching X or O marks, since three empty squares do not count as a win. I check this before board fullness so a winning ninth move receives the correct result.

  4. Continue or freeze

    In my 2026 reference, I switch players only after an accepted move that leaves the game running. I stop accepting moves after a win or draw, keeping the finished result unchanged. I checked these changes before exploring every legal sequence of play; this verifies my new model, while the behavior of the missing 2022 submission remains unknown.

2026 reference rules: validate a move before changing the board, turn, or terminal state.

I made a move valid only when both coordinates are in range, the selected cell is empty, and the game is still running. I put the bounds test before any array access:

Illustrative java example
boolean inBounds = row >= 0 && row < 3
        && column >= 0 && column < 3;

Only after that predicate succeeds do I inspect the cell. Short-circuit evaluation keeps negative indices and coordinates equal to three from reaching an invalid array access.

I treated move application as a small transaction: validate, write one cell, and compute the resulting status. I switch players only after an accepted nonterminal move. If I reject a move, both the board and active player stay unchanged, so an occupied-square attempt cannot become a way to skip a turn.

I use a short manual sequence to make that rule visible: X plays (0,0), then O attempts (0,0). The second attempt must fail while O keeps the turn. A separate negative-index attempt should leave the same state unchanged.

Why I checked wins before a full board

I check all eight possible winning lines: three rows, three columns, and two diagonals. I count a line as a win only when all three values match and that value is not EMPTY.

After looking for a winner, I scan for an empty cell. If one remains, play continues; if none remains and no winner exists, the game is a draw. I needed that ordering because the ninth move can fill the board and complete a winning line simultaneously. Fullness must not override the win.

Once the game is terminal, I reject further moves. Checking that boundary preserves the result and prevents illegal continuations from entering the exhaustive traversal.

How I kept the console separate from the rules

For the new Main, I read two integers from one line, report malformed input, print the board after accepted moves, and let q or end-of-file end the session. I identify these conveniences as 2026 implementation choices because I cannot establish them as features of the missing final program.

I kept parsing separate from move so I could test the rules without a terminal and keep an input typo from changing state. I also used a scripted console session for malformed text, an occupied cell, a valid row win, and clean termination, while keeping direct rule tests as separate evidence.

How I explored every completed legal sequence

I explored the legal game tree in the reference tests. At each running position, the traversal copies the state, tries each legal move, and recurses. When it reaches a win or draw, it increments the matching total and stops expanding that branch.

My recorded October 2026 totals are:

  • 131,184 sequences ending in an X win
  • 77,904 sequences ending in an O win
  • 46,080 sequences ending in a draw
  • 255,168 terminal legal move sequences overall

I describe these as move sequences, not unique board positions. Different move orders can reach the same arrangement, so calling the total a count of distinct boards would misdescribe what I tested.

I established bounds, rejected moves, turn switching, and terminal freezing with targeted tests before relying on the traversal. A large total could otherwise hide a simple transition error. The restoration record includes those targeted checks, the exhaustive totals, and the console exercise.

What I learned without overstating the history

I ended with a two-local-player console reference and a state model whose rules I could inspect and exercise broadly. It has no AI opponent, networking, or graphical frontend. My main lesson was to define transitions before counting outcomes: exhaustive exploration verifies the new implementation within that model, but it cannot establish the absent 2022 submission's architecture or behavior. I keep the surviving receipt tied to the historical submission and the code and results tied to the 2026 reconstruction.

PROJECT WALKTHROUGH

Original final source unavailable; October 2026 reference built from recovered requirements and submission evidence, with targeted rules tests, exhaustive traversal, and a console check.

Validation & limitations

  • Original final source unavailable; October 2026 reference built from recovered requirements and submission evidence, with targeted rules tests, exhaustive traversal, and a console check.

Project records

  • Project artifacts and historical records, June 13, 2022 submission evidence
  • Restoration and public documentation, October 1, 2026
Course descriptions and assignment context
END OF PROJECT FILE RETURN TO ARCHIVE