Wiley Man Logo
Tux Logo

TIC-TAC-PRO 3D

A fully interactive 3D tic-tac-toe engine with AI scoring, timing analytics, and a console-style ASCII board.

BOARD // REAL-TIME 3D VIEW

          
GAME LOG & TELEMETRY
Choose your marker [X or O], then press Submit:

How TIC-TAC-PRO 3D Works

🧩 3D Tic-Tac-Toe at a Glance

TIC-TAC-PRO 3D is a 3-dimensional take on classic tic-tac-toe. Instead of a single 3×3 grid, you play on a 3×3×3 cube made of three stacked boards. All winning lines are checked across this 3D structure: rows, columns, pillars, and full space diagonals.

The ASCII board on the left shows:

  • The top 3×3 layer (layer 0).
  • The middle 3×3 layer (layer 1).
  • A slanted bottom layer (layer 2), using slashes and pipes to suggest depth.

Each move “drops” your marker into a 3D column. You pick a square 1–9 using the green Moves helper grid, and the game finds the next available layer in that column, stacking from bottom to top.

📐 Board, Turns & Controls

  • Internally, the game uses a 3 × 3 × 3 array: [layer][row][col] with values: +1 for X, -1 for O, and 0 for empty.
  • At the start, you choose to play as X or O. The engine enforces that O always moves first.
  • To move, enter a number 1–9, matching the green Moves helper: 1 / 2 / 3, 4 / 5 / 6, 7 / 8 / 9.
  • When you choose a square, the engine finds the first free layer in that column (bottom to top). If all three layers are occupied, the column is considered full and you must choose another square.
  • You can quit at any time by entering q. The game logs that the human quit and ends the match.

🎯 What Counts as a Win?

The engine checks for three in a row across all 3D directions:

  • Rows along X on every layer.
  • Columns along Y on every layer.
  • Pillars along Z through the cube.
  • 2D diagonals on every fixed plane: constant Z (each board), constant Y (“walls” front/middle/back), constant X (“walls” left/middle/right).
  • 3D space diagonals that cut corner-to-corner across the cube.

For each line of three cells, the values are summed: +3 = X wins, -3 = O wins.

🤖 AI Strategy & Behavior

The AI plays as whichever marker you do not choose at the beginning of the game. Its move selection is a lightweight, tactical heuristic:

  1. Look for immediate wins. For every legal move, the AI temporarily places its piece and checks if that produces a winning line. If so, it takes that move.
  2. Block your wins. If there is no winning move, the AI simulates your move on each legal square and checks if you would win. If so, it plays there to block.
  3. Prefer the center. If there’s no immediate tactical move, the AI prefers the center square (5) when available.
  4. Fallback: random legal move. When nothing else stands out, it chooses randomly from remaining legal moves to keep the game varied.

Before each of its moves, the AI also writes a randomized robotic comment into the log, giving the sense of a sarcastic, slightly overconfident digital opponent.

🎛️ Visual Feedback

  • X markers are shown in green.
  • O markers are shown in purple.
  • The last move is highlighted in yellow.
  • If a win occurs, the entire winning line glows red.

📊 Timing, Telemetry & Score

  • Each move is timestamped. When a move completes, the engine computes how many seconds it took.
  • For both X and O, the game tracks:
    • Individual move times.
    • Total time spent.
    • Derived details like fastest and slowest moves.
  • The GAME LOG & TELEMETRY panel records:
    • Turn number, player, move (1–9), and elapsed time.
    • AI comments each time it moves.
    • Final outcome: who won or whether it was a draw.

🏆 End-of-Game Score Heuristic

At the end of each game, a simple score is computed for the winner. It’s designed to reward fast wins in fewer moves:

  • Base score starts at 1000.
  • Fewer turns add a bonus (shorter games score higher).
  • Lower total time adds another bonus (faster decision-making scores higher).

The resulting score is written to the log as: WINNER X — Score 1234.56. This can be wired into a future leaderboard or stored per user/session to track best runs.

🔁 Resetting & Playing Again

Each page load plays a single match from start to finish. When a winner is declared—or a draw occurs—the prompt is disabled and the status message invites you to refresh the page to play again. This keeps matches self-contained and makes it easy to plug into persistent stats, profiles, or multi-game analytics later.