← Back to Work

Java • Game Tree Search

Tic-Tac-Toe AI

Tic-Tac-Toe is my compact playground for learning new technologies. This Java edition explores domain modelling, console interaction, and a stubborn intelligence that searches every future.

Rangmanch interface ready • Java runtime connection in progress

The Search

It does not guess. It examines the futures left on the board.

Every legal move is classified by recursively exploring the remaining game tree. A move is kept as a victory when one can be forced, as a draw when defeat can be avoided, and as a loss only when no stronger future remains.

Random selection happens only between outcomes of the same quality, so the play stays varied without becoming careless.

Victory first

Winning continuations outrank every alternative and are selected immediately.

Draw secured

When no forced win remains, the search protects the strongest non-losing path.

Varied play

Equivalent moves are chosen randomly, keeping repeated games from feeling scripted.

The Model

A compact domain model keeps the algorithm readable.

Board owns legal placement and win detection. Move carries position and sign. HumanPlayer and AbhishekAI share one Player contract, allowing either side of a match to be human or automated.

Each recursive branch copies the board before evaluating it. The live match remains untouched until the selected move is committed.

Board snapshots

Search branches evaluate isolated copies instead of mutating the active game.

Player strategy

Human and AI players satisfy the same move-selection contract.

Winning strokes

Rows, columns, and diagonals are reported as explicit game outcomes.

The Stage

A terminal application, presented without turning it into a web app.

Rangmanch preserves the program's native console interaction. The browser renders terminal state while the approved Java process remains the application of record.

The production session will be short-lived, rate-limited, isolated from the homelab, and destroyed when the game exits or the visitor leaves.

One fixed process

The runner starts this game directly; visitors never receive a general shell.

Ephemeral session

A backend-authored deadline and cleanup controller bound every execution.

Isolated by default

No public internet, persistent disk, cluster credential, or arbitrary image selection.

The Playground

One familiar game. A different technology lesson each time.

Tic-Tac-Toe gives every experiment the same small, understood problem space. That leaves the interesting differences exposed: language design, state management, rendering, interaction, packaging, and runtime behaviour.

This console edition became a way to explore Java and game-tree search. A later browser edition became my bridge from React into Svelte. The board stays familiar while the technology changes around it.

Java console

Domain modelling, recursive search, and native terminal interaction.

Svelte browser

A practical way to learn Svelte through a UI already familiar from React.

Rangmanch

The same playground now exercises ephemeral application delivery in the browser.

Rangmanch Demo

Play the console edition

Challenge the original Java interface inside a short-lived Rangmanch terminal.

Java 21 • ConsoleEphemeral

tic-tac-toe-java

Ready

15:00

The terminal is ready.

Run the interface rehearsal while the isolated Java runtime is connected.

One visitor · One process · No persistent stateCtrl+C exits the preview

Built With

JavaMinimaxConsole I/ORangmanch

The Match Ends

Tiny board. Complete search space.

The interesting part is not the size of the game. It is the discipline of modelling every state clearly enough that the strongest move falls out of the system.

RANGMANCH READY

Tic-Tac-Toe AI • Built by Abhishek Kashyap

Read the original Java

The source keeps the board, moves, players, win detection, and recursive AI together in a compact console program.

View Repository (opens in a new tab)

Runtime, not rewrite

The production demo will execute the console application through Rangmanch rather than replacing it with browser game logic.