feat(bot): scaffold Brain interface and types
This commit is contained in:
@@ -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<void>;
|
||||||
|
decide(input: BrainInput): Promise<BrainAction>;
|
||||||
|
dispose?(): Promise<void>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export type {
|
||||||
|
Brain, BrainInput, BrainAction, BrainInitArgs,
|
||||||
|
CandidateMove, AttemptHistoryEntry,
|
||||||
|
} from './brain.js';
|
||||||
Reference in New Issue
Block a user