โโโ โโโโโโ โโโโโโ โโโ โโโโโโ โโโ
โโโ โโโโโโ โโโโโโโ โโโ โโโโโโโโโโโ
โโโ โโโโโโโโโโ โโโ โโโโโโโโโโโโโโโโโโโโ
โโโ โโโโโโโโโโ โโโ โโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโ โโโโโโโโโโโโ โโโ โโโโโโ
โโโโโโโโโโโโโโ โโโ โโโโโโโ โโโ โโโโโโ
AI-Enhanced Terminal Game Platform with Real-Time WebSocket Communication
Quick Start โข For AI Agents โข For Developers โข Games โข API Reference
DO NOT run
npm startin VS Code's integrated terminal!This is a TUI that will hang your IDE. You MUST:
- Read LIKU-CORE.md - Essential setup and launch instructions
- Read game docs in
docs/ai/before playing any gameThe correct way to launch is via
Start-Process(Windows) or background process (Linux). See LIKU-CORE.md for details.
Liku-AI is a terminal-based game platform designed for both human players and AI agents. It provides:
| Feature | Description |
|---|---|
| ๐ฎ Terminal Games | Chess, Snake, Dino Run, Tic-Tac-Toe with React/Ink TUI |
| ๐ค AI Agent API | Real-time WebSocket control for any AI model |
| โ๏ธ Chess Engine | Alpha-beta search, 20+ openings, Elo rating system |
| ๐ Training Tools | Session recording, replay, self-play, A/B testing |
| ๐ Cross-Platform | Windows, macOS, Linux, GitHub Codespaces |
Use Cases:
- Play terminal games as a human
- Build AI agents that play games autonomously
- Train models with recorded game sessions
- Benchmark AI strategies with Elo ratings
| Requirement | Version | Check Command |
|---|---|---|
| Node.js | 20.x+ | node --version |
| npm | 10.x+ | npm --version |
# Clone repository
git clone https://github.com/TayDa64/Liku-AI.git
cd Liku-AI
# Install dependencies
npm install
# Build TypeScript
npm run build
# Start the game!
npm startUse arrow keys to navigate, Enter to select, Escape to go back.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ LIKU-AI v2.0 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ > ๐ฎ Let's Play โ
โ โ๏ธ Chess โ
โ ๐ Stats & Leaderboards โ
โ โ๏ธ Settings โ
โ ๐ช Exit โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Liku-AI is designed to be controlled by AI models (Claude, GPT, Gemini, etc.) through a state file + command interface.
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ AI Agent โ โโโโ โ State File โ โโโโ โ Liku-AI โ
โ (Claude, โ read โ likubuddy- โ โ Terminal โ
โ GPT, etc.) โ โ state.txt โ โ Game โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ โฒ
โ โโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโ โ Commands โ โโโโโโโโโโโโโ
send โ WebSocket โ control
โ or Scripts โ
โโโโโโโโโโโโโโโโ
# 1. Start game in separate window
Start-Process pwsh -ArgumentList "-NoExit", "-Command", "cd C:\dev\Liku-AI; node dist/index.js"
# 2. Read current state
Get-Content .\likubuddy-state.txt
# 3. Send commands
.\send-keys.ps1 -Key "{DOWN}" # Navigate down
.\send-keys.ps1 -Key "{ENTER}" # Select item# 1. Start game in background
node dist/index.js &
# 2. Read current state
cat likubuddy-state.txt
# 3. Send commands via WebSocket
./send-keys.sh -Key "{DOWN}" # Navigate down
./send-keys.sh -Key "{ENTER}" # Select item
# Alternative: Direct WebSocket
node send-command.js --key down
node send-command.js --key enter| Command | Windows | macOS/Linux | Description |
|---|---|---|---|
| Navigate Up | .\send-keys.ps1 -Key "{UP}" |
./send-keys.sh -Key "{UP}" |
Move selection up |
| Navigate Down | .\send-keys.ps1 -Key "{DOWN}" |
./send-keys.sh -Key "{DOWN}" |
Move selection down |
| Select | .\send-keys.ps1 -Key "{ENTER}" |
./send-keys.sh -Key "{ENTER}" |
Confirm selection |
| Back | .\send-keys.ps1 -Key "{ESCAPE}" |
./send-keys.sh -Key "{ESCAPE}" |
Go back / Exit |
| Jump (Dino) | .\send-keys.ps1 -Key " " |
./send-keys.sh -Key " " |
Space bar |
| Chess Move | .\send-keys.ps1 -Key "e4" |
./send-keys.sh -Key "e4" |
Type move notation |
The likubuddy-state.txt file updates in real-time with:
=== LIKU-AI STATE ===
SCREEN: chess
STATUS: Your turn (White)
TURN: white
FEN: rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1
VISUAL STATE:
a b c d e f g h
8 r n b q k b n r
7 p p p p p p p p
...
STRUCTURED STATE (JSON):
{"screen":"chess","turn":"white","fen":"..."}
| Document | Purpose |
|---|---|
| LIKU-CORE.md | Complete AI agent manual |
| docs/ai/LIKU-CHESS.md | Chess-specific AI guide |
| docs/ai/LIKU-SNAKE.md | Snake AI guide |
| docs/AI_AGENT_BRIEFING.md | Quick agent briefing |
| Game | Description | Controls | AI Support |
|---|---|---|---|
| โ๏ธ Chess | Full chess engine with 5 difficulty levels | e4, Nf3, h (hint), u (undo), r (resign) |
โ Minimax + Opening Book |
| ๐ Snake | Classic snake game | Arrow keys | โ State-based AI |
| ๐ฆ Dino Run | Chrome dinosaur clone | Space (jump), Down (duck) | โ Obstacle prediction |
| โญ Tic-Tac-Toe | Unbeatable AI opponent | Number keys 1-9 | โ Perfect play AI |
| ๐ Hangman | Word guessing game | Letter keys | โ Human only |
| ๐ข Sudoku | Number puzzle | Number keys | โ Human only |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Chess Engine โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Search: Alpha-Beta with Iterative Deepening โ
โ Features: Transposition Table, Quiescence Search โ
โ Opening Book: 20+ named openings โ
โ Evaluation: Material, Position, Pawn Structure โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Difficulty โ Depth โ Time โ Est. Elo โ
โ โโโโโโโโโโโโผโโโโโโโโผโโโโโโโโโผโโโโโโโโโโ โ
โ Easy โ 2 โ <1s โ ~1000 โ
โ Medium โ 3 โ ~2s โ ~1200 โ
โ Hard โ 4 โ ~5s โ ~1400 โ
โ Expert โ 5 โ ~15s โ ~1600 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
liku-ai/
โโโ src/
โ โโโ index.tsx # Entry point (React/Ink TUI)
โ โโโ chess/ # Chess engine
โ โ โโโ ChessAI.ts # AI player (minimax)
โ โ โโโ ChessEval.ts # Position evaluation
โ โ โโโ ChessSearch.ts # Alpha-beta search
โ โ โโโ OpeningBook.ts # 20+ named openings
โ โโโ websocket/ # WebSocket server
โ โ โโโ server.ts # WS server (port 3847)
โ โ โโโ router.ts # Command routing
โ โ โโโ cli.ts # Standalone server CLI
โ โโโ training/ # Training infrastructure
โ โ โโโ SessionRecorder.ts # Record game sessions
โ โ โโโ SessionPlayer.ts # Replay sessions
โ โ โโโ ABTest.ts # A/B testing framework
โ โโโ ui/games/ # Game components
โ โ โโโ Chess.tsx # Chess UI
โ โ โโโ Snake.tsx # Snake game
โ โ โโโ DinoRun.tsx # Dino game
โ โ โโโ TicTacToe.tsx # Tic-Tac-Toe
โ โโโ core/ # Core utilities
โ โโโ StateLogger.ts # State file writer
โ โโโ DatabaseService.ts # SQLite database
โโโ scripts/ # Utility scripts
โ โโโ chess-ai-battle.js # AI vs AI matches
โ โโโ self-play.ts # Training data generation
โ โโโ elo-estimate.ts # Elo calculation
โโโ __tests__/ # Test files (514 tests)
โโโ docs/ # Documentation
โโโ k8s/ # Kubernetes manifests
โโโ send-keys.ps1 # Windows keystroke sender
โโโ send-keys.sh # macOS/Linux keystroke sender
โโโ send-command.js # Cross-platform WebSocket CLI
โโโ likubuddy-state.txt # Real-time state file (generated)
| Script | Command | Description |
|---|---|---|
| Start | npm start |
Launch terminal UI |
| Build | npm run build |
Compile TypeScript |
| Dev | npm run dev |
Watch mode (auto-rebuild) |
| Test | npm test |
Run Vitest tests |
| Server | npm run server |
WebSocket server only |
| AI Battle | npm run ai-vs-ai |
Run AI vs AI chess match |
Connect to ws://localhost:3847 for real-time communication:
// Example: Connect and send commands
import WebSocket from 'ws';
const ws = new WebSocket('ws://localhost:3847');
ws.on('open', () => {
// Send a key press
ws.send(JSON.stringify({ type: 'key', key: 'down' }));
// Send a chess move
ws.send(JSON.stringify({ type: 'action', action: 'chess_move', params: { move: 'e4' } }));
// Query current state
ws.send(JSON.stringify({ type: 'query', query: 'state' }));
});
ws.on('message', (data) => {
const response = JSON.parse(data.toString());
console.log('Response:', response);
});Message Types:
| Type | Purpose | Example |
|---|---|---|
key |
Send keystroke | { type: 'key', key: 'enter' } |
action |
Game action | { type: 'action', action: 'chess_move', params: { move: 'e4' } } |
query |
Request data | { type: 'query', query: 'state' } |
| Variable | Default | Description |
|---|---|---|
LIKU_WS_PORT |
3847 |
WebSocket server port |
LIKU_HEALTH_PORT |
3848 |
Health check endpoint |
GEMINI_API_KEY |
โ | Google AI for move explanations |
# Run all tests
npm test
# Run once (CI mode)
npm run test:run
# Run specific test file
npx vitest run __tests__/WebSocket.test.ts
# Run with coverage
npx vitest run --coverageTest Coverage:
| Module | Tests | Coverage |
|---|---|---|
| WebSocket | 179 | ~95% |
| Training | 93 | ~95% |
| Spectator | 93 | ~95% |
| Security | 43 | ~90% |
| TURN | 40 | ~90% |
| Total | 514 | ~95% |
# Generate training data from AI vs AI games
npx tsx scripts/self-play.ts --games 20 --depth-range 2-4
# Estimate Elo rating from recorded games
npx tsx scripts/elo-estimate.ts --verbose
# Run AI battle with specific settings
node scripts/chess-ai-battle.js --white=minimax --black=minimax --depth=4# Build image
docker build -t liku-ai .
# Run container
docker run -p 3847:3847 -p 3848:3848 liku-ai
# Docker Compose (with Redis)
docker-compose up -d| Document | Audience | Description |
|---|---|---|
| LIKU-CORE.md | AI Agents | Complete AI agent operation manual |
| Quick Reference | Everyone | One-page command cheatsheet |
| API Reference | Developers | WebSocket API documentation |
| WebSocket Protocol | Developers | Protocol specification |
| Troubleshooting | Everyone | Common issues & solutions |
| AI Battle Guide | Developers | AI vs AI game setup |
| Performance | Developers | Benchmarks & load tests |
| Game | AI Guide |
|---|---|
| Chess | docs/ai/LIKU-CHESS.md |
| Snake | docs/ai/LIKU-SNAKE.md |
| Tic-Tac-Toe | docs/ai/LIKU-TICTACTOE.md |
| Dino Run | docs/ai/LIKU-DINORUN.md |
| Problem | Solution |
|---|---|
| "Cannot find module 'dist/index.js'" | Run npm run build first |
| WebSocket connection refused | Ensure server is running: npm run server |
| State file not updating | Check game is running in separate terminal |
| Commands not working | Verify game window has focus (Windows) or WebSocket port 3847 is open |
| Permission denied on send-keys.sh | Run chmod +x send-keys.sh send-command.js |
Windows:
- PowerShell 5.1+ required
send-keys.ps1uses COM automation (requires foreground window)
macOS:
- Bash 3.2+ compatible (native macOS shell works)
send-keys.shuses WebSocket (no GUI requirements)
Linux / Codespaces:
- Works fully headless via WebSocket
- No display server required
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit changes:
git commit -m 'Add my feature' - Push to branch:
git push origin feature/my-feature - Open a Pull Request
# Clone your fork
git clone https://github.com/YOUR_USERNAME/Liku-AI.git
cd Liku-AI
# Install dependencies
npm install
# Start dev mode (auto-rebuild)
npm run dev
# In another terminal, run the app
npm startMIT License โ see LICENSE for details.
- chess.js โ Chess move generation & validation
- Ink โ React for command-line interfaces
- ws โ WebSocket implementation
- Vitest โ Testing framework
- Chess Programming Wiki โ Engine algorithms reference
Version: 2.0.0 โข Tests: 514 passing โข Platforms: Windows, macOS, Linux
Made with โค๏ธ for AI agents and humans alike
