Lurker News
This is the first iteration of a short game I’m making that tries to interactively explain some of my favorite math questions / ideas. My goal is mostly to get the player curious and not necessarily to explain absolutely everything.

There were a lot of fun technical parts to building this:
- For implementation reasons, it’s much easier if the lines all have integer intersection points with each other. To do this, when a new line is added I “cheat” by rounding intersections to integers and then splitting the old lines at the intersection into new linds (with potentially different slopes) going through the rounded point
- I had to draw semi accurate maps of actual places (UK, South America, US west coast) in the HTML canvas using just line segments. I tried a few different solutions, including using SVG data. I ended up using the topojson library to give nice line approximations to GeoJSON maps
- I use a simple backtracking algorithm to handle the live coloring of graphs
- I use turf.js’s polygonize function to handle finding polygons from line segments (very happy I didn’t have to implement this myself!)
- I wanted to make the game as mobile friendly as possible (don’t think I’ve nailed this quite yet)
There were also a few tradeoffs I made:
- I wanted give links earlier in the game for players to learn more, but I decided to wait until the end to maintain the flow of the game
- In order to make the game more mobile-friendly, I generally stuck to maps with a small number of regions (at least for maps people have to interact with them). So for the most part all of the instances in the game are “easy”

Comments (172) 62 threads

Earlier comments
soneca1 reply#
Great job! I enjoyed going through the steps.

The final though seemed like a huge leap for me, who don’t know anything about those math mysteries (which I assume is your target audience).
First I was curious to learn how is the fast way to understand that 1, 2, or 4 colors suffice. And why finding out such a way for 3 is so hard.
The zero-knowledge proof demonstration felt like “changing the subject”. Probably I missed the connection there.

gowld#
ZKP is the subject. The maps part is a helper lemma.

It would help to clarify that in the beginning. The game is a bit of a shaggy dog tail. It would be good to give an outline and progress bar at the start (without spoilers)

sverona#
This is cute. You should flag the "I claim that three colors suffice" map if the user actually 3-colors it. At least, I think I did...
aib#
Ahh, very nice. It was fun to rediscover/relearn some of these things through this game.

Very nice wording on the 5-color challenge! I think it was the perfect balance.
One thing I was missing was the ability to move the points already on canvas. I assume you already considered, though. (As well as right-click-to-remove?)

Guvante#
Fun fact, one of the reasons the four color problem is hard to prove is there isn't an algorithm that can color a map in four colors.

Well beyond effectively trivial ones where you try over and over again.
But the algorithm for coloring with five is pretty easy (relatively speaking still involves fun graph theory)

Load more comments