Giter Club home page Giter Club logo

sunfish's Introduction

Sunfish

Sunfish is a simple, but strong chess engine, written in Python, mostly for teaching purposes. Without tables and its simple interface, it takes up just 111 lines of code!

Because Sunfish is small and strives to be simple, the code provides a great platform for experimenting. People have used it for testing parallel search algorithms, experimenting with evaluation functions, and developing deep learning chess programs. Fork it today and see what you can do!

Screenshot

My move: g8f6

  8 ♖ ♘ ♗ ♕ ♔ ♗ · ♖
  7 ♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙
  6 · · · · · ♘ · ·
  5 · · · · · · · ·
  4 · · · · ♟ · · ·
  3 · · · · · · · ·
  2 ♟ ♟ ♟ ♟ · ♟ ♟ ♟
  1 ♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
    a b c d e f g h


Your move:

Run it!

Sunfish is self contained in the sunfish.py file from the repository. I recommend running it with pypy or pypy3 for optimal performance.

It is also possible to run Sunfish with a graphical interface, such as PyChess, Arena or your chess interface of choice. Sunfish' can communicate through the XBoard/CECP protocol by the command pypy -u xboard.py. Ruxy Sylwyka has a note on making it all work on Windows.

Play now on Lichess! against Recursing's Rust port

Features

  1. Built around the simple, but deadly efficient MTD-bi search algorithm.
  2. Filled with classic as well as modern 'chess engine tricks' for simpler and faster code.
  3. Easily adaptive evaluation function through Piece Square Tables.
  4. Uses standard Python collections and data structures for clarity and efficiency.

Limitations

Sunfish supports castling, en passant, and promotion. It doesn't however do minor promotion or draws by repetition. All input must be done in simple 'two coordinate' notation, as shown in the screenshot.

There are many ways in which you may try to make Sunfish stronger. First you could change to board representation to a mutable array and add a fast way to enumerate pieces. Then you could implement dedicated capture generation, check detection and check evasions. You could also move everything to bitboards, implement parts of the code in C or experiment with parallel search!

The other way to make Sunfish stronger is to give it more knowledge of chess. The current evaluation function only uses piece square tables - it doesn't even distinguish between midgame and endgame. You can also experiment with more pruning - currently only null move is done - and extensions - currently none are used. Finally Sunfish might benefit from a more advanced move ordering, MVV/LVA and SEE perhaps?

Why Sunfish?

The name Sunfish actually refers to the Pygmy Sunfish, which is among the very few fish to start with the letters 'Py'. The use of a fish is in the spirit of great engines such as Stockfish, Zappa and Rybka.

In terms of Heritage, Sunfish borrows much more from Micro-Max by Geert Muller and PyChess.

Sunfish logo

sunfish's People

Contributors

adilosa avatar bakerwho avatar boarpig avatar illagrenan avatar jthemphill avatar michaelmior avatar recursing avatar ryanhs avatar thomasahle avatar ugoertz avatar verhovsky avatar wpapper avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.