@nodots-llc/backgammon-ai
Version:
AI and integration for nodots-backgammon using the @nodots-llc/gnubg-hints native addon.
52 lines (51 loc) • 2.07 kB
JavaScript
import { gnubgHints, GnubgHintsIntegration } from './gnubg.js';
import { RandomMoveAnalyzer } from './moveAnalyzers.js';
// Lazy registration to avoid circular dependency during module initialization
// The registration happens when registerAIProvider() is called, not at import time
let registered = false;
export async function registerAIProvider() {
if (registered)
return;
// Dynamic imports to break circular dependency (ESM-compatible)
const { RobotAIRegistry } = await import('@nodots-llc/backgammon-core');
const { GNUAIProvider } = await import('./GNUAIProvider.js');
RobotAIRegistry.register(new GNUAIProvider());
registered = true;
}
export { gnubgHints, GnubgHintsIntegration };
export async function initializeGnubgHints(options) {
await gnubgHints.initialize(options);
}
export async function configureGnubgHints(config) {
await gnubgHints.configure(config);
}
export async function getMoveHints(request, maxHints) {
return gnubgHints.getMoveHints(request, maxHints);
}
export async function getBestMove(request, options) {
return gnubgHints.getBestMove(request, options?.maxHints);
}
export async function getDoubleHint(request) {
return gnubgHints.getDoubleHint(request);
}
export async function getTakeHint(request) {
return gnubgHints.getTakeHint(request);
}
export async function shutdownGnubgHints() {
await gnubgHints.shutdown();
}
export async function selectMoveFromList(moves, analyzer) {
const moveAnalyzer = analyzer ?? new RandomMoveAnalyzer();
return moveAnalyzer.selectMove(moves);
}
export * from './moveAnalyzers.js';
export * from './moveSelection.js';
export * from './pluginLoader.js';
export * from './hintContext.js';
// Training modules are not part of the current distribution
// export * from './training/features.js';
// export * from './training/dataset.js';
// export * from './training/policyModel.js';
// Export AI provider implementations
export { GNUAIProvider } from './GNUAIProvider.js';
export { executeRobotTurnWithGNU } from './robotExecution.js';