ICFP 2022 was a good contest. It had a relatively interesting problem and possibly the lowest barrier to entry compared to earlier ICFP contests. It was time well spent.
This year's task is essentially a lossy compression problem, approximating target images with rectangles.
It actually works quite well for something like Mondrian's paintings (which has lots of rectangles), but for most other pictures it came up to be a blur. This is because this year's task requires minimizing a cost function that is the sum of the image's similarity plus the cost of operations, and the similarity function is well tuned such that additional operations only marginally improved similarity. By tweaking the similarity function, we can see how work done on this contest can actually produce something practical.
I approached this task in two steps:
I spent ~34 hours on this year's task, about 2 hours of it was spent on step 2 (coloring) and that bit remained roughly the same throughout the contest. Majority of the time was spent on step 1 (where to cut).
Coloring was done by traversing the nested shapes from root to leaf and assigning colors to the largest shape.
Or, it would have worked like this if I fixed all the bugs, which I probably didn't. A great time saving strategy is to never write any bugs in the first place, then I wouldn't need to test for them or fix them later. Well, this year I survived purely with assertions and didn't bother writing any tests, and honestly I had lots of bugs, but this year's contest was very lenient so I just rolled with it.
For the lightning round, two strategies were attempted:
Neither really worked because the code was buggy, so most of my lightning round submissions are actually just a single color that is the average of all pixels in target image.
For the full round, I tried a few different strategies:
I didn't make an interactive tool to solve the problems manually, so I didn't quite get the same hands-on experience that I had last year. I suspect it would have been fun to play with such a tool, but my experience with the two problems I did try to manually solve suggests that a manual tool probably wouldn't have helped.
Throughout the entire contest all the way up until the end, my program never produced the same cost values as the contest playground. I had fixed some of the more egregious bugs that caused wildly different cost values, but I never quite matched the cost values exactly. Most of them were in the same order of magnitude so it was kind of workable, but there were likely some solutions I missed because I had bugs in computing costs.
None of the initial or target images contained alpha values, but alpha values for the intermediate shapes might have helped to better approximate the gradients seen in the target images. I did not explore any of that because I didn't think I would be able to get the alpha composition code correct in time.
Actually, I didn't use the full contest spec -- the "merge" command I did not use at all, even though that would have made it cheaper to apply color to some of the shapes. The "swap" command I only implemented very late as a preprocessing step, and not integrated as a more generalized search step. These are things I might do if I had more time, but in 3 days, it wasn't quite worth the effort and risk.
This year's contest had roughly the lowest barrier to entry ever, where submitting even a blank solution could score me some points. I greatly appreciate task that are easy to start but has hidden depths that are difficult to master, so this year's task had just the right difficulty.
I also very much enjoy problems that are visual in nature, and had a good laugh over the many variations of Mona Lisa this year. Due to the low accuracy similarity function, most of the output came out to be a blur. I suspect the alpha constant for the similarity function was tuned to make deep searches not cost effective, and I can kind of appreciate the blocky aesthetics, so I would say this aspect of the task went rather well.
Overall, I would say the ~34 hours spent on this year's contest was time well spent. 34 hours is less than the ~43 hours I spent last year, mostly because there are fewer things I wanted to try this year, and it wasn't that the task was any way less engaging. I was actually worried about how this year would turn out due to scheduling problems, but it turned out OK and I had a good time.
Many thanks to the organizers for another great year!
Previous (2022-08-02): "Project Hail Mary" by Andy Weir
Next (2022-09-14): "No Game No Life" volume 11 by Kamiya Yuu