GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - yohannes15/chess-engine: Full-featured chess library and multiplayer backend in Scala 3, Cats Effect, and Http4s with bitboards and alpha-beta pruning.

BranchesTags
Open more actions menu

Latest commit

 

History

125 Commits
125 Commits

Folders and files

NameName
Last commit message
Last commit date
.devcontainer
.devcontainer
 
 
.github
.github
 
 
frontend
frontend
 
 
project
project
 
 
src
src
 
 
.dockerignore
.dockerignore
 
 
.gitignore
.gitignore
 
 
.scalafmt.conf
.scalafmt.conf
 
 
Dockerfile
Dockerfile
 
 
README.md
README.md
 
 
build.sbt
build.sbt
 
 
fly.toml
fly.toml
 
 

Repository files navigation

Chess Engine

A purely functional chess engine and HTTP API in Scala 3, Cats Effect, and Http4s.

Portfolio

A purely functional chess engine implementation in Scala 3 that demonstrates advanced functional programming concepts and concurrent system design. Implements perft-validated move generation, FEN notation parsing, alpha-beta search with transposition tables and Zobrist hashing, piece-square evaluation, and a stateless HTTP API. Built with Cats Effect for side-effect management and Http4s for the REST API layer.

The goal is to create a production-ready chess library similar to Lichess's scalachess, with WebSocket support for live games and a stateless HTTP API for move validation and engine suggestions.

Status

Core engine is complete and tested. A basic frontend player-vs-engine mode is also working:

  • Domain model — Piece, Board, Square, Move, GameState, FEN notation, castling rights
  • Move generation — pseudo-legal + legal moves, perft-validated across 4 positions (depths 1–4)
  • Search — negamax with alpha-beta pruning, transposition table, Zobrist hashing
  • Evaluation — material counting + piece-square tables
  • HTTP API — health check, best-move suggestion, move validation
  • Multiplayer backend — GameRegistry with game creation, state lookup, move application
  • PGN parser — tag parser, SAN resolver with disambiguation, SAN encoder
  • Frontend MVP — Vite + React dark UI, visual board, legal move highlighting, engine auto-reply
  • Tests — 259 tests across 9 suites, all passing

Quick start

# rebuild devcontainer once (if not done already)
devcontainer up --workspace-folder . --remove-existing-container

# backend (terminal 1)
devcontainer exec --workspace-folder . sbt "~reStart"

# frontend (terminal 2)
devcontainer exec --workspace-folder . npm --prefix frontend run dev

# enter workspace folder in neovim
devcontainer exec --workspace-folder . nvim .

Stack

Language Scala 3.8.2
Build sbt 1.12.8
Effects Cats Effect 3, Http4s 0.23, Circe 0.14
Test MUnit + munit-cats-effect
Formatter scalafmt 3.10.7 (scala3 dialect, remove-optional-braces)
Plugins sbt-tpolecat (warnings-as-errors), sbt-revolver, sbt-assembly

Project structure

src/main/scala/chessengine/
├── domain/       Piece, Board, Square, Move, GameState, Fen, CastlingRights, Color, Role, Side
├── logic/        MoveGenerator — pseudo-legal + legal move generation, check/stalemate detection
├── engine/       Search (negamax + alpha-beta), Evaluation (material + PST),
│                 TranspositionTable, Zobrist hashing, Score, TTEntry
├── game/         GameRegistry — Ref-backed multiplayer game state
└── api/          Http4s server (port 8080), routes (health, best-move, validate-move,
                  game create/lookup/move), DTOs

frontend/src/
├── api/          typed fetch client generated from OpenAPI types
├── chess/        UI-only FEN helpers
├── components/   Board, Landing, GameView
├── modes/        PlayerVsEngine
└── types/        generated OpenAPI types

src/test/scala/chessengine/
├── domain/       SquareSuite (139), FenSuite (23), BoardSuite (9), GameStateSuite (23)
├── logic/        MoveGeneratorSuite (14) — perft tests
├── engine/       SearchSuite (4), EvaluationSuite (6)
└── api/          ChessRoutesSuite (8), GameRoutesSuite (7)

Architecture notes

  • Square is an opaque type wrapping Int (0–63), row-major: rank * 8 + file. a1=0, h8=63.
  • Board is a Vector[Option[Piece]] of length 64.
  • GameState.applyMove uses incremental Zobrist hashing — the hash updates on each move rather than recomputing.
  • TranspositionTable is a fixed-size array with a dual-bucket strategy (depth-preferred + recent-replace per bucket). Size must be a power of 2.
  • Search uses negamax with alpha-beta pruning. Checkmate scores are ply-adjusted before TT storage.
  • MoveGenerator.isLegal applies the move then checks if the moving player's king is attacked.
  • GameRegistry wraps a Ref[IO, Map[UUID, GameState]] for thread-safe multiplayer game storage.

Roadmap

Priority What Status
— Multiplayer backend (GameRegistry, game routes, PGN parser, Fen.write) Done
— Frontend player-vs-engine MVP (visual board, dark UI, engine replies) Paused
1 Multiplayer frontend + backend game status/clocks Next
2 Bitboard optimization Later

License

MIT

About

Full-featured chess library and multiplayer backend in Scala 3, Cats Effect, and Http4s with bitboards and alpha-beta pruning.

chess-engine.fly.dev/

Topics

demolearningportfolioshowcase

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.