Code Monkey home page Code Monkey logo

andoma's Introduction

Unit tests and puzzles

♟ Andoma

My blog post: Building My Own Chess Engine


A chess engine which implements:

  • Alpha-beta pruning for move searching
  • Move ordering based off heuristics like captures and promotions
  • Tomasz Michniewski's Simplified Evaluation Function for board evaluation and piece-square tables
  • A slice of the Universal Chess Interface (UCI) to allow challenges via lichess.org
  • A command-line user interface

It uses Python 3.8 with type hints as well as unit + integration tests. Mypy checks type hints as part of the GitHub Actions CI pipeline.


Install

pip install -r requirements.txt


Use it via command-line

Start the engine with:

python ui.py

Start as [w]hite or [b]lack:
w

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

Enter a move like g1h3:

Use it as a UCI engine

Start the engine with:

python main.py

An example interaction with the engine (responses have #):

uci
# id name Andoma
# id author Andrew Healey & Roma Parramore
# uciok
position startpos moves e2e4
go
# bestmove g8f6

Also accepts a FEN string:

position fen rnbqk1nr/p1ppppbp/1p4p1/8/2P5/2Q5/PP1PPPPP/RNB1KBNR b KQkq - 0 1


See the UCI interface doc for more information on communicating with the engine.

Debug information (the number of positions searched, the time taken) is sent to stderr. The engine's response is sent to stdout.


Lichess.org

The UCI protocol slice that's implemented by this engine means you can play it via lichess.org by using ShailChoksi/lichess-bot (a bridge between Lichess API and chess engines) and a BOT account.

The engine file required by lichess-bot may be generated using pyinstaller.


Tests

There are unit tests for the engine, UI, and evaluation modules. Mate-in-two/mate-in-three puzzles are being added.

python -m unittest discover test/

Type hints:

pip install -r requirements-dev.txt

mypy .

andoma's People

Contributors

chitty avatar healeycodes avatar jparramore 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.