Want a quick email when a new article is published? Subscribe
Could a computer teach itself to fly?
I enjoy learning which borrows from other disciplines. As people building companies, products and software, we can learn from all kinds of other fields of endeavour. I’ve written before about what software engineers can learn from aviation. I once ran a session at London Tech Week on the basis of it - I taught a room full of product and software developers how to fly an aeroplane, along the way learning all kinds of lessons that are valuable to their own trade.
Now I’ve taken it rather more literally and from a different angle. How hard is it to get a computer to learn to fly? Obviously we’ve all heard of auto pilots, but can a computer readily figure out how to fly for itself; no lessons, no programming, no instruction except a score to aim for, just trial and error? Machine learning at its finest.
Turns out, it’s not as hard as I expected. And perhaps even more interestingly, there are lots of lessons we can learn along the way. This series of articles describes the process and some of those lessons.
It all started with my BigSkySimulator.
The big sky theory in aviation is that planes don’t crash into each other very often because the sky is really big. Simple as that. Fortunately it’s not what commercial aviation relies on - airline travel is safe because everything about it, from the pilots and the aeroplanes to the way they move through the sky, is carefully regulated and controlled.
But the person flying that 4 seater so a friend can see their house from 2,000’ on a sunny summer’s afternoon utilises what is called “see and avoid”. Look out the window and make sure you don’t hit anything. It might sound primitive, if you’ve got two aeroplanes closing on one another at about 120mph each, but it’s generally very effective and it relies on the big sky theory.
I’d always wanted to build a mathematical model to test it out. If enough pilots fly around a small space for long enough without being too careful about keeping a good lookout, how long till they hit one another? Better still, how about a simulator in order that one could watch it happen. Put like that it sounds a bit morbid, but I swear it was only a theoretical curiosity.
As a software engineer I could have tried to build such a simulator, but it’s a big project. You’d need to create a 3D world, a model of how an aircraft is flown, a means of launching the aircraft, the display for all of it, and so on. My best guess, having now created at least half a dozen such simulators, is it would have taken me about three months of coding. I couldn’t spare that much time.
With the advent of Large Language Models (LLMs) that can write code, I decided to give it a go. I created the first version in mid 2025. I used Google’s Gemini to write the code, in a regular chat window. I’d converse with the LLM, explaining each feature one step at a time. I explained how a small aeroplane flew a single circuit - take off, fly straight for a minute or so, then turn left 90 degrees, levelling off at 1,000’, fly for about a mile, turn left 90 degrees and fly for a few minutes until you’re past the end of the runway where you departed, turn left 90 degrees a third time whilst starting to descend, fly until a point whereby when you finish your fourth and final 90 degree turn you’ll be aligned with the runway, then fly to that runway descending steadily as you go, and touch down roughly at the point you started. I told it the speeds you used for each part of that journey, the heights, the timings. I asked it to draw a top down view of the aeroplane doing that circuit, then add other aeroplanes doing the same thing, and see how long it took until two aeroplanes ended up in the exact same bit of the big sky.
In that first version, it took a couple of weeks of two to three hours a day (which was still more time than I really should be spending on this idle musing) to get the code to work. The bit that took the longest was landing, which incidentally is generally both the most dangerous part of any flight (even an airline flight) as well as the hardest part for a new pilot to master. The code would have the plane turning too soon, not soon enough or wandering off, missing the runway completely. I’d watch it run the simulation, see what was going wrong, stop it, prompt it to change, have it write some more code, run it again, and repeat.
Eventually it worked. Meanwhile, Anthropic released a better coding model. This time I wrote down all the instructions for how the thing should work, gave it to the model and had it build it. It spent about half an hour writing code, which then wouldn’t run. Cue lots of back and forth and eventually it did run, and did a much better job than that first version - the final approach was nailed after only a few iterations of discussion between me and the LLM.
The next release of a better model, Opus 4.6, coincided with another change - giving the LLM a browser so that it could test the flights itself. This was the turning point. The LLM could now write some code, try it out and watch what happened, fixing whatever it saw, without me touching it. It worked.
Along the way, I’d added interesting aspects. An apron from which the aircraft would taxi out to the runway. A profile view of the planes in the circuit. Wind (a big deal in flying, especially with small aeroplanes). Later came different aircraft types, different skill levels for the mechanical pilots - high skill pilots would hold headings and altitudes more precisely, basic see-and-avoid, where the model used to control the plane was allowed to “see” the existence of other aeroplanes out of the window, as long as they were in front of it, and so on.
At this point I had a detailed specification, which actually removed all the information about how a General Aviation aeroplane flies a circuit, because the LLMs already knew that. But that Product Requirements Document (PRD) became my standard way for testing out new LLMs as they got released. I’m not claiming it was a robust test, or even a particularly good one, but it’s certainly true that as models improved, the results got better and better. It was also a way to compare two models from different AI labs. I tried it with all the Claude models (Fable was a big step up in terms of the polish it applied to the whole project), the OpenAI ones in Codex, the lower-cost models from the Chinese labs, and even self hosted models.
With Fable 5.2 I added a view out of the cockpit window. This was never meant to be a simulator with realistic visuals, but it’s nice to be able to see what’s actually happening in the aeroplane.
Finally I added the ability to send commands to the aeroplane so you could control it and see what the pilot could see. But unlike a normal flight simulator, you couldn’t ask it for its position in terms of latitude and longitude, angles in 3D space and speed to 2 decimal places, because pilots don’t think of positions that way - they think of it in terms of “I’m 2 miles east of the runway” or “I’m half a mile from the touchdown point at 400’ going about 80 knots”.
Once I had that, I started thinking about how a machine could learn to fly such a plane. To date, it had worked because the code told the plane how to move - after one second accelerate at this speed, once you’re going that speed then start to climb at this number of feet per minute. But firstly that was telling the plane what state it should be in, not giving it control inputs that would make it move towards a particular state and secondly it was all based on already knowing how to fly.
Could I build a machine learning system where the computer would figure out how to be a pilot? Turns out, it’s easier than I expected, and hard in places I didn’t expect…
Share this article
Comments
Leave a Comment
All comments are moderated and may take a short while to appear.
Loading comments...