Finished #29. I’ll try to not make this post redundant with the 80 other posts above it
Small suggestions
Let me first start wtih a couple of small feedback points for CG
- Starter packs: this was my first contest where there was no started pack, it didn’t really matter for me but I do think that starter packs can be a huge help for new coders as it gives them a template to organize their code. Helps avoid ending up with a big much and let them work more on their ideas, while also to some extent learning about organization!
- Getting input files: an easy way to reproduce and debug a game seen on CG is (when both bots are deterministic) to just get the input file and use that as an input in their own IDE. Now to get the input, I just add a bunch of prints to error for all inputs, then copy the output and remove the extra information. When I want to reproduce the end of several games, this starts to be pretty annoying. A few easy suggestions (anyone of them would be great) are:
- Just have an option to download the input file as a text file, that would be awesome!
- Have an option to download exactly what was printed to the console without any alteration for new turns
- Have an option to only show what was printed to the console without any alteration for new turns so that it is at least very easy to copy paste that without having random numbers and/or text in the middle for new turns
Now as for my bot itself, I’ll focus on my algo and inferring some of the incomplete information as I thing everything else I could say has already been covered
Pathfinding algo
- Start by running a DFS for all of my pacs that do not have a move already assigned. Depth was 12 to 15 depending on my number of pacs alive. I did not allow to visit the same cell twice, except when I reached a dead end or a super pellet, in which case I just erase the visited history to make all cells accessible again
- Keep the one with the highest score and assign it a move based on its best path
- Propagate the effect of its movements to a copy of my game state. So for example, if it is supposed to go and grab a pellet next turn, completely discount that pellet. If it is supposed to grab one in 10 turns, still discard it but much less
- Repeat
Picking the pac with the highest score at each step meant I could not find optimal combinations of paths where none of the individual paths were optimal on their own. However, rerunning the DFS for all non-assigned pacs after assigning each pac meant that they still worked pretty well together. The other downside was that I had to run n! DFS where n is the number of pacs, just because the eval changed with each new assignment. I did not find a way to avoid this though (if anyone sees a way, please let me know!)
Regarding abilities, I initially switched if I knew an enemy pac could try and kill me next turn, but I then realized that at the top of the leaderboard no one ever does that. I even saw one guy who always assumed no one would try to kill his pacs if their cooldown was 0, so who actually used the speed boost right next to one of my stronger pacs… Anyway, at that point I removed switch altogether, and since I did not implement any sort of attacking for sure kills or preemptively defending against those, I just never switched.
I also saw a few people mention they only used their speed ability at (odd, odd) cells. I think this is slightly too aggressive and I had another approach: since I have an estimated path for > 10 cells, I just check if I ever step on the same cell during moves 0 and 2, 2 and 4, 4 and 6, 6 and 8 or 8 and 10 and if not, that means I can go ahead and use speed now without wasting one of its uses.
Inferring hidden information
This is what I spent most of my contest on. Unlike others, I don’t find incomplete information games annoying, on the contrary it is quite fun to come with more and more subtle ways to get an extra slither of information out. There is one caveat though: this is fun only if more information does give you more edge. Here unfortunately, after a certain point more information about pellets completely stopped helping. I think this was due to the nature of this game being more random. Thinking about it, I do believe this randomness (and therefore the leaderboard randomness) is due to the impossibility to always avoid “unlucky” encounters across a corner where you just die without being able to avoid it, so any decent bot can easily win a couple games against #1. This was an unfortunate feature of the game, but in my opinion was impossible to have been predicted by the creators so this is not a reproach in any way, just a fact.
Anyway, what made me jump to top 15 was the following relatively easy feature: whenever I see an opponent or a pellet that I know just disappeared (usually super pellets) and could have been eaten by only 1 opponent, I look for all possible paths this opponent pac could have taken since its last knows position, I then remove paths for which I know there currently still is a cell with a pallet on it, and I intersect the remaining paths to get all cells this enemy pac MUST have visited. This very often leaves you with only 1 possible path.
I then decided you could do better, and worked on adding memory of all cells at all time to remove even more paths. This is actually the exact same algorithm MSmits described in details so I won’t repeat what he wrote, but similarly to him this took me a while to finish and yielded no result, which was extremely frustrating. Retrospectively, we both should have acknowledged the randomness sooner, realized that given this getting 90 or 92% of the information would not have changed anything and moved on to try to mitigate the randomness more by better enemy tracking or to coding other features (my bot didn’t even have features such as sure kill detection which would have been helpful both for defense and offense, or super pellet allocation when I just hope the furthest pellet is in my DFS breadth length). While we wasted our time on this feature, we both slowly drifted down in the leaderboard as others worked on more useful things
Conclusion
I found this contest very entertaining, and I did learn a lot as well! A big thanks to the whole CG team for organizing it, and I am looking forward to the next one!