Files
ttt/README.md
T
daniel-jircaandrobi c4d707b5ad docs: make README consistent with implementation (#1)
## Summary

The README described two behaviors that don't match the actual code. This PR corrects both so the docs are accurate.

## Changes

- **CPU mode**: README claimed a *minimax* AI, but `public/game.js` (`cpuMove`) picks a random empty cell. Updated to say *random AI*.
- **SQLite**: README said `sql.js` runs *in-memory*, but `server/db.js` persists to a file (`server/data/games.db`). Updated to say *file-based persistence*.

No code changes — documentation only.

---------

Co-authored-by: robi <robi@alecsa.design>
Reviewed-on: #1
Reviewed-by: robi <robi@alecsa.design>
2026-09-27 18:17:19 +03:00

1.3 KiB

Tic Tac Toe

A tic-tac-toe game with two modes: CPU (play against a CPU opponent that makes random moves) and Online (real-time 2-player over WebSocket).

Stack

  • Frontend: vanilla JS + CSS (no build step)
  • Backend: Node.js + Express (serves static files) + ws (WebSocket) + sql.js (SQLite, file-based persistence)

Project layout

public/            frontend (index.html, app.js, game.js, multiplayer.js, style.css)
server/            backend (server.js, db.js, package.json, pnpm-lock.yaml)
docs/              design docs
Dockerfile         production image
docker-compose.yml

Run locally

The backend lives in server/ (the frontend has no build step).

# install backend deps (pnpm)
cd server && pnpm install

# start (default port 8080)
node server/server.js
# or with an explicit port
PORT=8080 node server/server.js

Then open http://localhost:8080/.

The server reads PORT (default 8080) and optional BASE_PATH (default empty).

Run with Docker

docker compose up --build

or build and run the image directly:

docker build -t tictactoe .
docker run -p 8080:8080 tictactoe

Then open http://localhost:8080/.

Notes

  • server/data/ holds the SQLite file and is git-ignored.
  • Online games persist to SQLite; a host who reloads can re-enter via the saved token.