UNPKG

@nodots-llc/backgammon-ai

Version:

AI and integration for nodots-backgammon using the @nodots-llc/gnubg-hints native addon.

22 lines (21 loc) 854 B
import fs from 'fs'; import path from 'path'; export function loadAnalyzersFromPluginsDir(pluginsDir) { const analyzers = {}; const files = fs.readdirSync(pluginsDir); for (const file of files) { if (file.endsWith('.js') || file.endsWith('.ts')) { const pluginPath = path.join(pluginsDir, file); // eslint-disable-next-line @typescript-eslint/no-var-requires const PluginClass = require(pluginPath).default; if (PluginClass) { const name = path.basename(file, path.extname(file)); analyzers[name] = new PluginClass(); } } } return analyzers; } // Usage example: // const analyzers = loadAnalyzersFromPluginsDir(path.join(__dirname, '../plugins')) // const move = await analyzers['myCustomAnalyzer'].selectMove(moves, context)