Toxic Games

Why farming games need a seeded RNG

Weather in a farming game has to be random enough that a season feels alive. It also has to be exactly the same weather when you leave for three days and come back. A seeded random number generator does both: it gives every game day an answer before anyone opens the farm.

That sounds like a fussy implementation detail. It changes whether the game can trust its own saves any time a player’s farm opens.

The weather can’t wait for you

Imagine a farm game that decides today’s weather only when the player loads the page. A player checks in at breakfast, gets sun, and plants a field. Another player leaves the tab closed for a week. When they return, the game has seven days to catch up. If it rolls those days from scratch, it needs to produce a whole weather sequence in one go.

That is already awkward. It gets worse when a browser reloads halfway through the catch-up, or when the game has to replay an old save after a bug fix. If the weather can change because the game happened to run in a different order, the farm has no stable history. The same save can produce two answers.

The cheap fix is to write every day’s weather into the save. That works, but it turns weather into a growing log. A long-running farm carries a little almanac of facts the game can calculate again. More saved state also means more ways for two parts of a simulation to disagree about what happened on day 84.

A seed makes a calendar without storing one

Acres keeps a worldSeed in the farm state. For a given game day, the simulation combines that seed with the day number and gets one value between zero and one. It then looks at the season’s weather table and picks a result from it.

Spring leans toward sun, cloud, and rain. Summer gets more sun and a little more storm risk. Winter substitutes snow for rain. The weights make the seasons feel different; the seed and day make a particular result repeatable. Day 19 is whatever day 19 was going to be for that farm, whether the player watches it happen or returns a month later.

There is no saved list of past weather. Ask for day 19 again and the game calculates the same answer. Ask for day 20 and it calculates another. The weather is still variable from the player’s point of view. It just isn’t a fresh dice roll every time the page needs to know.

That saves more than space. A list can report that day 19 was rainy, but it cannot explain the result without carrying every prior entry with it. The seed, the day, and the season are enough to reconstruct the answer. The rule is the record.

That distinction matters when the game catches up after time away. It can walk through the missed days, recover the weather for each one, and apply the consequences in order. Rain and storms water crops. Snow blocks planting. A storm can also cost soil and damage a standing crop, so the game still has real state to advance. The weather itself does not need to be one more piece of it.

Not all randomness belongs in the same bucket

There are two useful kinds of randomness here.

Weather and market noise are facts about a date. They should not depend on how many other things happened first, so Acres derives them from the world seed and the day. That makes them safe to look up from anywhere in the simulation.

Other events do depend on order. A crop hit by a storm, an animal breeding, or a contract draw can consume a random result as part of changing the farm. For those, the game keeps the random number generator’s current position in the save and advances it in the same order as the rest of the simulation. Starting a new generator in the middle with Math.random() would make a reload quietly change the future.

Keeping those jobs separate is less clever than it sounds. It is mostly a rule: derive a fact from the calendar when it belongs to the calendar; save a random cursor when the result belongs to a sequence of player history.

Replaying time has to give the same farm back

Offline progress is a test of this rule. Acres can process forty missed game days in one pass, or process ten, save, then process the next thirty. The farm should end in the same state either way. Otherwise a player who checks in more often has a different simulation from one who takes a week away.

That is not just a player-facing concern. Determinism gives us a useful way to test the game: the same seed and the same commands must produce the same save. When they do not, there is a real mistake to find instead of a shrug about chance.

The result is a farm where weather can ruin a plan without turning debugging into a weather forecast. It has enough uncertainty to make a season worth watching, and enough consistency to let the game remember what happened.

Acres is one of the games on the same Toxic Games account. Its season clock keeps moving when the tab is closed. The weather for those days was already there.

devlogacressimulation