Showoff Saturday [Showoff Saturday] A city quiz that picks your next grid of street photos with Thompson sampling, all in the browser
Hello! I built CityType, a quiz that matches you to cities from the streets you tap. A few parts I had the most fun with:
- It adapts while you play. After two grids of variety, every tap and every skip refits a small logistic regression over 19 street traits, right in the browser. Each new grid mixes a Thompson sample from that model, a "probe" tile that differs from something you tapped in just one trait (same glass towers, but leafy), and a wild card far from everything you've seen. The idea is that a wrong guess can still get corrected. Once the taste looks clear it offers to stop, which happens somewhere between grid 8 and 20, depending on how consistent your taps are...
- There's no backend for the matching. The scoring runs client-side based on a ~300 KB JSON of 290 cities and towns.
- Results can be shared without a database. The whole taste profile is packed into the link, 30 to 108 base64url characters. I first stored 5 bits per trait and it looked fine, but then I ran a simulation that showed only 73% of simulated profiles kept the same top 3, so I switched to 8 bits, which gets 98.6%.
- The share cards are drawn on a canvas in three formats, with a contour-line terrain seeded by your result.
- The 496 street photos are AI-generated on purpose so that they all have the same light and lens. The idea is to make users react to the buildings and not to whichever photo had the nicest sky...
Stack: Astro with a Preact island, Cloudflare Workers + D1, d3-geo for the globe on the results page. There's no sign-up and no tracking cookies either.
I'd love to know whether the adaptive part feels like it's learning you, or just like a stream of random photos. And how it feels on your phone as well.
https://citytype.fyi/?ref=r-webdev
Have fun!