Inspiration
I was curious what it would be like to sail in different parts of the UK, from Cornwall to the west coast of Scotland. You can't easily try them all for real, so I built a simulator that uses the real wind forecast and coastline for wherever you pick, to show what sailing there would actually be like.
What it does
Drop a start and a few buoys anywhere around the UK. WindSail pulls the real wind forecast and coastline for that spot and puts you at the helm of a real yacht, whose speed comes from its official racing performance data. You can't sail straight into the wind, gusts drift across the water, and if you hit land you're aground. You race a computer sailor in the same boat and the same wind.
How I built it
The backend is a Python simulation that streams the race to the browser over a websocket. The frontend is React and MapLibre. The computer sailor is simple: at each moment it picks the heading that gets it closest to the next buoy fastest, without running into land.
Challenges
The computer sailor was fine on open water and hopeless in harbours. It kept so far from land that it couldn't reach a buoy placed next to a quay, so it sailed past and wiggled about. Real data was also a pain: the raw coastline file is 1.3 GB, and drawing it smoothly as you zoom is still a work in progress.
What I learned
Sailing is mostly geometry: once you see a boat's speed plotted against wind angle, it's obvious why zig-zagging upwind beats pointing at the mark. I also learned that a good test suite is what let me hand tasks to AI agents overnight and trust what I found in the morning.
Built With
- fastapi
- maplibre-gl
- python
- react
- typescript