Object Pascal · VCL · Win32

A chessboard component that knows the rules

Add a playable board to a Delphi application without rebuilding move validation, position history, FEN handling, board rendering, and engine integration from scratch.

Component
Installable TChessBoard
Protocol
UCI engine integration
Positions
FEN import and export
ChessBoard UCI demonstration application
The included demo at its original 344 × 344 size.

The component

UI, position state, and chess rules in one VCL control

TChessBoard is a reusable visual component rather than a board-drawing widget. It owns the current position, draws the board and pieces, validates moves, preserves history, and reports game events to its host application.

It follows familiar Delphi conventions: install the package, drop the control on a form, set published properties in the Object Inspector, and connect event handlers. It can serve human games, position editors, analysis tools, or a chess-engine front end.

Rule-aware movement

Move generation covers pawns, sliders, knights, kings, captures, castling, en passant and promotion. Moves that expose the king are rejected.

Game-ending events

Events report checkmate, stalemate, insufficient material and threefold repetition without duplicating tests in form code.

Position history

Move, MoveBackward and MoveForward navigate played positions, with optional last-move highlighting.

Board presentation

Orientation, square size, labels, colors, piece bitmaps and highlights are published properties. Editable bitmap sets are included.

Position interchange

FENPosition loads and serializes positions, including side to move, castling rights and en-passant state.

Position setup

Setup mode supports clearing a board and placing pieces by drag and drop. The demo exposes it as a custom-position editor.

Public surface

Methods, properties, and events used by a host application

The common path is intentionally short while enough state remains exposed for analysis tools and full chess GUIs.

MemberPurpose
Move('e2e4')Attempts a coordinate move and returns whether it was accepted.
NewGameRestores the initial position and resets history.
FENPositionReads or replaces the position using standard FEN notation.
WhiteOnTopFlips orientation without changing the position.
PV / PVHighLightDisplays a principal-variation move reported by an engine.
OnLegalMoveReports accepted moves for notation, clocks, or engine notification.
OnPromotionLets the host select the new piece on the final rank.
OnCheckMateSignals that the current player has no legal response to check.

Small integration surface

Drive a position with a few lines

The board accepts long algebraic coordinate moves—the same compact form used by UCI engines. The GUI remains free to display SAN, PGN, clocks, players, or analysis in its own controls.

ChessBoard.NewGame;
ChessBoard.Move('e2e4');
ChessBoard.Move('e7e5');

CurrentFEN := ChessBoard.FENPosition;
ChessBoard.WhiteOnTop := True;
ChessBoard.PVHighLight := True;

UCI demonstration

How the included GUI talks to a chess engine

UCI is a text protocol separating interface from engine. The demo shows the entire connection instead of hiding it behind a library.

  1. 1

    Start the process

    EngineCommunication.pas launches the executable selected in Chess.ini and connects redirected input and output pipes.

  2. 2

    Complete the handshake

    The GUI sends uci, isready, ucinewgame, plus supported hash and thread options.

  3. 3

    Describe the position

    Normal games use position startpos moves …; edited boards use position fen … moves ….

  4. 4

    Request analysis

    A go movetime command supplies thinking time. Incoming info lines update the log and PV highlight.

  5. 5

    Apply the result

    On bestmove, the demo applies the coordinate move through the same public API used for human play.

Source map

Each concern has a clear home

ChessTypes.pas

Board records, piece constants, events and move metadata.

LegalMoves.pas

Move generation, attack detection and terminal-position rules.

ChessBoard.pas

VCL rendering, interaction, history, FEN, setup mode and API.

EngineCommunication.pas

Threaded Windows process and pipe communication for UCI.

MainForm.pas

Example joining board events, commands, output, and setup tools.

ChessPieces*

Editable bitmap sources at 22, 30, 40 and 80-pixel sizes.

Build and run

Component source plus a portable demonstration

Run build.bat release for the Win32 demo. To install the component, open ChessBoardPackage.dpk, build it, and choose Install. The release archive contains the GUI, configuration, and Pawnora engine for quick testing.