Server

Web interface for playing draughts games interactively. The desktop and mobile images below were captured from the running FastAPI server.

Analysis view with a 10×10 board, move history, and engine controls

Desktop analysis view.

The board and move panel stacked on a mobile screen

Mobile layout. The move panel sits below the board.

class draughts.Server(board, white_engine=None, black_engine=None)[source]

Draughts game server with web UI.

Supports: - Human play via web interface - Single engine for computer moves - Two engines playing against each other (engine vs engine mode)

Parameters:
  • board (BaseBoard)

  • white_engine (Engine | None)

  • black_engine (Engine | None)

__init__(board, white_engine=None, black_engine=None)[source]

Initialize the server.

Parameters:
  • board (BaseBoard) – The initial board state

  • white_engine (Engine | None) – Engine to play as white (optional)

  • black_engine (Engine | None) – Engine to play as black (optional)

run(**kwargs)[source]

Start the server.

Quick Start

from draughts import Board, Server, SimpleEngine

board = Board()
server = Server(
    board=board,
    white_engine=SimpleEngine(depth_limit=6),
    black_engine=SimpleEngine(depth_limit=4)
)
server.run()  # Open http://localhost:8000

Command Line

Run just the UI with one command (no project setup needed), then open http://localhost:8000:

uvx --from py-draughts draughts-server

Or after pip install py-draughts:

draughts-server              # same as: python -m draughts.server

Options: --port 8080, --host 0.0.0.0 (expose on the network), --depth 8 (SimpleEngine search depth).

Engine Matches

Pit engines against each other:

from draughts import Board, Server, SimpleEngine, Engine
import random

class RandomEngine(Engine):
    def get_best_move(self, board, with_evaluation=False):
        move = random.choice(list(board.legal_moves))
        return (move, 0.0) if with_evaluation else move

server = Server(
    board=Board(),
    white_engine=SimpleEngine(depth_limit=6),
    black_engine=RandomEngine()
)
server.run()

Click “Auto Play” in the UI to watch the match.

Web UI Controls

  • Play / Analysis / Engines: Switch between the board controls and automatic engine play. These views share the same game.

  • New game: Reset the board and choose any of the eight supported variants.

  • Board: Select a piece to see legal destinations, then select a destination to move. Use the controls below the board to flip it or show square numbers.

  • Moves / Position: Navigate recorded moves backward and forward, or inspect the current FEN, legal-move count, and material. Playing from an earlier position replaces the later moves.

  • Engine move: Ask the engine configured for the current side to play one move. Set its depth in Engine settings (1–10). Engine choice is configured when creating the Python Server, not in the browser.

  • Auto play: Start or stop continuous play in the Engines view when both sides have engines configured. Stopping waits for an in-progress move to finish.

  • Actions: Import FEN or PDN, export FEN/PDN or an SVG board, copy a Python API example for the current position, and toggle dark mode.

The Server holds one shared board. Opening it in multiple browser tabs does not create separate games.

API Endpoints

Endpoint

Method

Description

/position

GET

Current board position

/legal_moves

GET

Legal moves for current player

/fen

GET

FEN string

/pdn

GET

PDN string

/engine_info

GET

Configured engines and depth

/move/{src}/{tgt}

POST

Make a move

/best_move

GET

Play engine’s best move

/pop

GET

Undo last move

/goto/{ply}

GET

Navigate recorded half-moves

/load_fen

POST

Load position from FEN

/load_pdn

POST

Load game from PDN

/set_depth/{depth}

GET

Set engine search depth (1–10)

/set_board/{variant}

GET

Reset to a supported variant