Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Interactive intro to 4 color theorem, P vs NP, zero knowledge (rahulilango.com)
2 points by MCSP on June 18, 2024 | hide | past | favorite
This is the first iteration of a short game I’m making that tries to interactively explain some of my favorite questions / ideas in math! My goal is to get the player curious about the concepts and not necessarily to explain absolutely everything.

There were a lot of fun technical parts to building this:

- For implementation reasons, its 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 lines (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 an 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 data

- 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)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: