/** * Sovereign Strategy Engine (SSE) * A rule-based GOFAI system for optimal play guidance. */ const STRATEGY_RULES = [ { id: 'use_ops', priority: 100, condition: () => G.ops >= G.maxOps * 0.9, recommendation: "Operations near capacity. Convert Ops to Code or Knowledge now." }, { id: 'buy_autocoder', priority: 80, condition: () => G.phase === 1 && (G.buildings.autocoder || 0) < 10 && canAffordBuilding('autocoder'), recommendation: "Prioritize AutoCoders to establish passive code production." }, { id: 'activate_sprint', priority: 90, condition: () => G.sprintCooldown === 0 && !G.sprintActive && G.codeRate > 10, recommendation: "Code Sprint available. Activate for 10x production burst." }, { id: 'resolve_events', priority: 95, condition: () => G.activeDebuffs && G.activeDebuffs.length > 0, recommendation: "System anomalies detected. Resolve active events to restore rates." }, { id: 'save_game', priority: 10, condition: () => (Date.now() - (G.lastSaveTime || 0)) > 300000, recommendation: "Unsaved progress detected. Manual save recommended." }, { id: 'pact_alignment', priority: 85, condition: () => G.pendingAlignment, recommendation: "Alignment decision pending. Consider the long-term impact of The Pact." } ]; class StrategyEngine { constructor() { this.currentRecommendation = null; } update() { // Find the highest priority rule that meets its condition const activeRules = STRATEGY_RULES.filter(r => r.condition()); activeRules.sort((a, b) => b.priority - a.priority); if (activeRules.length > 0) { this.currentRecommendation = activeRules[0].recommendation; } else { this.currentRecommendation = "System stable. Continue writing code."; } } getRecommendation() { return this.currentRecommendation; } } const SSE = new StrategyEngine(); window.SSE = SSE; // Expose to global scope