diff --git a/packages/server/src/bot/brain.ts b/packages/server/src/bot/brain.ts new file mode 100644 index 0000000..7366684 --- /dev/null +++ b/packages/server/src/bot/brain.ts @@ -0,0 +1,46 @@ +import type { + Announcement, + BoardView, + Color, + PromotionType, + Square, +} from '@blind-chess/shared'; +import type { ModeratorText } from '@blind-chess/shared'; + +export interface CandidateMove { + from: Square; + to: Square; + promotion?: PromotionType; +} + +export interface AttemptHistoryEntry { + move: CandidateMove; + rejection: ModeratorText; +} + +export interface BrainInput { + view: BoardView; + newAnnouncements: Announcement[]; + legalCandidates: CandidateMove[]; + attemptHistory: AttemptHistoryEntry[]; + drawOfferFromOpponent: boolean; + ply: number; +} + +export type BrainAction = + | { type: 'commit'; from: Square; to: Square; promotion?: PromotionType } + | { type: 'resign' } + | { type: 'offer-draw' } + | { type: 'respond-draw'; accept: boolean }; + +export interface BrainInitArgs { + color: Color; + mode: 'blind' | 'vanilla'; + gameId: string; +} + +export interface Brain { + init(args: BrainInitArgs): Promise; + decide(input: BrainInput): Promise; + dispose?(): Promise; +} diff --git a/packages/server/src/bot/index.ts b/packages/server/src/bot/index.ts new file mode 100644 index 0000000..d86506f --- /dev/null +++ b/packages/server/src/bot/index.ts @@ -0,0 +1,4 @@ +export type { + Brain, BrainInput, BrainAction, BrainInitArgs, + CandidateMove, AttemptHistoryEntry, +} from './brain.js';