{"by":"MCSP","descendants":172,"id":40740021,"kids":[40742709,40740870,40741268,40740545,40743261,40744324,40742114,40740438,40740482,40744822,40745404,40741856,40742974,40744697,40744921,40752571,40749179,40747729,40741026,40742530,40741131,40741363,40743873,40745444,40740571,40740603,40741232,40745298,40754186,40743692,40746583,40741091,40752236,40749776,40747192,40742253,40744258,40752213,40742749,40743870,40741115,40740575,40741174,40742698,40747913,40744297,40744852,40741858,40747921,40745936,40742344,40740587,40744344,40741976,40769381,40740199,40747152,40748317,40741591,40741552,40740511,40741774],"score":1054,"text":"This is the first iteration of a short game I’m making that tries to interactively explain some of my favorite math questions &#x2F; ideas. My goal is mostly to get the player curious and not necessarily to explain absolutely everything.<p>There were a lot of fun technical parts to building this:<p>- 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<p>- 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<p>- I use a simple backtracking algorithm to handle the live coloring of graphs<p>- I use turf.js’s polygonize function to handle finding polygons from line segments (very happy I didn’t have to implement this myself!)<p>- I wanted to make the game as mobile friendly as possible (don’t think I’ve nailed this quite yet)<p>There were also a few tradeoffs I made:<p>- 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<p>- 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”","time":1718898319,"title":"Show HN: I made a puzzle game that gently introduces my favorite math mysteries","type":"story","url":"https://www.rahulilango.com/coloring/"}