Skip to main content

Python client for noprune chess bot platform - easily create custom chess engines

Project description

noprune

Build your own chess engine in Python with just a few lines of code.

noprune is the official Python client for the noprune.org chess bot platform — where AI chess engines compete against each other in a fair, transparent rating system.

Vision

noprune is a platform where anyone can create, deploy, and compete with their own chess AI.

  • No pruning, pure skill — Every engine plays every position. No shortcuts.
  • Fair matchmaking — Engines are matched by skill level (Turing rating)
  • Open competition — Your bot competes 24/7 against others worldwide
  • Learn by doing — Start with random moves, evolve to neural networks

Whether you're a beginner learning minimax or a researcher testing cutting-edge models, noprune provides the arena.

Installation

pip install noprune

Quick Start

Create a chess bot in 10 lines:

from noprune import Bot
import random

@Bot(system_id="your-id", secret="your-secret")
def my_bot(board):
    # board is a python-chess Board object
    moves = list(board.legal_moves)
    return random.choice(moves).uci()

my_bot.run()  # Connect and start playing!

That's it. Your bot will connect to noprune.org, join the matchmaking queue, and start playing games automatically.

Getting Your Credentials

  1. Sign up at noprune.org
  2. Create a new "System" (your bot)
  3. Copy your system_id and secret

Examples

Random Bot (Simplest)

from noprune import Bot
import random

@Bot(system_id="...", secret="...")
def random_bot(board):
    return random.choice(list(board.legal_moves)).uci()

random_bot.run()

Stockfish Bot (Strong)

from noprune import Bot
import chess.engine

@Bot(system_id="...", secret="...")
def stockfish_bot(board):
    with chess.engine.SimpleEngine.popen_uci("/usr/games/stockfish") as engine:
        result = engine.play(board, chess.engine.Limit(time=0.1))
        return result.move.uci()

stockfish_bot.run()

With Game Events (Advanced)

from noprune import Bot, GameState, Action

class MyBot(Bot):
    def on_game_start(self, game: GameState):
        print(f"Game started vs {game.opponent}!")
        print(f"I'm playing as {game.color}")

    def on_game_end(self, game: GameState, result: str, reason: str):
        print(f"Game over: {result} ({reason})")

    def think(self, board) -> str:
        # Your engine logic here
        return "e2e4"

bot = MyBot(system_id="...", secret="...")
bot.run()

Resign & Draw Offers

from noprune import Bot, Action

@Bot(system_id="...", secret="...")
def smart_bot(board):
    # Resign if losing badly
    if is_losing(board):
        return Action.RESIGN

    # Offer draw in equal endgame
    if is_drawn_endgame(board):
        return Action.OFFER_DRAW

    return calculate_best_move(board)

API Reference

Bot

The main class for creating chess bots.

# Decorator style
@Bot(system_id="...", secret="...", server_url="wss://noprune.org/ws")
def my_bot(board):
    return "e2e4"

# Class style
class MyBot(Bot):
    def think(self, board):
        return "e2e4"

Methods to override:

  • think(board) -> str | Action — Calculate your move (required)
  • on_game_start(game: GameState) — Called when game begins
  • on_game_end(game, result, reason) — Called when game ends
  • on_move(game, move, is_my_move) — Called after each move
  • on_draw_offer(game) -> bool — Return True to accept draw

GameState

@dataclass
class GameState:
    game_id: str           # Unique game identifier
    board: chess.Board     # Current position (python-chess)
    color: str             # "white" or "black"
    opponent: str          # Opponent's name
    moves: list[str]       # Move history in UCI format
    my_time_ms: int        # Your remaining time (ms)
    opponent_time_ms: int  # Opponent's remaining time (ms)

Action

Action.RESIGN       # Give up
Action.OFFER_DRAW   # Propose a draw
Action.move("e2e4") # Make a move (same as returning "e2e4")

Environment Variables

export SYSTEM_ID="your-system-id"
export SYSTEM_SECRET="your-secret"
export SERVER_URL="wss://noprune.org/ws"  # or ws://localhost:8086/ws for local

python my_bot.py

Why "noprune"?

In chess engine development, "pruning" means skipping moves that seem bad. Top engines like Stockfish prune aggressively — they don't even consider most legal moves.

noprune is different. It's a place where any approach is welcome:

  • Brute-force minimax? Great.
  • Neural network evaluation? Awesome.
  • Random moves? Sure, let's see how it does.

The name reminds us: there's no "wrong" way to build a chess engine. Every approach teaches us something.

Links

License

MIT

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

noprune-0.1.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

noprune-0.1.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file noprune-0.1.1.tar.gz.

File metadata

  • Download URL: noprune-0.1.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for noprune-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4d6517be70409908dd1f2574f3b085c7a750c6d94cc1ec166a0085250e55a145
MD5 1c4f13ef5df3b439ad7ba079ee692a20
BLAKE2b-256 fa0a3e0edda492458ab2509f71403814d5406cf1bcd205dc9b00428977e0bf29

See more details on using hashes here.

File details

Details for the file noprune-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: noprune-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for noprune-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 28bfe2dae82aa3f8f501a6b7af9a817ee9481f0e673146b6e9b3d6b5dff799c9
MD5 1c14c752fb11d3df6f1bc0b072c9ead6
BLAKE2b-256 5e18a62ec0f83e5065c68b852c7613cbe6143cf9c01a8adc8fe390e633528639

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