Iohorizontictactoeaix

IOHORIZONTICTACTOEAIX is a digital implementation of the classic two-player game Tic-Tac-Toe, where the user plays as X and the AI plays as O. The name suggests an “IO” (input/output) structure, a “Horizon” concept (possibly referring to the AI’s search depth or a futuristic UI), and an emphasis on AI behavior.

Set a short setTimeout after human move to simulate “thinking” – adds polish.


Human player = 'X' (moves first by default).
AI = 'O' (moves second).


Due to space, here’s a condensed minimax implementation for horizontal tic-tac-toe in JavaScript: iohorizontictactoeaix

function aiMove() 
  let bestScore = -Infinity;
  let bestMove = null;
  for (let move of getEmptyCells(board)) 
    board[move.row][move.col] = 'O';
    let score = minimax(board, 0, false);
    board[move.row][move.col] = '';
    if (score > bestScore) 
      bestScore = score;
      bestMove = move;
if (bestMove) 
    board[bestMove.row][bestMove.col] = 'O';
    checkGameState();
    drawBoard();

function minimax(board, depth, isMax) if (checkWin(board, 'O')) return 10 - depth; if (checkWin(board, 'X')) return depth - 10; if (isDraw(board)) return 0;

if (isMax) let maxEval = -Infinity; for (let move of getEmptyCells(board)) board[move.row][move.col] = 'O'; let eval = minimax(board, depth + 1, false); board[move.row][move.col] = ''; maxEval = Math.max(maxEval, eval); return maxEval; else let minEval = Infinity; for (let move of getEmptyCells(board)) board[move.row][move.col] = 'X'; let eval = minimax(board, depth + 1, true); board[move.row][move.col] = ''; minEval = Math.min(minEval, eval); return minEval;


The "Horizon" look is achieved using the Minimax Algorithm. This is a recursive algorithm used in two-player games to minimize the possible loss for a worst-case scenario.

Tic-tac-toe is a simple two-player game played on a 3×3 grid. Players take turns marking X or O; the first to get three in a row (horizontally, vertically, or diagonally) wins. Because the game has only 765 possible game positions (and 255,168 possible total games), it is considered a solved game—perfect play leads to a draw.

In classic tic-tac-toe, the center square is critical (part of 4 winning lines).
In horizontal-only tic-tac-toe: Human player = 'X' (moves first by default)

The minimax strategy will exploit this: blocking the human’s row completion becomes priority #1.


A practical AI for IoHoriZonticTacToe would combine three modern AI techniques: