Capital Allocation
Technology Systems

Developer Log Flight Dispatch 98 Engineering

Developer Log >

Whatever the weather

Weather is everything in flying. While modern aircraft can mostly fly through most conditions (and absoutely not a volcanic ash cloud), the weather still has a massive impact on the day to day running of an airline. Snow, wind, thunderstorms, really just about anything has an impact on how much fuel is loaded or if the flight is on time.

This has been one of the things that I was putting off for quite a while, but once I got into it I really enjoyed it. It is completely overwhelming to think about, and I’m going to have to come back to it to fix a lot of what I’ve built. This will do for now.

Keeping things in step

Going into this, there were a couple of things I knew I would want to make sure happened.

  • It isn’t live weather. It’s a really lovely idea, but I want to create a more predictable environment.
  • It’s deterministic. For scenarios, it would be great to be able to know a weather pattern to work with. And it’s saved with the game.

It would be really annoying if each time you opened a save the weather changed entirely based on when you opened the game. Having a deterministic outcome means that you can re-open or share saves, and the weather doesn’t just randomly change.

For these reasons I knew I’d want a seed-based system that would generate a predictable weather pattern. Obviously the player doesn’t get to find out what’s going to happen, but it makes the whole game much easier to build if the weather can be moddled.

Locking the weather also means it’ll render the same on different computers (or at least, it should), and when you speed the simulation up. One day I might even get multiplayer to work, and this’ll be a huge help if the weather is connected to the game ticks.

Housekeeping

Before I got started on the weather, I did a review of how the tick is being used, and most importantly, how many days there were in a year.

Having built a few systems around the calendar, I knew this was going to be a problem and I’d need to face it. When I started working on the game last year, I originally was going to use a 28-day calendar for all months, so that I wouldn’t have to deal with leap years and timezones (as much). But of course it turns out that’s a problem no matter how many days there are in a year. After a lot of debate, I settled on using 365.25 days a year. It’s good enough, and it means that most systems can act fairly normally.

This now gives a shape to the year that I can model the weather around.

The second bit of housekeeping was to sort out the world verus the planet. The data had been getting tangled up a tad and needed organising. Trying to perfectly collect data for all airports around the world is something that companies struggle with in the real world, so I’m not going to try and do that in a game. I want it to feel real, so by using things like OurAirports I’m going to build a world-like database of airports, but with a few tweaks to make it easier. And ultimately more enoyable to play, hopefully.

But maybe you don’t want to play that world. Maybe you want to have a world with fewer airports, or more. Or you don’t agree with the runway data (whole article on Gatwick’s pesky runways is inbound). So I know that I’m going to allow changes to the standard data in the future, or even allowing players to build their own world from scratch.

However, also changing the planet itself is a nightmare, because the geography does so much. So here’s the call I’m making for now.

  1. The planet is the geography, such as the oceans and landmass
  2. The world is the airports, runways, routes, and more

Versioning the world and planet

If there’s ever a 1.1 or 1.2 version of the game, then I want to let players keep their saved games, and be able to play with data they’ve used before. So I’m going to name the worlds, as they’re unlikely to change too much, and version the planet.

The planet data is simply version 1, and it’s unlikely to ever change unless the tectonic plates start moving around at an increased speed.

The world itself, the first version that ships with the game will be called ‘Amelia’, after Amelia Earhart, who was the first woman to fly across the Atlantic.

Planet data

The world data I’ll come back to because it needs a whole article on how it’s created, but the planet itself is coming from Natural Earth, at the 1:10m scale. Really impressed as that it also includes lakes, which especially in Canada and the USA are really important.

With the housekeeping taken care of, we can now start to build weather.

Scenarios

Each WeatherScenario is based off the world and a seed. (Seed is easy to read so you can share it, it removes spaces and is not case sensitive.) I have put in a very simple system for adjusting how strong the weather is, which I don’t know if we’ll keep for launch, but will be useful to test with. Just put five points in, from mildest to severest, with 3 being ‘faithful’. Effectively 3 is going to be steered towards being real-ish (for the early 21st century), and then you can go softer or harder from there. From the WeatherScenario you can predict decades of weather. In testing I went up to a few decades, I will do longer tests later, but it held up reliably enough. Game ticks are per game minute, and that’s certainly enough to plan weather around.

