UNPKG

@nodots-llc/backgammon-ai

Version:

AI and integration for nodots-backgammon using gnubg as a backend engine.

39 lines (38 loc) 1.85 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.GnubgMoveAnalyzer = void 0; const gnubgApi_1 = require("../src/gnubgApi"); class GnubgMoveAnalyzer { selectMove(moves, context) { return __awaiter(this, void 0, void 0, function* () { if (!moves.length) return null; const position = context === null || context === void 0 ? void 0 : context.positionId; if (!position) { throw new Error('No positionId provided in context for GNUBG analysis'); } try { const gnubgOutput = yield (0, gnubgApi_1.getBestMoveFromGnubg)(position); // TODO: Parse gnubgOutput to select the actual best move from the moves array console.log('GNUBG output:', gnubgOutput); // Placeholder: return the first move return moves[0]; } catch (err) { console.error('Error calling GNUBG API:', err); return null; } }); } } exports.GnubgMoveAnalyzer = GnubgMoveAnalyzer; exports.default = GnubgMoveAnalyzer;