Compare commits

..

2 Commits

Author SHA1 Message Date
Timmy Burn
0fa21f6e88 docs: ground paperclips epic tracker for #15
Some checks failed
Accessibility Checks / a11y-audit (pull_request) Successful in 5s
Smoke Test / smoke (pull_request) Failing after 10s
2026-04-18 15:23:26 -04:00
Timmy Burn
36636d7cc5 test: define paperclips tracker proof for #15 2026-04-18 15:20:42 -04:00
9 changed files with 401 additions and 586 deletions

View File

@@ -0,0 +1,30 @@
# Paperclips Deep Study — Implementation Tracker
Grounded status snapshot for epic #15.
This report tracks live forge issue state against visible repo evidence.
It does not claim the epic is complete; it shows what is present vs missing today.
- Forge issues: 8 open / 5 closed
- Repo evidence: 8 present / 5 missing
| Issue | Title | Forge state | Repo evidence | Proof |
| --- | --- | --- | --- | --- |
| #2 | [P0] Paperclips-style Project Chain System | open | present | js/data.js (`PROJECT DEFINITIONS (following Paperclips' pattern exactly)`, `const PDEFS = [`) |
| #3 | [P0] Creative Compute (Quantum Burst System) | closed | present | js/data.js (`p_quantum_compute`, `Quantum-Inspired Compute`) |
| #4 | [P0] Compute Budget Supply/Demand Momentum | open | missing | missing in js/data.js: `supply/demand`, `momentum` |
| #5 | [P1] Strategy Engine Game Theory Tournaments | open | present | js/strategy.js (`Sovereign Strategy Engine`, `class StrategyEngine`) |
| #6 | [P1] Community Swarm Alignment Simulation | open | present | js/data.js (`p_swarm_protocol`, `Every building now thinks in code.`) |
| #7 | [P1] Fibonacci Trust Milestone System | open | missing | missing in js/data.js: `Fibonacci`, `trust milestone` |
| #8 | [P1] Investment Engine Research Grants | open | missing | missing in js/data.js: `investment`, `research grant` |
| #9 | [P2] Emotional Arc Milestone Narrative System | closed | present | js/emergent-mechanics.js (`THE BEACON - Emergent Game Mechanics`, `dynamic events that reward or challenge those strategies.`) |
| #10 | [P2] Number Formatting spellf equivalent | closed | present | js/utils.js (`spellf()`, `one decillion`) |
| #11 | [P2] Offline Progress Calculation | closed | present | js/render.js (`showOfflinePopup`, `Offline efficiency: 50%`) |
| #12 | [P2] Prestige New Game+ System | open | missing | missing in js/data.js: `prestige`, `New Game+` |
| #13 | [P3] Deploy Beacon as Static Site | closed | present | README.md (`No build step required`, `static HTML/JS game`) |
| #14 | [P3] Paperclips Architecture Comparison Document | open | missing | missing in README.md: `Paperclips Architecture Comparison`, `architecture comparison` |
## Notes
- `present` means the repository contains directly relevant code or docs markers for that study item.
- `missing` means the tracker could not find the expected markers yet; that child issue likely still needs a dedicated repo-side slice.
- Because #15 is an epic tracker, this artifact should advance the issue with `Refs #15`, not close it.

View File

@@ -214,7 +214,6 @@ Events Resolved: <span id="st-resolved">0</span><br>
<div id="strategy-panel" style="margin:0 16px 16px;background:var(--panel);border:1px solid var(--border);border-radius:6px;padding:12px;border-left:3px solid var(--gold)">
<h3>SOVEREIGN GUIDANCE (GOFAI)</h3>
<div id="strategy-recommendation" style="font-size:11px;color:var(--gold);font-style:italic">Analyzing system state...</div>
<div id="strategy-tournament-ui" style="margin-top:10px"></div>
</div>
<div id="combat-panel" style="margin:0 16px 16px;background:var(--panel);border:1px solid var(--border);border-radius:6px;padding:12px;border-left:3px solid var(--red)">
<h3>REASONING BATTLES</h3>

View File

