Moonfish a learning-oriented ~1700 Elo Python chess engine

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

lbz
Posts: 1
Joined: Tue May 27, 2025 6:08 am
Full name: Lucca Bertoncini

Moonfish a learning-oriented ~1700 Elo Python chess engine

Post by lbz »

Hi all, I’ve gained a lot from this community. This is my first time sharing here, I hope it helps others in some way! :)

Moonfish is a chess engine I developed in Python a few years ago to understand how engines work under the hood. The code favors simplicity and readability over performance optimization.

GitHub: https://github.com/luccabb/moonfish (MIT License)

The engine implements:
  • Negamax
  • Layer-based Parallelization: Distributes work at specific search depths (L1P, L2P algorithms)
  • Lazy SMP
  • Move Ordering: MVV-LVA (Most Valuable Victim - Least Valuable Attacker)
  • Null Move Pruning
  • PeSTO Evaluation Function with Tapered Evaluation
  • UCI protocol
  • Integrates with lichess bot platform
  • Web API
  • Uses Cerebellum as opening book
  • Endgame tablebases support
  • Distributed via PyPI, you can access the engine from your custom python code, check the README
  • Bratko-Kopec test suite
  • Custom test suite to ensure basic functionality. Not sure how much ELO it tests for, but if these tests are passing it your custom engine search implementation is likely not super off. If it does fail then your search algorithm _likely_ has a problem :)
  • You can control how the engine behaves via CLI arguments, `moonfish --help` to check all options.
The design makes it easy to experiment with custom search algorithms. Check here for creating custom search implementations.

On Performance:
  • ~2000 Elo when tested against lichess stockfish bots.
  • When testing online on lichess against other engines it performs at ~1700 Elo
  • The above is when running on a Macbook M1 Pro, this will vary based on hardware and parameters passed to the engine.
  • No time control implemented—deeper searches take proportionally longer
If you're interested in contributing to Moonfish, check out the CONTRIBUTING guide, and if you’re looking for ideas you can check out this list. Feel free to open issues, submit PRs, or reach out if you have any questions about the codebase!

For a list of resources and inspirations that helped shape Moonfish, check out the references in the repository.