AoC 2019 D13: Care Package
| Problem statement | Source code | Tags: IntcodeArcade game
← Previous Back to AoC Index Next →
Part 1
For part 1, we just run to completion and pop all outputs:
Part 2
Now, building on day 11, the Intcode program is interactive but produces many outputs at a time, so we cannot use a fixed number of run_until_output() calls. Instead, I added a run_until_input() method that runs until an input is needed, at which point we are certain that all outputs have been produced.
Initially, I thought about just playing the game myself, but it turned out to be a quite tedious process. Reddit wisdom suggested two ways: (1) always move the paddle towards the ball, or (2) hack the memory to replace the paddle's row with walls. I implemented (1) since it felt more satisfying.
I still kept my visualization logic though, and it was fun to watch the AI play the game:

(One complaint: I didn't understand from the problem statement that each time only the diff is output, so at first I rendered the entire screen each time and wondered why the blocks disappeared!)