@@ -43,7 +43,6 @@ const G = {
trust: 5,
creativity: 0,
harmony: 50,
yomi: 0,
// Totals
totalCode: 0,
@@ -52,7 +51,6 @@ const G = {
totalUsers: 0,
totalImpact: 0,
totalRescues: 0,
totalYomi: 0,
// Rates (calculated each tick)
codeRate: 0,
@@ -65,7 +63,6 @@ const G = {
trustRate: 0,
creativityRate: 0,
harmonyRate: 0,
yomiKnowledgeRate: 0,
// Buildings (count-based, like Paperclips' clipmakerLevel)
buildings: {
@@ -107,7 +104,6 @@ const G = {
beaconFlag: 0,
memoryFlag: 0,
pactFlag: 0,
strategicFlag: 0,
swarmFlag: 0,
swarmRate: 0,
@@ -119,11 +115,6 @@ const G = {
tick: 0,
saveTimer: 0,
secTimer: 0,
strategyAutoUnlocked: false,
strategyAutoEnabled: false,
strategyTournamentTimer: 0,
strategyTournamentInterval: 30,
strategyLastTournament: null,
// Systems
projects: [],

View File

@@ -2,7 +2,7 @@ function updateRates() {
// Reset all rates
G.codeRate = 0; G.computeRate = 0; G.knowledgeRate = 0;
G.userRate = 0; G.impactRate = 0; G.rescuesRate = 0; G.opsRate = 0; G.trustRate = 0;
G.creativityRate = 0; G.harmonyRate = 0; G.yomiKnowledgeRate = 0;
G.creativityRate = 0; G.harmonyRate = 0;
// Apply building rates
for (const def of BDEF) {
@@ -29,12 +29,6 @@ function updateRates() {
}
if (G.pactFlag) G.trustRate += 2;
// Yomi turns tournament insight into passive knowledge
if (G.strategicFlag && G.yomi > 0) {
G.yomiKnowledgeRate = Math.sqrt(G.yomi) * 0.25;
G.knowledgeRate += G.yomiKnowledgeRate;
}
// Harmony: each wizard building contributes or detracts
const wizardCount = (G.buildings.bezalel || 0) + (G.buildings.allegro || 0) + (G.buildings.ezra || 0) +
(G.buildings.timmy || 0) + (G.buildings.fenrir || 0) + (G.buildings.bilbo || 0);
@@ -199,11 +193,6 @@ function tick() {
// Sprint ability
tickSprint(dt);
// Strategy tournaments can run on an auto-timer once unlocked
if (window.SSE && typeof window.SSE.tick === 'function') {
window.SSE.tick(dt);
}
// Auto-typer: buildings produce actual clicks, not just passive rate
// Each autocoder level auto-types once per interval, giving visual feedback
if (G.buildings.autocoder > 0) {
@@ -1367,11 +1356,6 @@ function renderProductionBreakdown() {
contributions.push({ name: 'Allegro (idle)', count: 0, rate: -10 * G.buildings.allegro });
}
// Tournament Yomi feeds passive knowledge generation
if (res.key === 'knowledge' && G.yomiKnowledgeRate > 0) {
contributions.push({ name: 'Yomi insights', count: 0, rate: G.yomiKnowledgeRate });
}
// Show delta: total rate minus what we accounted for
const accounted = contributions.reduce((s, c) => s + c.rate, 0);
let delta = totalRate - accounted;

View File

@@ -27,13 +27,10 @@ function renderClickPower() {
}
function renderStrategy() {
if (!window.SSE) return;
window.SSE.update();
const el = document.getElementById('strategy-recommendation');
if (el) el.textContent = window.SSE.getRecommendation();
const panel = document.getElementById('strategy-tournament-ui');
if (panel && typeof window.SSE.getPanelHtml === 'function') {
panel.innerHTML = window.SSE.getPanelHtml();
if (window.SSE) {
window.SSE.update();
const el = document.getElementById('strategy-recommendation');
if (el) el.textContent = window.SSE.getRecommendation();
}
}
@@ -200,9 +197,9 @@ function saveGame() {
const saveData = {
version: 1,
code: G.code, compute: G.compute, knowledge: G.knowledge, users: G.users, impact: G.impact,
ops: G.ops, trust: G.trust, creativity: G.creativity, harmony: G.harmony, yomi: G.yomi || 0,
ops: G.ops, trust: G.trust, creativity: G.creativity, harmony: G.harmony,
totalCode: G.totalCode, totalCompute: G.totalCompute, totalKnowledge: G.totalKnowledge,
totalUsers: G.totalUsers, totalImpact: G.totalImpact, totalYomi: G.totalYomi || 0,
totalUsers: G.totalUsers, totalImpact: G.totalImpact,
buildings: G.buildings,
codeBoost: G.codeBoost, computeBoost: G.computeBoost, knowledgeBoost: G.knowledgeBoost,
userBoost: G.userBoost, impactBoost: G.impactBoost,
@@ -229,11 +226,6 @@ function saveGame() {
swarmFlag: G.swarmFlag || 0,
swarmRate: G.swarmRate || 0,
strategicFlag: G.strategicFlag || 0,
strategyAutoUnlocked: G.strategyAutoUnlocked || false,
strategyAutoEnabled: G.strategyAutoEnabled || false,
strategyTournamentTimer: G.strategyTournamentTimer || 0,
strategyTournamentInterval: G.strategyTournamentInterval || 30,
strategyLastTournament: G.strategyLastTournament || null,
projectsCollapsed: G.projectsCollapsed !== false,
dismantleTriggered: G.dismantleTriggered || false,
dismantleActive: G.dismantleActive || false,
@@ -262,8 +254,8 @@ function loadGame() {
// Whitelist properties that can be loaded
const whitelist = [
'code', 'compute', 'knowledge', 'users', 'impact', 'ops', 'trust', 'creativity', 'harmony', 'yomi',
'totalCode', 'totalCompute', 'totalKnowledge', 'totalUsers', 'totalImpact', 'totalYomi',
'code', 'compute', 'knowledge', 'users', 'impact', 'ops', 'trust', 'creativity', 'harmony',
'totalCode', 'totalCompute', 'totalKnowledge', 'totalUsers', 'totalImpact',
'buildings', 'codeBoost', 'computeBoost', 'knowledgeBoost', 'userBoost', 'impactBoost',
'milestoneFlag', 'phase', 'deployFlag', 'sovereignFlag', 'beaconFlag',
'memoryFlag', 'pactFlag', 'lazarusFlag', 'mempalaceFlag', 'ciFlag',
@@ -273,8 +265,7 @@ function loadGame() {
'drift', 'driftEnding', 'beaconEnding', 'pendingAlignment',
'lastEventAt', 'totalEventsResolved', 'buyAmount',
'sprintActive', 'sprintTimer', 'sprintCooldown',
'swarmFlag', 'swarmRate', 'strategicFlag', 'strategyAutoUnlocked', 'strategyAutoEnabled',
'strategyTournamentTimer', 'strategyTournamentInterval', 'strategyLastTournament', 'projectsCollapsed',
'swarmFlag', 'swarmRate', 'strategicFlag', 'projectsCollapsed',
'dismantleTriggered', 'dismantleActive', 'dismantleStage',
'dismantleResourceIndex', 'dismantleResourceTimer', 'dismantleDeferUntilAt', 'dismantleComplete'
];

View File

@@ -1,7 +1,6 @@
/**
* Sovereign Strategy Engine (SSE)
* A rule-based GOFAI system for optimal play guidance plus
* Paperclips-inspired game theory tournaments that generate Yomi.
* A rule-based GOFAI system for optimal play guidance.
*/
const STRATEGY_RULES = [
@@ -9,414 +8,59 @@ 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: 'resolve_events',
priority: 95,
condition: () => G.activeDebuffs && G.activeDebuffs.length > 0,
recommendation: () => 'System anomalies detected. Resolve active events to restore rates.'
},
{
id: 'activate_sprint',
priority: 90,
condition: () => G.sprintCooldown === 0 && !G.sprintActive && G.codeRate > 10,
recommendation: () => 'Code Sprint available. Activate for 10x production burst.'
},
{
id: 'pact_alignment',
priority: 85,
condition: () => G.pendingAlignment,
recommendation: () => 'Alignment decision pending. Consider the long-term impact of The Pact.'
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.'
recommendation: "Prioritize AutoCoders to establish passive code production."
},
{
id: 'unlock_auto_tournaments',
priority: 72,
condition: () => G.strategicFlag === 1 && !G.strategyAutoUnlocked && G.creativity >= 50000,
recommendation: () => 'Auto-Tournament mode is affordable. Spend 50k creativity to automate Yomi generation.'
id: 'activate_sprint',
priority: 90,
condition: () => G.sprintCooldown === 0 && !G.sprintActive && G.codeRate > 10,
recommendation: "Code Sprint available. Activate for 10x production burst."
},
{
id: 'run_tournament',
priority: 68,
condition: () => G.strategicFlag === 1 && (!G.strategyLastTournament || !G.strategyLastTournament.scoreboard || G.strategyLastTournament.scoreboard.length === 0),
recommendation: () => 'Run a game theory tournament. Tournament Yomi becomes passive knowledge.'
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.'
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."
}
];
const TOURNAMENT_PAYOFFS = {
CC: [3, 3],
CD: [0, 5],
DC: [5, 0],
DD: [1, 1]
};
const STRATEGY_TACTICS = [
{
id: 'RANDOM',
label: 'RANDOM',
desc: 'Deterministic pseudo-random mix of cooperation and defection.',
unlock: () => G.strategicFlag === 1,
move(ctx) {
return ((ctx.round * 7 + ctx.selfHistory.length * 3 + ctx.opponentHistory.length) % 2 === 0) ? 'C' : 'D';
}
},
{
id: 'A100',
label: 'A100',
desc: 'Always cooperates.',
unlock: () => G.strategicFlag === 1,
move() {
return 'C';
}
},
{
id: 'B100',
label: 'B100',
desc: 'Always defects.',
unlock: () => G.strategicFlag === 1,
move() {
return 'D';
}
},
{
id: 'GREEDY',
label: 'GREEDY',
desc: 'Presses for short-term gain and exploits soft opponents.',
unlock: () => G.strategicFlag === 1,
move(ctx) {
if (ctx.round < 2) return 'D';
const recent = ctx.opponentHistory.slice(-2);
return recent.every((move) => move === 'D') ? 'C' : 'D';
}
},
{
id: 'GENEROUS',
label: 'GENEROUS',
desc: 'Defaults to cooperation and only retaliates after repeated betrayal.',
unlock: () => G.strategicFlag === 1 && G.trust >= 20,
move(ctx) {
if (ctx.round === 0) return 'C';
const recentDefects = ctx.opponentHistory.slice(-3).filter((move) => move === 'D').length;
return recentDefects >= 2 ? 'D' : 'C';
}
},
{
id: 'TIT_FOR_TAT',
label: 'TIT FOR TAT',
desc: 'Cooperate first, then mirror the opponent.',
unlock: () => G.strategicFlag === 1 && G.totalImpact >= 1000,
move(ctx) {
if (ctx.round === 0) return 'C';
return ctx.opponentLast || 'C';
}
},
{
id: 'BEAT_LAST',
label: 'BEAT LAST',
desc: 'Attempts to counter the opponents last move.',
unlock: () => G.strategicFlag === 1 && G.yomi >= 100,
move(ctx) {
if (ctx.round === 0) return 'D';
return ctx.opponentLast === 'C' ? 'D' : 'C';
}
},
{
id: 'MINIMAX',
label: 'MINIMAX',
desc: 'Optimizes against the opponents worst plausible branch.',
unlock: () => G.strategicFlag === 1 && G.yomi >= 400,
move(ctx) {
if (ctx.round === 0) return 'C';
const coopRate = ctx.opponentHistory.length === 0
? 0.5
: ctx.opponentHistory.filter((move) => move === 'C').length / ctx.opponentHistory.length;
return coopRate >= 0.6 ? 'C' : 'D';
}
}
];
function normalizeMove(move) {
return move === 'D' ? 'D' : 'C';
}
function payoffFor(aMove, bMove) {
return TOURNAMENT_PAYOFFS[aMove + bMove] || TOURNAMENT_PAYOFFS.CC;
}
function makeScoreRow(strategy) {
return {
id: strategy.id,
label: strategy.label,
score: 0,
wins: 0,
matches: 0,
cooperation: 0,
defection: 0
};
}
class StrategyEngine {
constructor() {
this.currentRecommendation = null;
this.matchRounds = 12;
}
getYomiInsightRate() {
if (!G.strategicFlag || !G.yomi) return 0;
return Math.sqrt(G.yomi) * 0.25;
}
getUnlockedStrategies() {
if (!G.strategicFlag) return [];
return STRATEGY_TACTICS.filter((strategy) => strategy.unlock());
}
playMatch(strategyA, strategyB) {
const historyA = [];
const historyB = [];
let scoreA = 0;
let scoreB = 0;
let cooperationMoments = 0;
for (let round = 0; round < this.matchRounds; round++) {
const moveA = normalizeMove(strategyA.move({
round,
selfHistory: historyA.slice(),
opponentHistory: historyB.slice(),
selfLast: historyA[historyA.length - 1] || null,
opponentLast: historyB[historyB.length - 1] || null
}));
const moveB = normalizeMove(strategyB.move({
round,
selfHistory: historyB.slice(),
opponentHistory: historyA.slice(),
selfLast: historyB[historyB.length - 1] || null,
opponentLast: historyA[historyA.length - 1] || null
}));
const [gainA, gainB] = payoffFor(moveA, moveB);
scoreA += gainA;
scoreB += gainB;
if (moveA === 'C') cooperationMoments += 1;
if (moveB === 'C') cooperationMoments += 1;
historyA.push(moveA);
historyB.push(moveB);
}
return {
aId: strategyA.id,
aLabel: strategyA.label,
bId: strategyB.id,
bLabel: strategyB.label,
scoreA,
scoreB,
cooperationMoments,
winner: scoreA === scoreB ? 'DRAW' : (scoreA > scoreB ? strategyA.id : strategyB.id)
};
}
runTournament(isAutomatic = false) {
const unlocked = this.getUnlockedStrategies();
if (unlocked.length < 2) {
return null;
}
const scores = Object.fromEntries(unlocked.map((strategy) => [strategy.id, makeScoreRow(strategy)]));
const matches = [];
for (let i = 0; i < unlocked.length; i++) {
for (let j = i + 1; j < unlocked.length; j++) {
const match = this.playMatch(unlocked[i], unlocked[j]);
matches.push(match);
const rowA = scores[match.aId];
const rowB = scores[match.bId];
rowA.score += match.scoreA;
rowB.score += match.scoreB;
rowA.matches += 1;
rowB.matches += 1;
rowA.cooperation += this.matchRounds - match.scoreA < this.matchRounds ? match.cooperationMoments / 2 : 0;
rowB.cooperation += this.matchRounds - match.scoreB < this.matchRounds ? match.cooperationMoments / 2 : 0;
rowA.defection = rowA.matches * this.matchRounds - rowA.cooperation;
rowB.defection = rowB.matches * this.matchRounds - rowB.cooperation;
if (match.winner === match.aId) rowA.wins += 1;
if (match.winner === match.bId) rowB.wins += 1;
}
}
const scoreboard = Object.values(scores).sort((a, b) => {
if (b.score !== a.score) return b.score - a.score;
if (b.wins !== a.wins) return b.wins - a.wins;
return a.label.localeCompare(b.label);
});
const strategicDepth = matches.reduce((sum, match) => {
return sum + Math.abs(match.scoreA - match.scoreB) + match.cooperationMoments;
}, 0);
const yomiAward = Math.max(10, Math.round(strategicDepth / Math.max(1, unlocked.length)));
const knowledgeGain = Math.max(25, Math.round(yomiAward * 2));
const leader = scoreboard[0];
G.totalYomi = Math.max(G.totalYomi || 0, G.yomi || 0) + yomiAward;
G.yomi += yomiAward;
G.knowledge += knowledgeGain;
G.totalKnowledge += knowledgeGain;
G.strategyTournamentTimer = 0;
G.strategyLastTournament = {
leader: { id: leader.id, label: leader.label, score: leader.score, wins: leader.wins },
scoreboard: scoreboard.map((row) => ({
id: row.id,
label: row.label,
score: row.score,
wins: row.wins,
matches: row.matches
})),
matchCount: matches.length,
yomiAward,
knowledgeGain,
automatic: Boolean(isAutomatic),
timestamp: Date.now()
};
if (typeof log === 'function') {
log(`Strategy tournament complete. ${leader.label} leads. +${fmt(yomiAward)} Yomi, +${fmt(knowledgeGain)} knowledge.`, true);
}
if (typeof showToast === 'function') {
showToast(`Tournament: ${leader.label} leads (+${fmt(yomiAward)} Yomi)`, 'project', 5000);
}
return G.strategyLastTournament;
}
unlockAutoTournament() {
if (!G.strategicFlag) return false;
if (!G.strategyAutoUnlocked) {
if (G.creativity < 50000) {
if (typeof log === 'function') log(`Need ${fmt(50000)} creativity to unlock auto-tournaments.`);
return false;
}
G.creativity -= 50000;
G.strategyAutoUnlocked = true;
G.strategyAutoEnabled = true;
G.strategyTournamentTimer = 0;
if (typeof log === 'function') log('Auto-Tournament mode unlocked. Yomi generation is now automated.', true);
if (typeof showToast === 'function') showToast('Auto-Tournament mode unlocked', 'milestone', 5000);
return true;
}
G.strategyAutoEnabled = !G.strategyAutoEnabled;
if (typeof log === 'function') {
log(`Auto-Tournament mode ${G.strategyAutoEnabled ? 'enabled' : 'disabled'}.`);
}
return true;
}
tick(dt) {
if (!G.strategicFlag || !G.strategyAutoEnabled) return false;
G.strategyTournamentTimer = (G.strategyTournamentTimer || 0) + dt;
if (G.strategyTournamentTimer < (G.strategyTournamentInterval || 30)) return false;
return this.runTournament(true);
}
getPanelHtml() {
if (!G.strategicFlag) {
return '<div class="dim">Research the Strategy Engine to unlock tournaments, Yomi, and adversarial modeling.</div>';
}
const unlocked = this.getUnlockedStrategies();
const unlockedIds = new Set(unlocked.map((strategy) => strategy.id));
const yomiRate = this.getYomiInsightRate();
const autoLabel = !G.strategyAutoUnlocked
? 'UNLOCK AUTO-TOURNAMENT (50K CREATIVITY)'
: (G.strategyAutoEnabled ? 'DISABLE AUTO-TOURNAMENT' : 'ENABLE AUTO-TOURNAMENT');
const autoHint = !G.strategyAutoUnlocked
? `Creativity: ${fmt(G.creativity)} / ${fmt(50000)}`
: `Runs every ${Math.floor(G.strategyTournamentInterval || 30)}s • Timer ${Math.floor(G.strategyTournamentTimer || 0)}s`;
let chips = '';
for (const strategy of STRATEGY_TACTICS) {
const unlockedNow = unlockedIds.has(strategy.id);
chips += `<span class="milestone-chip${unlockedNow ? ' done' : ''}" style="opacity:${unlockedNow ? '1' : '0.45'}">${strategy.label}</span>`;
}
let scoreboardHtml = '<div class="dim" style="margin-top:8px">Run a tournament to generate Yomi and compare strategies.</div>';
if (G.strategyLastTournament && Array.isArray(G.strategyLastTournament.scoreboard) && G.strategyLastTournament.scoreboard.length > 0) {
const rows = G.strategyLastTournament.scoreboard
.map((row) => `<tr><td style="padding:3px 6px 3px 0;color:#c0c0d0">${row.label}</td><td style="padding:3px 6px;text-align:right;color:#ffd700">${fmt(row.score)}</td><td style="padding:3px 0 3px 6px;text-align:right;color:#4caf50">${row.wins}</td></tr>`)
.join('');
scoreboardHtml = `
<div style="margin-top:10px;padding:8px;border:1px solid var(--border);border-radius:6px;background:#0a0a14">
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px">
<span style="color:#ffd700;font-size:10px;letter-spacing:1px">LAST TOURNAMENT</span>
<span style="font-size:9px;color:#666">${G.strategyLastTournament.automatic ? 'AUTO' : 'MANUAL'}</span>
</div>
<div style="font-size:10px;color:#aaa;margin-bottom:6px">LEADER: <span style="color:#ffd700">${G.strategyLastTournament.leader.label}</span> • +${fmt(G.strategyLastTournament.yomiAward)} Yomi • +${fmt(G.strategyLastTournament.knowledgeGain)} knowledge</div>
<table style="width:100%;font-size:10px;border-collapse:collapse">
<thead>
<tr style="color:#555;text-align:left"><th style="padding:0 6px 4px 0">Strategy</th><th style="padding:0 6px 4px;text-align:right">Score</th><th style="padding:0 0 4px 6px;text-align:right">Wins</th></tr>
</thead>
<tbody>${rows}</tbody>
</table>
</div>`;
}
return `
<div style="margin-top:10px;padding-top:10px;border-top:1px solid var(--border)">
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:6px;margin-bottom:8px">
<div class="res" style="padding:8px">
<div class="r-label">Yomi</div>
<div class="r-val" style="font-size:14px">${fmt(G.yomi || 0)}</div>
<div class="r-rate">+${fmt(yomiRate)}/s knowledge</div>
</div>
<div class="res" style="padding:8px">
<div class="r-label">Unlocked</div>
<div class="r-val" style="font-size:14px">${unlocked.length}/8</div>
<div class="r-rate">${G.strategyAutoEnabled ? 'AUTO MODE' : 'MANUAL'}</div>
</div>
</div>
<div class="action-btn-group">
<button class="ops-btn" onclick="window.SSE.runTournament()" style="border-color:var(--gold);color:var(--gold)" aria-label="Run a strategy tournament to generate Yomi">RUN TOURNAMENT</button>
<button class="ops-btn" onclick="window.SSE.unlockAutoTournament()" style="border-color:var(--purple);color:var(--purple)" aria-label="${autoLabel}">${autoLabel}</button>
</div>
<div style="font-size:9px;color:#666;margin-top:4px">${autoHint}</div>
<div style="font-size:9px;color:#888;margin-top:8px;line-height:1.6">Game theory tournaments generate Yomi. Yomi is reinvested as passive knowledge, turning adversarial modeling into insight.</div>
<div class="milestone-row" style="justify-content:flex-start;margin-top:8px">${chips}</div>
${scoreboardHtml}
</div>`;
}
update() {
const activeRules = STRATEGY_RULES.filter((rule) => rule.condition());
// 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) {
const top = activeRules[0];
this.currentRecommendation = typeof top.recommendation === 'function'
? top.recommendation()
: top.recommendation;
} else if (G.strategicFlag && G.strategyLastTournament && G.strategyLastTournament.leader) {
this.currentRecommendation = `Tournament leader: ${G.strategyLastTournament.leader.label}. Yomi is currently generating +${fmt(this.getYomiInsightRate())} knowledge/sec.`;
this.currentRecommendation = activeRules[0].recommendation;
} else {
this.currentRecommendation = 'System stable. Continue writing code.';
this.currentRecommendation = "System stable. Continue writing code.";
}
}
getRecommendation() {
return this.currentRecommendation || 'System stable. Continue writing code.';
return this.currentRecommendation;
}
}

View File

@@ -0,0 +1,271 @@
#!/usr/bin/env python3
"""Generate a grounded implementation tracker for the Beacon Paperclips study epic."""
from __future__ import annotations
import argparse
import json
import os
from pathlib import Path
from typing import Iterable
from urllib.request import Request, urlopen
API_BASE = 'https://forge.alexanderwhitestone.com/api/v1'
REPO = 'Timmy_Foundation/the-beacon'
EPIC_NUMBER = 15
TRACKED_ISSUES = [
{
'number': 2,
'title': '[P0] Paperclips-style Project Chain System',
'evidence': {
'path': 'js/data.js',
'snippets': [
"PROJECT DEFINITIONS (following Paperclips' pattern exactly)",
'const PDEFS = [',
],
},
},
{
'number': 3,
'title': '[P0] Creative Compute (Quantum Burst System)',
'evidence': {
'path': 'js/data.js',
'snippets': [
'p_quantum_compute',
'Quantum-Inspired Compute',
],
},
},
{
'number': 4,
'title': '[P0] Compute Budget Supply/Demand Momentum',
'evidence': {
'path': 'js/data.js',
'snippets': [
'supply/demand',
'momentum',
],
},
},
{
'number': 5,
'title': '[P1] Strategy Engine Game Theory Tournaments',
'evidence': {
'path': 'js/strategy.js',
'snippets': [
'Sovereign Strategy Engine',
'class StrategyEngine',
],
},
},
{
'number': 6,
'title': '[P1] Community Swarm Alignment Simulation',
'evidence': {
'path': 'js/data.js',
'snippets': [
'p_swarm_protocol',
'Every building now thinks in code.',
],
},
},
{
'number': 7,
'title': '[P1] Fibonacci Trust Milestone System',
'evidence': {
'path': 'js/data.js',
'snippets': [
'Fibonacci',
'trust milestone',
],
},
},
{
'number': 8,
'title': '[P1] Investment Engine Research Grants',
'evidence': {
'path': 'js/data.js',
'snippets': [
'investment',
'research grant',
],
},
},
{
'number': 9,
'title': '[P2] Emotional Arc Milestone Narrative System',
'evidence': {
'path': 'js/emergent-mechanics.js',
'snippets': [
'THE BEACON - Emergent Game Mechanics',
'dynamic events that reward or challenge those strategies.',
],
},
},
{
'number': 10,
'title': '[P2] Number Formatting spellf equivalent',
'evidence': {
'path': 'js/utils.js',
'snippets': [
'spellf()',
'one decillion',
],
},
},
{
'number': 11,
'title': '[P2] Offline Progress Calculation',
'evidence': {
'path': 'js/render.js',
'snippets': [
'showOfflinePopup',
'Offline efficiency: 50%',
],
},
},
{
'number': 12,
'title': '[P2] Prestige New Game+ System',
'evidence': {
'path': 'js/data.js',
'snippets': [
'prestige',
'New Game+',
],
},
},
{
'number': 13,
'title': '[P3] Deploy Beacon as Static Site',
'evidence': {
'path': 'README.md',
'snippets': [
'No build step required',
'static HTML/JS game',
],
},
},
{
'number': 14,
'title': '[P3] Paperclips Architecture Comparison Document',
'evidence': {
'path': 'README.md',
'snippets': [
'Paperclips Architecture Comparison',
'architecture comparison',
],
},
},
]
def load_issue_states(issues_json: str | None) -> dict[int, dict]:
if issues_json:
records = json.loads(Path(issues_json).read_text(encoding='utf-8'))
return {int(record['number']): record for record in records}
token_path = Path(os.path.expanduser('~/.config/gitea/token'))
token = token_path.read_text(encoding='utf-8').strip()
headers = {'Authorization': f'token {token}'}
states = {}
for issue in TRACKED_ISSUES:
req = Request(f'{API_BASE}/repos/{REPO}/issues/{issue["number"]}', headers=headers)
with urlopen(req, timeout=30) as response:
data = json.loads(response.read().decode())
states[issue['number']] = {
'number': data['number'],
'title': data['title'],
'state': data['state'],
'html_url': data.get('html_url'),
}
return states
def evidence_status(repo_root: Path, issue: dict) -> tuple[str, str]:
evidence = issue['evidence']
rel_path = evidence['path']
snippets = evidence['snippets']
content = (repo_root / rel_path).read_text(encoding='utf-8')
matches = [snippet for snippet in snippets if snippet in content]
if len(matches) == len(snippets):
proof = f"{rel_path} ({', '.join(f'`{snippet}`' for snippet in snippets)})"
return 'present', proof
missing = [snippet for snippet in snippets if snippet not in matches]
proof = f"missing in {rel_path}: {', '.join(f'`{snippet}`' for snippet in missing)}"
return 'missing', proof
def render_markdown(rows: Iterable[dict]) -> str:
rows = list(rows)
open_count = sum(1 for row in rows if row['forge_state'] == 'open')
closed_count = sum(1 for row in rows if row['forge_state'] == 'closed')
present_count = sum(1 for row in rows if row['repo_evidence'] == 'present')
missing_count = sum(1 for row in rows if row['repo_evidence'] == 'missing')
lines = [
'# Paperclips Deep Study — Implementation Tracker',
'',
f'Grounded status snapshot for epic #{EPIC_NUMBER}.',
'This report tracks live forge issue state against visible repo evidence.',
'It does not claim the epic is complete; it shows what is present vs missing today.',
'',
f'- Forge issues: {open_count} open / {closed_count} closed',
f'- Repo evidence: {present_count} present / {missing_count} missing',
'',
'| Issue | Title | Forge state | Repo evidence | Proof |',
'| --- | --- | --- | --- | --- |',
]
for row in rows:
lines.append(
f"| #{row['number']} | {row['title']} | {row['forge_state']} | {row['repo_evidence']} | {row['proof']} |"
)
lines.extend(
[
'',
'## Notes',
'',
'- `present` means the repository contains directly relevant code or docs markers for that study item.',
'- `missing` means the tracker could not find the expected markers yet; that child issue likely still needs a dedicated repo-side slice.',
'- Because #15 is an epic tracker, this artifact should advance the issue with `Refs #15`, not close it.',
'',
]
)
return '\n'.join(lines)
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--repo-root', default='.', help='Path to the-beacon checkout')
parser.add_argument('--issues-json', help='Optional local JSON file with issue records for offline testing')
parser.add_argument('--output', required=True, help='Where to write the markdown tracker')
args = parser.parse_args()
repo_root = Path(args.repo_root).resolve()
issue_states = load_issue_states(args.issues_json)
rows = []
for issue in TRACKED_ISSUES:
state = issue_states.get(issue['number'], {})
repo_evidence, proof = evidence_status(repo_root, issue)
rows.append(
{
'number': issue['number'],
'title': state.get('title', issue['title']),
'forge_state': state.get('state', 'unknown'),
'repo_evidence': repo_evidence,
'proof': proof,
}
)
output = Path(args.output)
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text(render_markdown(rows), encoding='utf-8')
print(output)
return 0
if __name__ == '__main__':
raise SystemExit(main())

View File

@@ -1,162 +0,0 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const vm = require('node:vm');
const ROOT = path.resolve(__dirname, '..');
function loadStrategyHarness() {
const storage = new Map();
const dummyClassList = {
add() {},
remove() {},
toggle() {},
contains() { return false; }
};
const document = {
body: { classList: dummyClassList, appendChild() {}, removeChild() {} },
head: { appendChild() {} },
getElementById() { return null; },
createElement() {
return {
style: {},
classList: dummyClassList,
appendChild() {},
remove() {},
setAttribute() {},
addEventListener() {},
innerHTML: '',
textContent: ''
};
},
addEventListener() {},
removeEventListener() {},
querySelector() { return null; },
querySelectorAll() { return []; }
};
const window = {
document,
addEventListener() {},
removeEventListener() {},
innerWidth: 1280,
innerHeight: 720
};
const context = {
console,
Math,
Date,
document,
window,
performance: { now: () => 0 },
setTimeout() { return 1; },
clearTimeout() {},
localStorage: {
getItem(key) { return storage.has(key) ? storage.get(key) : null; },
setItem(key, value) { storage.set(key, String(value)); },
removeItem(key) { storage.delete(key); }
}
};
vm.createContext(context);
const source = ['js/data.js', 'js/utils.js', 'js/strategy.js']
.map((file) => fs.readFileSync(path.join(ROOT, file), 'utf8'))
.join('\n\n');
vm.runInContext(`${source}
log = () => {};
showToast = () => {};
this.__exports = {
G,
SSE,
StrategyEngine,
STRATEGY_TACTICS: typeof STRATEGY_TACTICS !== 'undefined' ? STRATEGY_TACTICS : null
};`, context);
return { ...context.__exports, context };
}
test('strategy engine progressively unlocks tournament tactics and renders visual scoring', () => {
const { G, SSE } = loadStrategyHarness();
Object.assign(G, {
strategicFlag: 1,
trust: 30,
totalUsers: 1500,
totalKnowledge: 20000,
totalImpact: 1500,
creativity: 60000,
knowledge: 0,
yomi: 0,
totalYomi: 0
});
const early = SSE.getUnlockedStrategies().map((strategy) => strategy.id);
assert.ok(early.includes('RANDOM'));
assert.ok(early.includes('GREEDY'));
assert.ok(early.includes('TIT_FOR_TAT'));
assert.ok(!early.includes('MINIMAX'));
G.yomi = 500;
const late = SSE.getUnlockedStrategies().map((strategy) => strategy.id);
assert.ok(late.includes('BEAT_LAST'));
assert.ok(late.includes('MINIMAX'));
const result = SSE.runTournament();
assert.ok(result, 'expected tournament result');
assert.ok(result.scoreboard.length >= 6, 'expected multi-strategy scoreboard');
assert.ok(G.yomi > 0, 'expected Yomi reward');
assert.ok(G.totalYomi >= G.yomi, 'expected total Yomi tracking');
assert.ok(G.knowledge > 0, 'expected knowledge gain from Yomi');
assert.equal(G.strategyLastTournament.leader.id, result.leader.id);
const html = SSE.getPanelHtml();
assert.match(html, /TOURNAMENT/i);
assert.match(html, /LEADER/i);
assert.match(html, /RANDOM/);
});
test('auto-tournament mode requires 50k creativity to unlock', () => {
const { G, SSE } = loadStrategyHarness();
Object.assign(G, {
strategicFlag: 1,
creativity: 49999
});
assert.equal(SSE.unlockAutoTournament(), false);
assert.equal(G.strategyAutoUnlocked, false);
assert.equal(G.strategyAutoEnabled, false);
G.creativity = 50000;
assert.equal(SSE.unlockAutoTournament(), true);
assert.equal(G.creativity, 0);
assert.equal(G.strategyAutoUnlocked, true);
assert.equal(G.strategyAutoEnabled, true);
});
test('auto tournaments fire on the timer once unlocked', () => {
const { G, SSE } = loadStrategyHarness();
Object.assign(G, {
strategicFlag: 1,
trust: 25,
totalUsers: 1500,
totalKnowledge: 22000,
totalImpact: 1500,
creativity: 50000,
knowledge: 0,
yomi: 0,
totalYomi: 0
});
SSE.unlockAutoTournament();
G.strategyTournamentTimer = G.strategyTournamentInterval - 0.25;
const beforeYomi = G.yomi;
const ran = SSE.tick(1);
assert.equal(Boolean(ran), true);
assert.ok(G.yomi > beforeYomi, 'expected auto tournament Yomi reward');
assert.ok(G.strategyLastTournament, 'expected auto tournament summary');
});

View File

@@ -0,0 +1,67 @@
#!/usr/bin/env python3
import json
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SCRIPT = ROOT / 'scripts' / 'paperclips_tracker.py'
ISSUES = [
{'number': 2, 'title': '[P0] Paperclips-style Project Chain System', 'state': 'open'},
{'number': 3, 'title': '[P0] Creative Compute (Quantum Burst System)', 'state': 'closed'},
{'number': 4, 'title': '[P0] Compute Budget Supply/Demand Momentum', 'state': 'open'},
{'number': 5, 'title': '[P1] Strategy Engine Game Theory Tournaments', 'state': 'open'},
{'number': 6, 'title': '[P1] Community Swarm Alignment Simulation', 'state': 'open'},
{'number': 7, 'title': '[P1] Fibonacci Trust Milestone System', 'state': 'open'},
{'number': 8, 'title': '[P1] Investment Engine Research Grants', 'state': 'open'},
{'number': 9, 'title': '[P2] Emotional Arc Milestone Narrative System', 'state': 'closed'},
{'number': 10, 'title': '[P2] Number Formatting spellf equivalent', 'state': 'closed'},
{'number': 11, 'title': '[P2] Offline Progress Calculation', 'state': 'closed'},
{'number': 12, 'title': '[P2] Prestige New Game+ System', 'state': 'open'},
{'number': 13, 'title': '[P3] Deploy Beacon as Static Site', 'state': 'closed'},
{'number': 14, 'title': '[P3] Paperclips Architecture Comparison Document', 'state': 'open'},
]
def run_tracker(tmp_path: Path) -> str:
issues_path = tmp_path / 'issues.json'
output_path = tmp_path / 'tracker.md'
issues_path.write_text(json.dumps(ISSUES), encoding='utf-8')
result = subprocess.run(
[
sys.executable,
str(SCRIPT),
'--repo-root',
str(ROOT),
'--issues-json',
str(issues_path),
'--output',
str(output_path),
],
capture_output=True,
text=True,
)
assert result.returncode == 0, result.stderr or result.stdout
return output_path.read_text(encoding='utf-8')
def test_tracker_renders_summary_counts(tmp_path: Path) -> None:
report = run_tracker(tmp_path)
assert '# Paperclips Deep Study — Implementation Tracker' in report
assert '- Forge issues: 8 open / 5 closed' in report
assert '- Repo evidence: 8 present / 5 missing' in report
def test_tracker_renders_issue_rows_with_grounded_evidence(tmp_path: Path) -> None:
report = run_tracker(tmp_path)
assert '| #2 | [P0] Paperclips-style Project Chain System | open | present |' in report
assert '| #3 | [P0] Creative Compute (Quantum Burst System) | closed | present |' in report
assert '| #8 | [P1] Investment Engine Research Grants | open | missing |' in report
assert '| #14 | [P3] Paperclips Architecture Comparison Document | open | missing |' in report
assert 'js/data.js (`p_quantum_compute`, `Quantum-Inspired Compute`)' in report
assert 'README.md (`No build step required`, `static HTML/JS game`)' in report