From the scenario, we spawn WeatherObjects. These have a duration, direction, location, ’storminess’, stength, and some other properties attached as its purpose. These are hashed and indexed so you can’t ever have a duplicate at the same time. Weather is spaned, and goes through four stages: forming, deepening, maturuing, and decaying. Each one has a front (like warm or cold).

A quick sum says that at anytime there’s about 120 weather systems in play, going up over 150 in July.

Climate action

To get the weather going, I decided not to try and model the exact climate. There’s a risk that I end up with slightly strange weather, but I think more of the gameplay needs working on before its worth trying to get it ‘right’.

The synthetic climate build has no mountains or ocean currents, and just divides the world up into some rough averages. I feel like this is going to be one of those whack-a-mole problems where fixing the weather in Sydney creates a problem in New York. I’ll come back to this.

Steering and breeding

Obviously weather doesn’t just stay still. A steering system acts as the upper winds that push weather systems around. I still have to look up whether latitude or longitude is the one that goes around the world, but the idea is that the weather systems are pushed around in a longitudable direction, westerly. I think it’s going to be a while before I find out if it’s any good.

Weather also doesn’t just appear out of nowhere. It forms and then moves. A lot of the places it forms are over oceans, seas, and some large land areas. If you’re in Europe, the weather is formed in the Atlantic, near Iceland, and the North Sea. Each area has a spread of how big the area is weather can breed in, and then how many times it can happen in a year (divided into 12, so it’s not tied to calendar months as the weather doesn’t care for them).

{
    "id": "mid-atlantic",
    "kind": "Low",
    "latitude": 42,
    "longitude": -38,
    "spreadKm": 700,
    "perTwelfth": [4, 4, 4, 3, 2, 2, 1, 1, 2, 3, 4, 4],
    "notes": "Secondary lows on the Atlantic polar front"
}

This is positioned almost slap bang in the middle of the North Atlantic, amazingly, and then has 350km on either side. As it’s in the northern hemisphere, it creates a lot of weather in late autumn, all winter, and then dies down towards the summer (in northern hemisphere terms). It spawns low pressure systems common near the poles, called polar low.

A little further south is the Azores High, which is positioned over the Mid-Atlantic Ridge. This produces a summer high pressure system.

{
    "id": "north-atlantic-ridge",
    "kind": "High",
    "latitude": 40,
    "longitude": -35,
    "spreadKm": 800,
    "perTwelfth": [3, 3, 3, 4, 4, 4, 4, 4, 4, 3, 3, 3],
    "notes": "Ridges building north from the Azores high"
}

The breeding grounds (called Genesis) are also versioned, although I really hope only one version is needed for launch. If feedback says otherwise then there’s scope to update them post-launch. It does mean that there’s nothing in code that actual dertermines the weather, so it’s really easy to change as it’s just a bunch of JSON files.

WeatherSim

I also built WeatherSim, which is used for testing and checking determinism. I can run it on a number of different computers and operating systems, with different processors, to make sure that the weather runs the same on different computres. It isn’t too important right now, but once I start piling on routing based on weather, it’s going to get crazy. I also imagine doing this now is going to make multiplayer much easier when I get there.

seed=1 intensity=3
Scenario 05de37cbfa4ddc91c55e6e12bce1f3a42dcfce8c3428b01d90b87dbf2348686e
    world World Amelia, seed 1, intensity 3, weather model 1, planet data 1
day     0 28D68E1CF2475680
day     7 396D7E35707BE681
day    14 915C8C67D100C3C0
day    21 5C242C72D8DCFEBA

There’s a commited determinism file with a hash of a bunch of different runs in it that’ll get run each time I make big changes.

Testing

I think this is one of those projects where it feels like there’s more tests than code. Picking a few usual suspects for testing (Heathrow, JFK, Syndey, Haneda, etc) gives a pretty good sense that the world is covered. I will never confess to being able to read a TAF report fluently (although I can just about read a METAR), but if nothing else, they mean that I can detect if a change is made accidentally.

Because the game can be run without the UI, you can speed up time really quickly and test 30 days of weather quite quickly. At this point I have about 4,000 airports in Amelia, so asking reports of each airport over 30 days produces 3,856,394 reports! Speeding up even more and running it for a year of weather produces 46,653,276 reports. I know I’m just testing the same thing in a loop, but it still amazes me that it works.

