Ended up in mid silver. Spent most of my time trying to grind out of bronze due to the fluctuation. It didn’t feel like beating the boss was enough, but eventually I got through.
The grand majority was spent debugging, especially ensuring efficiency of not going only 1 space if you have speed, but also ensuring that we acknowledge that said pellet inbetween is gone.
The three major parts involved are as follows:
Defensive switching:
I had thought of an idea to have a different tactic depending on how many pacs are spawned (2-3 pacs = win by killing them, 4-5 pacs it’s not worth the time so just devour pellets), but just ended up with a simple “oh, there’s a scissors within 5 squares of me, so I should become rock” and that took care of most situations.
A Pellet Map:
Like others mentioned, a map of pellets (since we get that nice grid to work with) can be made based on all the empty spaces, and once we see that pellet update it on the map. If we run over a square or see an enemy pac run over a square, remove that pellet. If we have speed or they have speed, remove all pellets 1 around them after doing calculations. If I had more motivation, I’d have implemented line of sight checking too, since we didn’t just have the knowledge of the visible pellets that weren’t there any more, we had to deduce it, but I didn’t bother with that.
The Pellet Finder
Obviously, this wasn’t the greatest as people had chess-engine-like searches, but I liked what I had done. Last time when I did this sort of thing, the first thing I controlled had priority, but that’s inefficient, especially for this, as pac 0 who was downtown would end up with priority and go for the big pellet while there’s a pac right next to it. The solution was to have a barrel of commands (since the order of what pac was commanded didn’t matter, this was easy to set up and have execute) and add to it when you find the nearest pellet. Pellets that we know exist (also easy to implement by just having the unknown ones start with a value of 0) were given a bit of priority since we know they’re there. Those with speed would try and target something at least 2 squares away, and if they had targetted something 1 square away, they were told to change their target.
Simple but effective. After adding to the barrel of commands what movement they wanted to do (speed and switch were also commands added), ie what pellet they targetted, the next pac was queried the same way. Beforehand, they just ignored pellets that were already targetted, but now they would compare their distance to the pellet to the other pac’s distance to the pellet, and if it’s closer, it would remove the other pac’s command from the command barrel and continue shuffling through pellets finding the closest one before making a command. This would go on for every pac until we went through each once, and then it would loop back through all unaccounted for pacs again and again until everyone had a command, and then just execute the commands.
Overall it was fun, though I personally am not a big fan of pac-man, but it was still lots of fun. I’m pumped and ready for the next challenge on the horizon!