Spielerando

Weather System

A weather system keeps the sky one way for a while and then eases into a neighbouring kind: clear, cloudy, rain, storm. A change never jumps from clear to storm, and it fades in rather than switching. Chance decides what comes next, but it comes in as plain numbers, so the same numbers give the same sky.

Also called: Dynamic weather, Weather cycle, Rain and storms, Changing weather.

A small wombat shepherd in a red cape stands in a meadow where a clear sunny sky on the left melts through a band of grey cloud into a violet storm with rain and lightning on the right, three blue sheep at its feet.
Gullwind Pasture, an invented shepherd adventure game. Invented game, image generated with AI.

Paste this to your AI

Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.

Add "Weather System" to my game.

What it should do: Weather gives a world a mood and a rhythm. It changes how the world looks and sounds, and it can change play: rain slows a fire, a storm closes a pass, a clear sky is a good time to travel.

Build it exactly as this state machine. First check that it fits my game, then build it like this:

```mermaid
stateDiagram-v2
  [*] --> clear
  clear: Clear sky
  cloudy: Clouds
  rain: Rain
  storm: Storm
  clear --> clear: sky stays clear
  clear --> cloudy: clouds roll in
  cloudy --> cloudy: clouds stay
  cloudy --> clear: clouds break up
  cloudy --> rain: rain starts
  rain --> rain: rain goes on
  rain --> cloudy: rain eases
  rain --> storm: storm builds
  storm --> storm: storm rages on
  storm --> rain: storm passes
```

Use these starting values:
- meanDuration: 180 s
- fadeTime: 20 s
- wetBias: 0.4

Watch out for these common mistakes:
- Clear sky to storm in one step: Tell your AI: only let the weather change to a neighbour in a row from clear to cloudy to rain to storm, and make a storm pass through rain on its way out.
- The sky snaps: Tell your AI: keep the old weather and blend from it to the new one over a fade time. Show both in proportion.
- A change starts in the middle of a fade: Tell your AI: never plan a spell shorter than the fade time.
- Fast-forwarding runs a whole week of weather: Tell your AI: allow one change per step at most, and start the new spell from zero. After a skip, the sky is simply a new one.
- The weather cannot be replayed: Tell your AI: pass the two random numbers in from outside, from a generator used only for weather, and save the state of the sky with the game.
- A roll lands on the weather already there: Tell your AI: a change always goes to a different kind. If you want longer spells of one kind, raise the average length instead.

Do not change anything else in the game. Do not claim anything without proof: model what it takes, and show me what your solution rests on and how I can see that it works. If you cannot show something, say you do not know. When you are done, tell me in plain words how to try it.

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

What it does

Weather gives a world a mood and a rhythm. It changes how the world looks and sounds, and it can change play: rain slows a fire, a storm closes a pass, a clear sky is a good time to travel.

How it runs, as a diagram

Everything it can be in, and what moves it on. Your AI builds from exactly this.

sky stays clearclouds roll inclouds stayclouds break uprain startsrain goes onrain easesstorm buildsstorm rages onstorm passesClear skyCloudsRainStorm
How it runs, as a diagram
  • Clear sky → Clear sky: sky stays clear
  • Clear sky → Clouds: clouds roll in
  • Clouds → Clouds: clouds stay
  • Clouds → Clear sky: clouds break up
  • Clouds → Rain: rain starts
  • Rain → Rain: rain goes on
  • Rain → Clouds: rain eases
  • Rain → Storm: storm builds
  • Storm → Storm: storm rages on
  • Storm → Rain: storm passes

Good starting values

ValueStart withWhat it changes
meanDuration180 sHow long a spell of weather lasts on average. Each spell lasts between half and one and a half times this. Three minutes is long enough to settle in and short enough to see change in one visit.
fadeTime20 sHow long a change takes to blend in. Too short and the sky seems to switch, too long and the weather is always half one thing and half another. A spell is never shorter than this.
wetBias0.4How rainy the world is. It is the chance that clouds lead to rain, and half that for rain to lead on to a storm. At 0 the sky never rains.

What usually goes wrong

Clear sky to storm in one step

The next weather is picked from all kinds at random. A bright day turns into a storm with no warning, and a storm ends straight into sunshine.

Fix: Tell your AI: only let the weather change to a neighbour in a row from clear to cloudy to rain to storm, and make a storm pass through rain on its way out.

The sky snaps

The weather switches the moment the spell ends. Rain starts at full strength in one frame, the light jumps, and the player sees a cut.

Fix: Tell your AI: keep the old weather and blend from it to the new one over a fade time. Show both in proportion.

A change starts in the middle of a fade

A spell is shorter than the fade. The next change begins before the last one has finished, and the old blend is thrown away, so the sky jumps.

Fix: Tell your AI: never plan a spell shorter than the fade time.

Fast-forwarding runs a whole week of weather

The player sleeps for eight hours or the game is paused for ages. The code loops through every spell it missed, or does a thousand changes in one step.

Fix: Tell your AI: allow one change per step at most, and start the new spell from zero. After a skip, the sky is simply a new one.

The weather cannot be replayed

The weather asks the game's random generator directly, and other things use it too. Two players, or a test, get a different sky from the same start, and a saved game gives a different weather after loading.

Fix: Tell your AI: pass the two random numbers in from outside, from a generator used only for weather, and save the state of the sky with the game.

A roll lands on the weather already there

The next weather is picked from all kinds including the current one. Sometimes nothing changes, spells silently double in length, and a short test of the mechanic seems broken.

Fix: Tell your AI: a change always goes to a different kind. If you want longer spells of one kind, raise the average length instead.

How to check it works

Works well with

Common questions

how does a weather system work in games

The game keeps one kind of weather for a spell, then picks a neighbouring kind at random and blends into it over some seconds. Chance only decides which neighbour, so a storm does not appear out of a clear sky.

how long should weather last in a game

Start with about three minutes on average, with each spell between half and one and a half times that. Shorter feels restless, longer means many players never see most of the weather.

how do i make weather the same for every player

Do not use the game's general random numbers. Feed the weather its own numbers from a shared starting value. The same start and the same numbers then give the same sky on every machine, and in every test.

what do i tell my ai to add a weather system

Paste this: Add weather in a row from clear to cloudy to rain to storm. It changes only to a neighbour, after a spell of about three minutes, and fades in over 20 seconds. The random numbers come in from outside, so the same numbers give the same sky.

Where it comes from

We could not find a reliable origin for this one yet.

Where this mechanic comes from has not been researched yet.

Games are named only as references. Names and marks belong to their owners, and nothing here is endorsed by them.

What was checked

This is what separates the blueprint from a catalogue entry: the values on this page come from code that runs.

Your AI gets the code

Tested example code comes through the Spielerando connection, so your AI can use it right away. How to connect it