# Enemy Bunching and Harder Puzzles

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

2 Likes

I am slowly reaching your point (not there yet, but soooooon), and I am interested to know the answer.

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

Sorry, couldnâ€™t not. From back in terminale, and now there is even a player calld Barry (with one r too much)

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.

5 Likes

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.

1 Like

Thanks again for the reply
The links are quite helpful and I have also stumbled upon a few YouTube videos that helped very much

CS 61B Lecture 16: Game Trees
CS 61B Lecture 17: Encapsulation - Havent watched it yet but it is the follow up to the very helpful Lecture 16
Search: Games, Minimax, and Alpha-Beta