feat: add compute budget supply/demand system (#4)
Some checks failed
Accessibility Checks / a11y-audit (pull_request) Successful in 9s
Smoke Test / smoke (pull_request) Failing after 12s

This commit is contained in:
Alexander Whitestone
2026-04-13 22:16:32 -04:00
parent 1081b9e6c4
commit 4571fdca64
5 changed files with 222 additions and 3 deletions

View File

@@ -28,7 +28,10 @@ const CONFIG = {
CREATIVITY_RATE_USER_MULT: 0.001,
OPS_OVERFLOW_THRESHOLD: 0.8,
OPS_OVERFLOW_DRAIN_RATE: 2,
OPS_OVERFLOW_CODE_MULT: 10
OPS_OVERFLOW_CODE_MULT: 10,
COMPUTE_BUDGET_ENABLED: false,
COMPUTE_MOMENTUM_RATE: 0.0005,
COMPUTE_BATTERY_MAX: 1000
};
const G = {
@@ -158,7 +161,14 @@ const G = {
// Time tracking
playTime: 0,
startTime: 0,
flags: {}
flags: {},
// Compute Budget
computeSupply: 0,
computeDemand: 0,
computeBattery: 0,
computeMomentum: 0,
computePowMod: 1
};
// === PHASE DEFINITIONS ===
@@ -195,6 +205,7 @@ const BDEF = [
desc: 'A machine in your closet. Runs 24/7.',
baseCost: { code: 750 }, costMult: 1.15,
rates: { code: 20, compute: 1 },
computeSupply: 1,
unlock: () => G.totalCode >= 200, phase: 1,
edu: 'Sovereign compute starts at home. A $500 mini-PC runs a 7B model with 4-bit quantization.'
},
@@ -211,6 +222,7 @@ const BDEF = [
desc: 'Gradient descent. Billions of steps. Loss drops.',
baseCost: { compute: 1000 }, costMult: 1.15,
rates: { knowledge: 3 },
computeDemand: 2,
unlock: () => G.totalCompute >= 300, phase: 2,
edu: 'Training is math: minimize the gap between predicted and actual next token. Repeat enough, it learns.'
},
@@ -219,6 +231,7 @@ const BDEF = [
desc: 'Tests the model. Finds blind spots.',
baseCost: { knowledge: 3000 }, costMult: 1.15,
rates: { trust: 1, ops: 1 },
computeDemand: 5,
unlock: () => G.totalKnowledge >= 500, phase: 2,
edu: 'Benchmarks are the minimum. Real users find what benchmarks miss.'
},
@@ -251,6 +264,7 @@ const BDEF = [
desc: 'No cloud. No dependencies. Your iron.',
baseCost: { code: 100000 }, costMult: 1.15,
rates: { code: 500, compute: 100 },
computeSupply: 10,
unlock: () => G.totalCode >= 50000 && G.totalUsers >= 5000 && G.sovereignFlag === 1, phase: 4,
edu: '50 servers in a room beats 5000 GPUs you do not own. Always on. Always yours.'
},
@@ -275,6 +289,7 @@ const BDEF = [
desc: 'The AI writes better versions of itself.',
baseCost: { knowledge: 1000000 }, costMult: 1.20,
rates: { code: 1000, knowledge: 500 },
computeDemand: 20,
unlock: () => G.totalKnowledge >= 200000 && G.totalImpact >= 10000, phase: 5,
edu: 'Self-improvement is both the dream and the danger. Must improve toward good.'
},
@@ -526,6 +541,19 @@ const PDEFS = [
trigger: () => G.totalUsers >= 30,
effect: () => { G.trustRate += 2; log('Trust engine online. Good experiences compound.'); }
},
{
id: 'p_compute_budget',
name: 'Compute Budget System',
desc: 'Track compute supply vs demand. Over-supply builds momentum. Under-supply slows everything. "Every watt has a cost."',
cost: { knowledge: 2000, ops: 50 },
trigger: () => G.totalKnowledge >= 1500 && (G.buildings.trainer || 0) >= 1,
effect: () => {
CONFIG.COMPUTE_BUDGET_ENABLED = true;
log('Compute budget online. Supply vs demand now tracked.', true);
showToast('Compute Budget — watch supply/demand', 'milestone');
},
milestone: true
},
{
id: 'p_quantum_compute',
name: 'Quantum-Inspired Compute',
@@ -792,6 +820,7 @@ const EDU_FACTS = [
{ title: "How Code Becomes AI", text: "Every AI starts as lines of code - a model architecture, a training loop, a loss function. The code tells the computer how to learn. What emerges is something no single line could predict.", phase: 1 },
{ title: "The Compute Bottleneck", text: "Training a 7B model requires 1.4e20 FLOPs. A MacBook M3 does 15 TFLOPS. Training locally takes weeks. Hardware access determines who builds AI.", phase: 1 },
{ title: "What is a Token?", text: "One token equals about 3/4 of a word. A 128K context window means 96,000 words held in working memory at once - a novel, a codebase, a conversation thread.", phase: 2 },
{ title: "Compute Budget", text: "Every model needs compute: supply from your hardware, demand from your workloads. Over-supply builds momentum — your system runs faster. Under-supply starves everything. Managing compute is managing your AI's health.", phase: 2 },
{ title: "Data Quality", text: "Clean data beats more data, every time. The best models are trained on curated datasets, not scraped garbage. Garbage in, garbage out.", phase: 2 },
{ title: "Evaluation Matters", text: "Benchmarks are the minimum. Real users find what benchmarks miss. An eval harness is your model's mirror - it shows you what is actually there.", phase: 2 },
{ title: "The Trust Economy", text: "One good experience tells three people. One bad experience tells thirty. Trust in AI is measurable: does it cite sources? Does it say I don't know?", phase: 3 },