Fix compute utilization bug and add subscriber saturation cap
CI / build-and-push (push) Successful in 34s
CI / build-and-push (push) Successful in 34s
Three intertwined fixes: 1. Zero-capacity utilization: when inference allocation was 0%, the guard clause returned 0% utilization instead of 100%, so the market system never penalized satisfaction and subscribers never churned. 2. Stale compute in market: restructured tick order so capacity is computed before market runs, giving satisfaction calculations current-tick demand/capacity ratio instead of previous tick's. 3. Subscriber growth: replaced pure compound growth (reached billions in minutes) with logistic saturation curve. Era-based market caps: startup 10K, scaleup 1M, bigtech 20M, agi 100M. Quality and reputation expand the effective cap. Also tuned FLOPS-to-tokens multiplier (10 → 26) for balanced demand/capacity feel across all eras, and added market saturation indicator to the Market page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,24 +1,36 @@
|
||||
import type { GameState, ComputeState, InfrastructureState } from '@ai-tycoon/shared';
|
||||
import { FLOPS_TO_TOKENS_MULTIPLIER } from '@ai-tycoon/shared';
|
||||
|
||||
export function processCompute(state: GameState, infrastructure: InfrastructureState): ComputeState {
|
||||
export interface CapacityResult {
|
||||
totalFlops: number;
|
||||
trainingAllocation: number;
|
||||
inferenceAllocation: number;
|
||||
tokensPerSecondCapacity: number;
|
||||
}
|
||||
|
||||
export function computeCapacity(state: GameState, infrastructure: InfrastructureState): CapacityResult {
|
||||
const totalFlops = infrastructure.totalFlops;
|
||||
const trainingAllocation = state.compute.trainingAllocation;
|
||||
const inferenceAllocation = 1 - trainingAllocation;
|
||||
|
||||
const inferenceFlops = totalFlops * inferenceAllocation;
|
||||
const tokensPerSecondCapacity = inferenceFlops * 10;
|
||||
const tokensPerSecondCapacity = inferenceFlops * FLOPS_TO_TOKENS_MULTIPLIER;
|
||||
|
||||
const tokensPerSecondDemand = state.compute.tokensPerSecondDemand;
|
||||
const inferenceUtilization = tokensPerSecondCapacity > 0
|
||||
? Math.min(1, tokensPerSecondDemand / tokensPerSecondCapacity)
|
||||
: 0;
|
||||
return { totalFlops, trainingAllocation, inferenceAllocation, tokensPerSecondCapacity };
|
||||
}
|
||||
|
||||
export function finalizeCompute(capacity: CapacityResult, totalTokenDemand: number): ComputeState {
|
||||
const inferenceUtilization = capacity.tokensPerSecondCapacity > 0
|
||||
? Math.min(1, totalTokenDemand / capacity.tokensPerSecondCapacity)
|
||||
: (totalTokenDemand > 0 ? 1 : 0);
|
||||
|
||||
return {
|
||||
totalFlops,
|
||||
trainingAllocation,
|
||||
inferenceAllocation,
|
||||
...capacity,
|
||||
tokensPerSecondDemand: totalTokenDemand,
|
||||
inferenceUtilization,
|
||||
tokensPerSecondCapacity,
|
||||
tokensPerSecondDemand,
|
||||
};
|
||||
}
|
||||
|
||||
export function processCompute(state: GameState, infrastructure: InfrastructureState): ComputeState {
|
||||
const cap = computeCapacity(state, infrastructure);
|
||||
return finalizeCompute(cap, state.compute.tokensPerSecondDemand);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user