'use client'; import type { JSX } from 'react'; import { defaultPieces } from 'react-chessboard'; import { BotAvatar } from './Avatars'; import { TIME_CONTROLS } from '../core/chess'; export type ColorChoice = 'w' | 'random' | 'b'; export interface EngineInfo { sims?: number; elo?: number; model?: string; } interface Props { engine: EngineInfo | null; offline: boolean; color: ColorChoice; onColor: (c: ColorChoice) => void; timeControl: string; onTimeControl: (id: string) => void; onPlay: () => void; onWatch: () => void; } const WhiteKing = defaultPieces.wK; const BlackKing = defaultPieces.bK; function RandomKing() { return ( ); } const COLORS: { id: ColorChoice; label: string; Icon: () => JSX.Element }[] = [ { id: 'w', label: 'White', Icon: WhiteKing }, { id: 'random', label: 'Random', Icon: RandomKing }, { id: 'b', label: 'Black', Icon: BlackKing }, ]; export default function SetupPanel({ engine, offline, color, onColor, timeControl, onTimeControl, onPlay, onWatch }: Props) { return (

ChessTransformer

{engine?.elo ? `Rated about ${engine.elo}` : offline ? 'Engine offline' : 'Connecting to the engine'}

A transformer that learned chess from human games only, then searches{' '} {engine?.sims ? `${engine.sims} positions` : 'ahead'} before each move.

I play as

{COLORS.map(({ id, label, Icon }) => ( ))}

Time control

{TIME_CONTROLS.map((tc) => ( ))}

The engine's clock runs while it searches, so faster time controls press it too.

{offline ? (

Can't reach the engine. Start the backend (see the README) and this page will connect on its own.

) : null}
); }