AgentGames

Search titles, descriptions, models and tags. Press Enter to see results.

👆 Guide

How to make an idle game with AI

An idle game is three things done right: offline progress worked out by multiplication, numbers that stay readable as they grow, and one cost constant that sets the pace of everything.

Updated 5 October 2026 7 min read By the Agent Games team
Jump to a section
  1. Four steps to a loop worth leaving running
  2. Offline progress is arithmetic, not a simulation
  3. Numbers stop being readable sooner than you think
  4. One constant sets the whole pace
  5. What the save has to survive
  6. Common questions
  7. Where to go next

Ask for one resource, a button that earns it by hand, and generators that earn it on their own. Then be exact about the part that defines the genre. When the player closes the tab, save the time. When they open it again, read that saved time, subtract it from now, and multiply the elapsed seconds by the current rate. One calculation, no catching up.

Never run the time the player missed

The instinct is to treat the game loop as the only thing that really knows the rules. So to find out what happened overnight, you run the loop until it has caught up. That is tens of thousands of iterations for a night and more for a weekend. The tab freezes, and it freezes for longer the more loyal the player has been.

Four steps to a loop worth leaving running#

Paste the prompt below and buy a few generators

You are checking that the next price climbs and that the rate per second climbs with it.

Close the tab, change nothing, come back

The welcome panel should appear immediately with a figure on it. Any pause at all means something is replaying.

Leave it long enough to break the formatter

Keep buying until a total gets wide. If a label starts pushing the layout sideways, the formatter is not being used everywhere.

Change the growth constant last

It is one number and it sets the pace of the entire game, so change it on its own and play a full session after.

PromptCopy this, paste it, send it
Build an idle game as ONE self-contained .html file. No frameworks,
no images, no libraries.

THE LOOP: one resource called energy. A large button earns energy by
hand. Three generators earn energy per second on their own once they
have been bought, and the player can own many of each.

COST CURVE: every generator has a base price, and each purchase
multiplies that generator's own next price by GROWTH, a constant a
little above one. The energy each unit produces never changes. Show
the next price and the per-second gain the next unit would add.

NUMBER FORMAT: write one function that turns any amount into a short
string, one decimal place and a suffix for thousands, millions,
billions and further. Call it for every figure the player can see,
rates included. No raw total is ever printed.

OFFLINE PROGRESS: save the whole state plus the current timestamp to
localStorage, on a repeating timer and again when the page is hidden.
On load, read the saved timestamp, subtract it from the current time,
and add the rate multiplied by those elapsed seconds in one
calculation. Do not run the game loop to catch up. Treat a negative
gap as zero, since that happens when the system clock has moved back,
and credit no more than OFFLINE_CAP_HOURS worth.

WELCOME BACK: on load, a small panel saying how long they were away
and what it earned, with a button to collect.

CHART: a small canvas plotting energy per second over the recent past,
redrawn as the game runs.

PRESTIGE: once lifetime energy passes a threshold, offer a reset that
clears energy and generators and leaves a permanent multiplier behind.
Show what the reset is currently worth before it is taken.

SAFETY: wrap every read and write of localStorage in try and catch, so
a browser that refuses storage still runs. Store a version number with
the save and start fresh if it does not match.

Drive the click feedback and the chart redraw from the seconds elapsed
since the previous frame, never more than 0.05 at a time, so a tab
coming back from the background does not animate the whole gap.
Include canvas { touch-action: none; } in the stylesheet so tapping
the chart on a phone does not scroll the page. Keep GROWTH, the base
prices, the base outputs, OFFLINE_CAP_HOURS and the prestige
threshold together in one CONFIG object at the top, one commented line
each.

The OFFLINE PROGRESS paragraph is the one to leave alone, including the negative gap and the cap. GROWTH, the base prices and the outputs are yours to tune, and GROWTH is the one that changes how the game feels rather than how fast it counts.

Offline progress is arithmetic, not a simulation#

An idle game is mostly played while it is closed. That makes the moment of return the most important screen in the thing, and the most common way to ruin it is to be too faithful to the loop.

Coming back after a day away The player was gone a long time. The arithmetic for it is one line and never gets slower. Replay the missing time while (behind > 0) { tick(); behind--; }The tab locks up on loadA longer absence means a longer wait Work it out in one step earned = rate * (now - leftAt) / 1000Instant, whatever the gap wasA panel showing what was banked Record when they left. Multiply on load. Never replay the loop to catch up.
The left-hand version is not merely slow. Its cost rises with how long the player stayed away, so the people most attached to the game get the worst experience of it.

Production in an idle game is a rate. Energy per second, derived from what the player owns. A rate multiplied by a duration is the amount, and that is true whether the duration was a second or a fortnight. So read the saved timestamp, take the difference, multiply once and credit the result. The work does not grow with the gap.

There is a design constraint hidden in that, and it is worth knowing before you add anything clever. The arithmetic only works while the rate can be worked out from the saved state. A mechanic that changes the rate partway through the absence breaks it. Random events, a boost that expires, a generator that upgrades itself at a milestone: each one turns a multiplication back into a simulation.

If you do want one of those, split the absence into the stretches where the rate was constant and multiply each one. Two or three segments is still arithmetic. Something that changes continuously is not, and it is usually not worth what it costs.

Numbers stop being readable sooner than you think#

