Power Of Thor - Episode 2 - Puzzle discussion

Do you have a check to STRIKE if you cannot move anywhere?

1 Like

Yes, I do.
I suspect my problem was when more than 1 giant threated me when I move (no WAIT or STRIKE). But Iā€™ve never seen this in a test case. So this wild guess and some extra checks that look more like dirty plugs work for now. It validates 100%.
If I had better possiblities to debug Iā€™d refactor it a lot. But as of now Iā€™m afraid Iā€™ll just break the code if I try.
Well you can check how bad it is since itā€™s published now :smiley:
Thanks for your thoughts and help!

1 Like

Solved it!
My solution is quite simple:

  • Strike if all giants are in range or if I donā€™t have a choice
  • Choose move depending on number of giants in range and distance to center of giants (+ donā€™t stay on same line/column as the first giant to avoid the last edge cases)
1 Like

My solution is rather simple as well, Iā€™m not even computing centroid.
Just move to position where you get

  1. As far as possible from closest giant
  2. As close as possible to farthest giant
  3. As close as possible to middle of the board

So Iā€™ll simply get farthest and closest giant (relative to thor) as close as possible to each other
This solution is as bad as solutions of others, because you canā€™t exactly predict movements of giants.

1 Like

Ah, got it at last. Very satisfying. :smiley:

The observation that helped me solve the ā€œqueuedā€ cases is that the giants will naturally clump up, you just have to give them the opportunity to do so! I had Thor walk over to the nearest giant and lead it on a merry chase until Thor was trapped or all giants were in range.

Without giving away too much (I hope): if the giants are clumped along axis a, lead them along axis b.

how do you get the position of the monsters

Their positions are given to you every turn.

Hi there,
I do an emergency strike if there is an intersection between the set of giantā€™s positions and thors (8-fields) neighbourhood, but this usually doesnā€™t save him.
Does anybody has an idea why ?

Just for the last caseā€¦

count = 0

while True:

if count < 11:

    print("E")

    count += 1

elif count < 18:

    print("SE")

    count += 1

else:

    print("STRIKE")

Fought with this for a good while, but finally got it. The discussion here was very helpful.

My solution was basically:

Check what moves donā€™t get Thor too close to any giants.
Check what moves brings the most amount of giants closer to Thor.
Pick the move that doesnā€™t get Thor too close to any giants, but closer to most possible giants, while not moving out of the playing field.
If there are several moves that are equally good pick the one that goes closest to the center.
If already at the center just take the first ā€œbestā€ move.
And if unable to find a valid move then strike.

1 Like

Queuing, 1 strike is very hard

If anyone is having trouble with the last test and already tried everything described here, make sure youā€™re using the Chebyshev distance, not Manhattan or Cartesian.

Not sure if those are the exact values, yet it seems that PI20/3 (27Ā°) and PI20/7 (63Ā°) are more accurate thresholds. I certainly found 28.xĀ° to be in the ā€œdiagonalā€ category.

So important. I donā€™t understand why the documentation hasnā€™t been updated yet, since itā€™s clearly wrong.

my solution
barycenter
and if an ennemy closest.
move on the new position the closest calculated barycenter and if 2 choice take the closest half axis.