Spielerando

Make an Idle Game With AI That Keeps Counting Offline

An idle game is one where numbers grow by themselves and you decide what to buy next, so the thing to get right is time. Have your AI save when the player left and work out the earnings on return, instead of counting while the page sits in the background.

Why does counting in the background fail?

Say you run a postal service staffed by snails, and each snail brings in one stamp a minute. The simple way to build that is a timer that adds a stamp every so often. It looks perfect while you watch it.

Then the tab goes to the background. Browsers slow down timers there on purpose. MDN's documentation says Firefox on a computer waits at least a second in an inactive tab, Chrome can drop to once a minute after a silent tab has been hidden for five minutes, and Firefox for Android can wait 15 minutes and may unload the tab entirely. Close the tab and nothing counts at all.

The fix is simple arithmetic. Save the clock time when the player leaves. On return, take the time passed, multiply by the earning rate, and show it: "You were away three hours, and your snails delivered 180 letters." That screen is also the best moment in the whole game.

What happens when the numbers get huge?

Browser games usually run on JavaScript, and its ordinary numbers have limits. Whole numbers stop being exact above about 9 quadrillion, and anything beyond a number with 309 digits turns into Infinity. In most games that never matters. In an idle game it is on the road map, so decide early how far your numbers will go and how they appear on screen, such as "4.2M".

What is the smallest version?

One button that sends a letter, one snail you can buy, one upgrade that doubles its speed, and the return screen.

Now the shape of the game. Each snail should cost a bit more than the last, say 15 percent, so that buying the next one takes slightly longer. The player should nearly always be able to see the next thing worth saving for.

Add a reset last: retire your snails and start over with a lasting bonus. A small skill tree works well for those bonuses.

What ends these games?

The wall. On day two the next purchase is a full day away and nothing new appears, so the player closes the tab for good. Nobody can find that by playing for ten minutes.

Your AI can, though. A whole week of patient play takes a computer a moment to work out. Ask for that list before you polish anything.

Paste this to your AI

Build a small idle game for the browser: one button that earns, one thing that earns by itself, one upgrade, and a screen that says what I earned while away.

Your first job is a state machine in a Mermaid diagram of the loop: earn, afford, buy, earn faster, stall, reset, plus the path through closed and back again. Tell me what each state does when the tab is hidden, closed or reopened. Build from that.

Never add earnings by counting in the background. Save the time I left, and work out earnings from the time that passed, up to a limit of 8 hours.

Keep every price and rate in one table. Before I play, simulate a week of a patient player and show me when each purchase happens. I want that list, not "the pacing looks good". If you have no such run, say you do not know how it paces.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP

How to check it worked

  • Hide the tab for ten minutes. Your earnings should match the full ten minutes.
  • Close it overnight. You should get the return screen with a believable sum.
  • Move your computer's clock forward. The 8-hour limit should stop a fortune appearing.
  • Reload straight after buying. The purchase should still be there.
  • Let the numbers grow. Past a million they should stay short and readable.
  • Look for the next goal. At any moment, you should know what you are saving for.

Sources

Last updated: 2026-11-02