Skip to content

rictorlome/pupil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pupil

Live link

Overview

Pupil is a chess engine written in Go. The goal of writing this program was to create an engine capable of beating me in a 10 minute game.

Perft tests pass for the initial board state and for kiwipete up to depths 8 and 6 respectively.

Some of the major optimizations include: bitboard piece representation, magic bitboards for move generation, quiescence search, null move pruning, killer move heuristic, MVV-LVA move ordering, object pooling, and a transposition table keyed via zobrist hashes.

Although nowhere near as complete, the code is heavily inspired by the open-source Stockfish project, whose source code I dipped into heavily.

Running the code

GOOS=js GOARCH=wasm go build -o docs/pupil.wasm     # fresh build of wasm
go run .                                            # start local server

Then visit http://localhost:8080.


Description

Feature Implementation
Board representation Bitboard
Square mapping Little-endian Rank-file Mapping
Bitboard Serialization Forward-scanning
Move encoding 16 bit From-to based
Move Generation Magic Bitboard approach
Search Alpha-beta with quiescence search, null move pruning, transposition tables, killer moves, and MVV-LVA move ordering.
Evaluation Material, piece-square tables, pawn structure (doubled/isolated/passed pawns), bishop pair, rook on open files, king safety (pawn shield), and endgame-specific king tables.

History

This is my third attempt at a chess engine.

The predecessors:

  1. Rhess - a command line game written in Ruby using a mailbox 8x8 board representation. Styled with 100% unicode and playable via keyboard.

  2. Gogochess - a chess-move generator written in Go with a custom HashMap based move-list. Passing perft tests up to depth 5 and capable of solving Mate-in-Twos in less than a minute. Configured with HTTP API for browser integration and easy testing.


Todo

  • Test alpha-beta against negamax.
  • Update transposition table for non-perft search
  • Cache best move
  • Update alpha-beta to search best move first
  • Limit cache entry size
  • Implement LRU/better cache clearing (simple array)
  • Flesh out frontend for better UX
  • Experiment compiling to WebAssembly
  • Deploy with WebAssembly
  • Quiescence search
  • Killer moves
  • MVV-LVA move ordering
  • Move list pooling
  • Null move pruning
  • Improved evaluation (pawn structure, king safety, endgame)
  • Lint

Nice to haves:

  • Iterative deepening with time limit
  • Concurrent alpha-beta

About

♟️Chess engine and AI ♟️

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors