Making of LLemMings

Reduce hand-drawn points in editor

ChatGPT: Unsurprisingly, it returned Ramer–Douglas–Peucker algorithm.


>>> Prompt:
Give me an algorithm and javascript code to simplify/reduce drawn coordinates
like the one below to use less points:

"points": [ { "x": 581, "y": 514 }, { "x": 584, "y": 512 }, { "x": 586, "y": 510 },
{ "x": 587, "y": 509 }, { "x": 590, "y": 508 }, { "x": 591, "y": 507 }, { "x": 592, "y": 506 },
{ "x": 595, "y": 506 }, { "x": 596, "y": 505 }, { "x": 598, "y": 505 }, { "x": 599, "y": 505 },
{ "x": 601, "y": 504 }, { "x": 602, "y": 504 }, { "x": 603, "y": 504 }, { "x": 605, "y": 504 }

>>> Human note: There is really no need for the _really_ high resolution of hand-drawn points. This will reduce the length of those arrays drastically and making hand-drawing a more viable alternative when editing levels.