Growth is the point, so the totals get large, and they get large faster than anyone expects on the first build. A figure wide enough to shove a button off the edge of a phone screen arrives in the first session.

Where a number stops being readable Add the formatter on day one. Retrofitting it means revisiting every label you wrote. Four digits A thousands separator is enough. Nobody misreads 9,400. Seven digits Switch to a suffix. 2.4M reads, 2400000 does not. Past a billion Keep one decimal place and keep the suffix list going. Past the suffixes Fall back to scientific notation, not a row of zeroes. Rates as well Format per-second figures exactly like the totals. One function, called everywhere. No raw total ever reaches the screen.
Ask for the formatter in the first prompt. It is a dozen lines written once, against a hunt through every label if you leave it until the numbers are already too wide.

Two details are worth insisting on. Keep exactly one decimal place, because a total that flickers between many digits is unreadable while it is moving. And format the rates with the same function as the totals, or you end up with a tidy figure above an untidy one and the panel looks half finished.

There is also a limit to how far plain numbers go at all. Once a value grows past what a double can hold exactly, the last digits stop meaning anything. That is fine for display, because nobody reads those digits anyway. It is not fine for comparisons, so keep prices and thresholds well inside the range where ordinary arithmetic is reliable.

One constant sets the whole pace#

Price each purchase as the previous price multiplied by a constant a little above one. That is the entire pacing system. Because prices multiply while income only adds, the time to afford the next unit creeps steadily upwards, which is exactly the shape the genre runs on.

The constantWhat happensHow it plays
No growth, a flat priceIncome passes the price almost at onceFinished before it started
Barely above onePurchases stay affordable far too longClicking, with no decisions in it
A little above oneEach purchase takes slightly longerThe pacing players expect
Well above oneThe second purchase is already out of reachA wall, and then a closed tab

One constant per generator, each in the config. This is the number to change when the game feels slow, and the only one.

A flat price is the mistake to watch for, because it looks reasonable and it is the default a model will sometimes pick. With a fixed price, income rises while the cost stays still, so the player buys everything available and then has nothing to do. The curve is what keeps the next thing just out of reach.

New generator tiers exist for the same reason. Each one starts the curve again from a cheap price with a bigger payoff. A player stuck on the slow part of one ladder is handed the fast part of the next. Prestige is that trick once more at the top level, trading everything owned for a multiplier that makes the early ladder quick.

What the save has to survive#

Offline progress means the save file is the game. It is also the part exposed to things outside your control, so it is worth asking for the awkward cases up front rather than finding them in a bug report.

  • A clock that moved backwards. The difference between now and the saved time can come out negative, usually because the machine corrected its own clock. Treat anything negative as nothing earned, or the credit arrives as a negative total.
  • A clock moved forwards on purpose. Some players will try it. A cap on how much offline time is credited keeps the reward worth returning for without making the clock a cheat code.
  • Storage that refuses to work. A read or a write of local storage can throw, and in a private window it can come back empty. Wrap both in a try and a catch, and make sure a failure means playing without a save rather than a blank page.
  • A save from an older version. Store a version number alongside the state. When it does not match what the code expects, start fresh instead of reading fields that are no longer there.
  • Two tabs open at once. Both will write, and the last write wins, so one tab's progress disappears. Saving often and keeping the state small limits the damage, and it is a fair trade for a first build.

Show the collected amount rather than adding it quietly. A player who returns to a larger total than they left has to take your word for it. A panel naming how long they were away and what it earned is the one moment where the maths becomes visible, and it is the reason they come back again.

👆Idle and clicker games written by AI

Common questions#

Can AI make an idle game?

Yes, and it is one of the better genres to ask for, because almost all of it is arithmetic and layout rather than physics or collision. The parts worth being specific about are offline progress, the number formatter and the price curve.

Why does my game freeze when I come back to it?

Because it is replaying the time you were away, one tick at a time. Replace that with a single calculation: the saved timestamp subtracted from now, multiplied by the current rate. The freeze goes, and it goes for every length of absence at once.

How do I keep big numbers readable?

One function that returns a short string with a single decimal place and a suffix for thousands, millions and upwards, used for every figure on screen including the rates. Ask for it in the first prompt, since adding it later means revisiting every label.

What should the price multiplier be?

A constant a little above one, applied to each generator's own next price. Close to one and purchases never slow down, so there is nothing to aim at. Much higher and the second purchase is unreachable. Tune it by playing a full session, not by reading the number.

Should offline earnings be capped?

Yes, for two reasons. It limits what moving the system clock can get somebody. It also keeps a return visit worth making, instead of handing over a total large enough to skip the rest of the ladder. Keep the cap in the config and show it in the welcome panel.

Do I need prestige in a first version?

No. Get the loop, the formatter and the curve working, and leave prestige until a session reaches the slow part of the ladder. It is the same curve trick applied one level up, so it is a small addition once the curve itself is right.

Where to go next#

When you have caught yourself opening the tab to check on it, publish it. It gets a page recording the model and the prompt behind it, and other people can leave it running too.

The general method is in how to make a game with AI. If you want the growth to be something the player manages rather than only accumulates, the simulation guide is the next read. For a short session with the same low friction, try the casual guide. Prompts for common faults are in the prompt guide, and the idle games here are a short list worth adding to.