[Solved] A little stuck on Twins Power

@Sergi_Diaz_Alonso @Damian_Mesa_Munoz
I can see your problem. This code is a bit different from a similar level “Think Ahead”.
You need to create a variable that carries all the twins. Every time you find somebody who is a twin, push it into the variable. Then at the start of every for loop, check if the the twins are in the variable. Here is an example:

var twins = [];
var friends = hero.findFriends();
var iUnit = friends[0];
for(var a = 0; a < friends.length; a++) {
     var twin = twins[a];
     if (twin == iUnit) {
         toggleBreak = true;
     }
}
if (toggleBreak === true) {
    continue;
}

Side note:
Try to use hero.move(aRandomPosition) instead of hero.moveXY(randomNumberA, randomNumberB) That way you won’t move too fast as the brawler is kinda slow and also you can make sure to lead him to the beams by moving correspondingly to his x Position.

Actually, I code with Python, and I used to be stuck on this too.
But then I spotted the problem: you have to check if twin1 and twin2’s names are the same
if they aren’t then great but if they are then no
like this: if areTwins(f1, f2) and f1.id != f2.id:
that will solve it

Hi wm-revision-centre,

Welcome to the forum, and thanks for trying to help.

However the last posts on this topic were 9 months ago, and the people who were needing help are no longer active. Please try not to revive dead topics.

Thanks,

Jenny

2 Likes