I have been trying some of the hard puzzles and am having trouble with the puzzles that require enemy bunching (such as Thor vs Giants and Code vs Zombies). I was just hoping that someone would be able to share some good sources and tutorials that I could have look at. Also any sources that would help me learn more advanced algorithms and principles needed for the harder puzzles would be much appreciated
I also realize that the answer to my problems may be to learn how to write more “general” algorithms instead of hard coding strategies, a source on how to learn this would be amazing
I think that you need to focus about learning how barycenter works (here a french description of it). If you’re not french, just look it up on google and you’ll have a good start to calculate where is the centerpoint of all those giants
Thanks for your reply @CvxFous
But I have looked at a few sources and dont quite understand. For bodies of no (or uniform and equal) mass would this not just be the average co-ordinate ((sum of X, sum of Y)/number of giants)? if so I have already implemented this in Thor vs Giants and it only lets me achieve a 50% score.
Oh and @Naity, I understand and it is ok
You have many many possible appoaches for a problem like this. And it will be hard to explain all in details but we can give you some hints.
Bruteforce
It is how i have solved Thor vs Giants. I just bruteforce all possibilities for the next 5 turns and i keep the best solution. You don’t have to how to bunch giants or something like that. Just do the best solution for the next 5 turns. But i would be pretty hard to do that in Code Vs Zombie since you have too many possibilities for just one turn.
Monte Carlo
It’s a little like bruteforce but you use that when you can’t test all possibilities because you don’t have the time for that. You test random solutions for 100ms (or more if you have the time) and you keep the best solution. It works pretty well for Code Vs Zombie (i’m pretty sure that the strategy of all the top 10 of the puzzle, including me). It could works for Thor vs Giants too. Just run random solutions for the next 10 turns and keep the best.
Heuristic
An heuristic strategy is a formula/algorithm which the result is “if you do that for this turns, you will win”. That’s where the link of CvxFous is useful. But a working heuristic is sometime hard to code. For Thor Vs Giants for example, you have to know when you can strike or not. Because if you waste a strike on too less giants, you will lose after.
Thanks for your reply @Magus
I do find this very helpful. I assume you mean that I should take these approaches by implementing game trees, minimax, alpha-beta and progressive deepening (things I all just found on Google and know very little about ). If so could you please give me any good sources to learn about those? I have been searching myself but cant seem to find ones explaining the implementation as well as the theory.
Thanks again
The first time i implemented minimax and alphabeta was for CodingGame (my current works doesn’t require at all to know such algorithms since i’m a web developper).
I used the pseudo code on wikipedia for both:
For progressive deepening i don’t know a pseudo code out there sorry.