Server
Web interface for playing draughts games interactively.
- class draughts.Server(board: BaseBoard, white_engine: Engine | None = None, black_engine: Engine | None = 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)
Quick Start
from draughts import Board, Server, AlphaBetaEngine
board = Board()
server = Server(
board=board,
white_engine=AlphaBetaEngine(depth_limit=6),
black_engine=AlphaBetaEngine(depth_limit=4)
)
server.run() # Open http://localhost:8000
Command Line
Start directly from terminal:
python -m draughts.server.server
Engine Matches
Pit engines against each other:
from draughts import Board, Server, AlphaBetaEngine, 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=AlphaBetaEngine(depth_limit=6),
black_engine=RandomEngine()
)
server.run()
Click “Auto Play” in the UI to watch the match.
Web UI Controls
Engine Move: Play best move for current side
Auto Play: Start/stop automatic engine play
Undo: Take back the last move
Copy/Load FEN: Import/export positions
Copy/Load PDN: Import/export game notation
API Endpoints
Endpoint |
Method |
Description |
|---|---|---|
|
GET |
Current board position |
|
GET |
Legal moves for current player |
|
GET |
FEN string |
|
GET |
PDN string |
|
POST |
Make a move |
|
GET |
Play engine’s best move |
|
GET |
Undo last move |
|
POST |
Load position from FEN |
|
POST |
Load game from PDN |