Chess engine for developers. Pieces are services, board is architecture, checkmate is prod outage, castling is failover.
  • JavaScript 100%
Find a file
2026-06-30 11:14:20 +00:00
node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709 fix: e2e tests now use CommonJS require for node --test compatibility 2026-06-30 11:14:17 +00:00
src feat(#1): chess engine — pieces, board, legal moves, AI, check detection, ASCII board 2026-06-15 16:08:21 +00:00
tests fix: e2e tests now use CommonJS require for node --test compatibility 2026-06-30 11:14:17 +00:00
package.json feat(#1): chess engine — pieces, board, legal moves, AI, check detection, ASCII board 2026-06-15 16:08:21 +00:00
README.md feat(#1): chess engine — pieces, board, legal moves, AI, check detection, ASCII board 2026-06-15 16:08:21 +00:00

code-chess

Chess engine for developers. Pieces are services, board is architecture, checkmate is prod outage, castling is failover.

Usage

const { Board, PIECE_TYPES } = require('./src/chess');

const board = new Board();
console.log(board.render());

// Make moves
board.makeMove(6, 4, 4, 4); // e2-e4 (pawn/microservice advances)
board.makeMove(0, 6, 2, 5); // Ng8-f6 (knight/worker deploys)

// AI plays itself
while (!board.gameOver && board.moveHistory.length < 50) {
  board.aiMove(board.turn);
}

console.log(board.render());
console.log(board.status());
console.log('FEN:', board.toFEN());

Piece Mapping

  • King (Core Service) — value 1000, lose it and the game is over
  • Queen (Database) — value 9, most powerful, handles everything
  • Rook (Cache Layer) — value 5, straight-line scaling
  • Bishop (Message Queue) — value 3, diagonal/async routing
  • Knight (Worker Process) — value 3, jumps over everything, background jobs
  • Pawn (Microservice) — value 1, can promote (scale up) at end of board

Features

  • Full legal move validation for all 6 piece types
  • Pawn promotion (microservice scales to full service)
  • King capture = game over (prod outage)
  • Simple AI (capture-priority with random tiebreak)
  • FEN notation export (infra state snapshot)
  • ASCII board with coordinate labels
  • Move history (deploy log)
  • Check detection