Skip to main content

A really bad chess engine that served as a learning project

Project description

SailMate

🌊 A simple chess engine built from scratch in Python

📦 PyPI: sailMate

Overview

SailMate is a simple chess engine built completely from scratch using Python and object-oriented programming (OOP).
It supports standard piece movement, simple FEN strings, basic evaluation, and a minimax algorithm with alpha-beta pruning.
You can even play against the engine from the command line.

That said, it does not support underpromotion, draws by repetition, or the 50-move rule. Also, since it's written in Python and not highly optimized, it runs quite slowly. I built it mainly as a learning exercise, for fun, and to submit to Shipwrecked.


How to Use

Fast Install

First, install SailMate:

pip install sailMate

Then write the following code and run:

import sailMate

sailMate.play()

And BOOM, you'll be able to play against the SailMate engine


🧠 OOP Design

Core Components:

  • Piece (abstract base class)

    • Pawn
    • Knight
    • Bishop
    • Rook
    • Queen
    • King (All inherit from Piece)
  • Board — Handles game state and possible move generation

  • FEN — Parses a simple FEN string into board state

    ⚠️ This does not support full FEN strings. Please remove the trailing data after the piece layout. Example:

    rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
    

    becomes:

    rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
    
    import sailMate
    
    myBoard = sailMate.FEN("r1bqkbnr/pppp1ppp/2n5/4p3/3PP3/5N2/PPP2PPP/RNBQKB1R", False)
    # First parameter: simplified FEN string
    # Second parameter: who plays (True → White, False → Black)
    
  • evaluate() — Simple material-based evaluation

    print(sailMate.evaluate(myBoard, 0)) 
    # First parameter: board object
    # Second parameter: depth
    
  • minimax(), minimaxImproved() — Minimax with alpha-beta pruning

    print(sailMate.minimaxImproved(myBoard, 2)) 
    # First parameter: board object
    # Second parameter: depth
    
  • play() — Command-line gameplay loop


📁 Check out sailMate/sailMate.py for more functions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sailmate-0.0.6.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sailmate-0.0.6-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file sailmate-0.0.6.tar.gz.

File metadata

  • Download URL: sailmate-0.0.6.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for sailmate-0.0.6.tar.gz
Algorithm Hash digest
SHA256 ac01ef66525ced3ca14c021b11f646c4cff25f0e43ac9629b8ca686ae03cbd6d
MD5 8aa842c535a189eb9d4cb74935003a1f
BLAKE2b-256 167644120debf485c6aae9a4fe8a4ace37bbf7432eb2f7b293d13e6645dd26f5

See more details on using hashes here.

File details

Details for the file sailmate-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: sailmate-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for sailmate-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e81443a80e4c619c539c9d11563442acb41e2a3a0f129e4c206b9ee55c568539
MD5 c1f93c239d3ec61ec2c9e330a53179fb
BLAKE2b-256 3fce9064ca7a664c7d3d1e8b31bf8e907e6e757422e911deb8d7ee0df265fa37

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page