UNPKG

goban-engine

Version:

This contains the built Go engine that is used by the Goban package. There are no display components in this package, only the logic for playing the game of Go, making it suitable for usage in node.js or other server-side environments.

66 lines (65 loc) 2.7 kB
import { EventEmitter } from "eventemitter3"; import { IGobanSocket } from "../GobanSocket"; import { JGOFAIReview, JGOFAIReviewMove } from "../formats/JGOF"; import * as protocol from "../protocol"; import { MoveTree } from "../MoveTree"; import { GobanMoveErrorMessageId } from "../GobanError"; import { GobanEngine } from "../GobanEngine"; import { AiReviewCategorization, ScoreDiffThresholds } from "./categorize"; export interface AIReviewUpdateContext { /** Type of update: "move" for trunk moves, "variation" for analyzed variations */ type: "move" | "variation"; /** For move updates, the move number that was updated */ move_number?: number; /** For variation updates, the variation key (e.g., "5-aa.bb.cc") */ variation_key?: string; } export interface AIReviewDataEvents { connected: () => void; destroy: () => void; metadata: (ai_review: JGOFAIReview) => void; /** Emitted when review data is updated. Context describes what was updated. */ update: (context: AIReviewUpdateContext) => void; } /** * AI Review data management class. * * Takes care of socket communication and updating AI review data as it streams in. * */ export declare class AIReviewData extends EventEmitter<AIReviewDataEvents> implements JGOFAIReview { readonly socket: IGobanSocket<protocol.ClientToAIServer, protocol.AIServerToClient>; readonly uuid: string; private ai_review; readonly move_tree: MoveTree; private analysis_requests_made; constructor(socket: IGobanSocket<protocol.ClientToAIServer, protocol.AIServerToClient>, move_tree: MoveTree, ai_review: JGOFAIReview, game_id: number | string); destroy(): void; get id(): string; get type(): "fast" | "full"; get network(): string; get network_size(): string; get engine(): string; get engine_version(): string; get strength(): number; get date(): number; get win_rate(): number; get win_rates(): Array<number>; get scores(): Array<number> | undefined; get moves(): { [key: string]: JGOFAIReviewMove; }; get analyzed_variations(): { [key: string]: JGOFAIReviewMove; } | undefined; get error(): undefined | { message_id: GobanMoveErrorMessageId; move_number: number; coords: string; }; private updateAIReviewMetadata; private debounce_update?; private debounce_queue?; private processUpdate; analyze_variation(uuid: string, game_id: number, ai_review_id: number, cur_move: MoveTree, trunk_move: MoveTree): void; categorize(engine: GobanEngine, thresholds?: ScoreDiffThresholds, include_negative_score_loss?: boolean): AiReviewCategorization | null; }