Reporting

So now there’s a bunch of weather systems blowing around the world. Now what? The reporting comes in a few formats.

METAR and TAF
These provide data on an exact location. If you’ve ever played a flight sim (or flown for real) you’ll know about them. METARs are very simple and provide a few key facts. TAFs go a bit further and add a bit of a prediction (which is where the determinism comes in useful again).
SPC
A surface weather analysis, or Surface Pressure Chart (SFC). Styled to be very 90s style chart that shows the clouds, storms, fronts, fog or anything else. Produced by a computer, it is quite blocky but gives enough detail that you’d know what was up.
SIGWX
This one is probably my favourite. It’s a SIGWX chart, which I didn’t know existed until I started this. It’s a chart of any things that will ruin your day. And of course because it’s 1998, it’s delivered by fax.

Understanding TAF

I don’t expect anyone to read a TAF (I guess some people can), so I’ve just added the ability to hover over the reports and find out what each part is. So rather than a random code, you’ll be able to see “Visibility 10 statute miles or more”. And then hopefully you know that’s a good thing for flying.

Enough flirting, show us the charts

Well done for making it all the way down to the end of this post.

SIGWX

I actually really love the SIGWX chart because it’s just so cute.

A fax of a weather map over Europe
Nothing to worry about

The fictional meteorological agency Skerryvore Met (named after Skerryvore Lighthouse in Scotland) provides this report every 10 minutes, delivered by fax. If something appears on a signifcant weather chart, then it’s signifcant. At the moment it just centres on where your hub airport is.

I had never seen a lot of the symbols on a SIGWX chart before, and I don’t think many people will have. I’ve got a script to export all the symbols into images, and they’ll be added to the help docs so you can learn more about the map and what it means. I think I’ll probably add an alert to the player that there’s going to be a big weather problem coming their way, but if you wanted to check on this for time-to-time, or maybe at the start of the each day, you could see what might be heading your way.

These could be a tropical cyclone, a storm, a serve gale, lots of fog (like, loads) or a massive thunderstorms (or lots of thunderstorms). These major weather events could easily be a bit annoying if they keep coming, so I’ve artifically limited them to 6 a year (bearing in mind they can happen anywhere in the world, you could get 4 and none of them affect you). And there has to be at least five days between them. I’ll get feedback on these, and possibly allow people to turn them off like how you can play SimCity with disasters turned off. Again this is stored a JSON file that can be swapped out or ignored.

SFC

A screenshot of a weather map over Europe
Look at those cold fronts – SFC

I tried to make this one more pixely so it looked like it came off Ceefax or something (very niche British reference). With reporting data per airport, each airport knows whether it’s under VFR or IFR conditions. Went way too hard on the pixels though.

A screenshot of a weather map over Europe centered on the UK with heavy blocks
Can you see your house?

Even without weather the map is way too blocky, and when the weather covers the map, you have no idea where anything is.

A screenshot of a weather map over Europe centered on the UK
Easy on the eyes

Increasing to ¼-degree weather blocks makes it look a tiny bit smooth when you zoom out, but I think it’s fine. Although there aren’t country borders (don’t want to touch that), you can at least see the rough shape. Making it less pixelated and then adding a border helps a bit, and then showing just the border through the weather helps a bit more.

A screenshot of a weather map over Europe centered on the UK
Snow’s coming

I can’t decide whether I like the dots for the airports or not (and it’s only some airports). Will wait for others opinions before removing them, or maybe adding as a filter.

Remaining todos

Having played around with the weather in extended play tests, it’s… not great. That’s not totally fair, it’s pretty amazing and I’m amazed it works. Watching weather systems form and drift across the screen is amazing. It doesn’t match the world I know though, because there just isn’t enough data to work with. You may have noticed in the screenshot of the SFC map, but it’s the biggest snow storm Europe has ever seen. What’s missing now is real climatology, and adding terrain like mountains and deserts. This is perfectly good enough for now.

Summary

Could this have waited? Yes. Does this actually do anything in the game? Nope. Was it really fun? Yes.

I’m going to work on something more functional next, or probably not and just find something else to procasinate with.