The pack
incremental
function incremental(): Pack<{ incremental: typeof rules }, { largeNumbers: unknown }>
Install renderer-independent timed businesses and serial mine economies backed by enormous decimal values.
Helpers
createIncremental
function createIncremental(definition: IncrementalDefinition): IncrementalGame
Create an independent idle economy from public scenario data.
generateIncremental
function generateIncremental(options: IncrementalGenerationOptions): IncrementalDefinition
Generate varied economic decisions: costs, milestones, ownership gates and initial bottleneck change with seed.
solveIncremental
function solveIncremental(definition: IncrementalDefinition, budget = 4000): { status: 'solved' | 'budget-exhausted'; actions: IncrementalAction[]; elapsedSeconds: number }
Bounded constructive economic plan. A replay-validated witness, not an optimal-strategy or difficulty proof.
Classes
IncrementalGame
class IncrementalGame
Reusable pure idle economy. Actions validate atomically. The run is a kernel history over a base state: undo, redo and saves replay the retained commands, and consecutive advances are merged into one command.
constructor(definition: IncrementalDefinition)get definition(): IncrementalDefinition— Scenario copy; callers cannot alter the economy during a run.get state(): IncrementalState— Current visible state copy.locked(id: string): string— Ownership gate explanation, or empty text when open.cost(id: string, amount = 1): LargeNumber— Total geometric cost for a bounded bulk purchase; conservatively rounded upward.maxAffordable(id: string): number— Maximum affordable purchase, found by bounded binary search without Number conversion of money.payout(id: string): LargeNumber— Income per cycle after ownership, milestones, upgrades and retained prestige.rate(id: string): LargeNumber— Theoretical sustained throughput, irrespective of manual/automated running status.bottleneck(): string | null— Weakest transport/production stage; all stages are required to sustain a mine.prestigeGain(): LargeNumber— Additional prestige points available; total-run threshold avoids repeated reset farming.apply(action: IncrementalAction): { ok: boolean; reason: string }— Apply an action atomically; rejection never consumes money, time or history.undo(): boolean— Undo the last command (consecutive elapsed advances form one command).redo(): boolean— Redo an undone command.reset(): void— Fresh run, discarding local history and prestige.snapshot(): IncrementalSnapshot— Bounded serializable timeline.restore(s: IncrementalSnapshot): void— Validate the complete save and all redo commands by replaying them before replacing anything.hint(): { action: IncrementalAction; explanation: string }— Practical visible-information hint, including purchasing, automation and starting manual cycles.
Types
IncrementalAction
type IncrementalAction = { kind: 'buy'; id: string; amount?: number | 'max' } | { kind: 'start' | 'manager' | 'upgrade'; id: string } | { kind: 'advance'; seconds: number } | { kind: 'prestige' }
Commands recorded in snapshots; advance accepts explicit host-supplied seconds.
IncrementalDefinition
interface IncrementalDefinition
Public scenario definitions; amounts are decimal strings, never unsafe Number values.
id: string— Stable scenario identity.kind: 'business' | 'mine'— Independent payout cycles or a serial fluid production pipeline.seed: number— Visible seed used by the scenario generator.difficulty: 'easy' | 'medium' | 'hard'— Economic constraints preset.startingCash: string— Initial spendable currency.target: string— Run income needed to finish the short-session objective.prestigeBase: string— Base income threshold for earning prestige points.catchUpCap: number— Maximum supplied elapsed time per advance, in seconds.generators: IncrementalGenerator[]— Ordered businesses or production/transport stages.
IncrementalGenerationOptions
interface IncrementalGenerationOptions
Seeded economic generation controls.
seed: number— Unsigned 32-bit seed.kind?: 'business' | 'mine'— Business ladder or mine pipeline.difficulty?: 'easy' | 'medium' | 'hard'— Default medium; changes growth costs, prerequisites and objective.count?: number— Business count from two to six; mines always use three distinct stages.magnitude?: number— Scale all currency/throughput by ten to this power, from zero to one million.
IncrementalGenerator
interface IncrementalGenerator
A priced producer with milestones, a manager and a permanent-for-this-run upgrade.
id: string— Unique ID, stable through the run.name: string— Display name.initial: number— Initial unit count.cost: string— First unit cost. Later units cost cost times growth raised to owned units.growth: string— Geometric unit-cost multiplier, strictly greater than one.income: string— Income per owned unit per cycle, or throughput over cycleMs in a pipeline.cycleMs: number— Positive whole milliseconds per cycle; manual pipeline work lasts this long.managerCost: string— Manager purchase cost, automating this producer.unlock?: { id: string; units: number }— Optional ownership requirement for opening the producer.milestones: number[]— Ownership thresholds each multiply production by two.upgradeCost: string— Cost of the producer's one-time threefold production upgrade.
IncrementalSnapshot
interface IncrementalSnapshot
Versioned save with a bounded undo timeline; all boundaries validate through replay.
version: 1— Save format version.definition: IncrementalDefinition— Complete public immutable scenario.base: IncrementalState— State at the start of the retained history.commands: IncrementalAction[]— Coalesced accepted commands, including redo commands beyond cursor.cursor: number— Number of applied commands.
IncrementalState
interface IncrementalState
Copied, JSON-safe mutable state; no game amounts are ordinary numbers.
cash: string— Spendable currency.earned: string— Income earned since the latest prestige.lifetime: string— Income earned across all runs.prestige: string— Retained prestige points. Each gives a 25 percent production bonus.resets: number— Number of accepted prestige resets.elapsedMs: number— Supplied simulated milliseconds since the latest prestige.cappedSeconds: number— Cumulative time excluded by catch-up caps.won: boolean— Short-session target has been reached; free play remains available.producers: Record<string, { units: number; manager: boolean; upgraded: boolean; remainingMs: number; stock: string }>— Unit ownership, automation, progress and queued incoming material by producer ID.


