Immediately at the start, I knew this would be painful to simulate. I dislike a lot challenges where too much mathematics are involved and I do not have that much time to invest, had many other hobbies requesting my attention, and was only free for a single day, the last day of the tournament.
I tried to get collisions right using my Coders Strick Back engine, which is currently in the legend league.
Unfortunately, I couldn't get it right and a glitch about collisions prevented me from starting any reliable simulation at all, so I gave up and tried to work on the test submit that eventually made it to Gold league with just a few hours of code.
That didn't do good, at all. For some reasons, any behavior I thought to be smarter and got to work accurately (flipendo precise calculation with simple rebound for snaffle, petrificus on dangerous snaffles, etc) did much worse and ranked all the way to the bottom of the league (bottom 1%!) while the naive algorithm I beat the Gold boss could do better than 25% of the players.
My naïve strategy:
- Target the closest snaffle that wasn't targeted by the other wizard,
- If you have the snaffle, throw it in the direction of the goals.
- If you don't, if it is in front of the goal (if the straight line [wizard - snaffle]) and you have at least 20 mana, use Flipendo.
- If it is far behind you and you have 40 mana, use Accio
This naïve strategy only requires some line intersection formula to find out if you can Flipendo and goal, but you can find that formula easily on wikipedia and simplify it to your needs.