Feedback: The Bane of Soldiers

Level summary

Goals: Detonate the robobombs; save most of the soldiers
Robobombs explode when they die or touch an enemy.
Split up your soldiers so that they don’t all get exploded together.

The concept of spreading out soldiers to avoid splash damage hasn’t been covered in detail in other levels so it is a good idea.
The level is quite easy and is passable with a simple strategy but that’s fine for an introductory level.
My strategy involved repeatedly commanding ally[0] to go right and the others to go left. Of course, many improvements can be made such as commanding the rightmost ally to go right instead of the first but my initial strategy still passed
There is potential for more complicated levels involving soldiers and robobombs (or catapult shots).

Edit: Another thing, the starting code contained some python syntax that I had never seen before:

for index, friend in enumerate(friends):
     # command soldiers

Some possibilities:

  • robobombs randomly approach from all sides
  • robobombs or catapult shots randomly fall from the sky above your soldiers
  • both of the above at the same time
  • fight robobombs mixed with other enemies
  • you control robobombs or artillery and need to hit clustered groups of enemies
1 Like

hmm this looks like a very interesting concept for a level like having to get soldiers id’s in a array then split those arrays

1 Like

Yup, good points about making more levels using more advanced robobomb scenarios. Want to make some? :slight_smile:

1 Like

I am having trouble figuring out how to pick out part of an index in the code. I can tell them all where to go, but not individuals…

loop:
    friends = self.findFriends()
    for index, friend in enumerate(friends, 0):
        # Use the index to decide where to command each soldier to move.
        for friend in friends:
            self.command(friend[0], "move", {'x':16,'y':16})
            self.command(friend, "move", {'x':50,'y':59})

the next to last line throws an error as I guess maybe I need to reference index or something. Any help just learning syntax to reference an index would be appreciated.

1 Like

I don’t even understand howto code it I know what I wan to do but the
loop:
friends = self.findFriends()
for index, friend in enumerate(friends):
# Use the index to decide where to command each soldier to move.

doesn’t make any sence with me could you explane what it does

1 Like

I had a hard time understanding how enumerate works based off what they give you. I watched some youtube and think I get it now. I beat this one by calling out the number or index assigned by the enumerate function in python. It is not elegant. I am sure someone can show a much better way. I will try in a moment. But I was able to just separate each friend by the index from enumerate. You could have created a list of positions and then assigned them matching the index’s from each I think would be less code.

1 Like

could i have some help? What did i do wrong?

loop:
friends = self.findFriends()
for index, friend in enumerate(friends, 0):
# Use the index to decide where to command each soldier to move.
for friend in friends:
self.command(friend[0], “move”, {‘x’:16,‘y’:16})
self.command(friend, “move”, {‘x’:50,‘y’:59})

1 Like

This type of code is confusing can you guys make a video on how to do the level but not only that but how the code works step by step so we can get a deeper understanding because I think me like many don’t have anybody to teach us this so we can fully understand it.:kissing_heart::innocent:

1 Like

Hello. Not quite sure if it just me, but this level is not allowing a python syntax. It is popping up only in what i believe is LUA. Advice?

1 Like

also lost…

I still don’t fully understand arrays or for loops

A video explanation and some practical application examples would be great!

1 Like

Have you worked through the Desert and early Mountain levels? Those should give you enough understanding of arrays to do this level.

Be sure to read the comments carefully, they usually provide you insight on what you need to write.

If all else fails, post your code so we can identify where the problem may be.

1 Like

I did but this one is really hard and it’s hard to understand without some pointing out.

1 Like

Please do not bring up untouched topics

1 Like
# Send the first soldier of the friends array towards the enemy.

how do I do this? Someone please help me! Thanks :grin:

1 Like

Also, I have already responded to your newly created topic and hope my advice can help you. :smiling_face:

(EDIT: Whoops…I didn’t mean to respond to _TD_RodYT…only meant to quote :sweat_smile:)

1 Like

I am from Russia and try to learn English.

I ran into the same problem but a little bit realizing that I want to do so:

while True:
    enemies = hero.findEnemies()
    enemy = hero.findNearest(enemies)
    friends = hero.findFriends()
    # Отправь первого солдата из массива друзей к врагу
    friend = friends[0]
    hero.command(friend, "attack", enemy)
    # i in range(1, n) начав индекс со второго элемента!
    for i in range(1, len(friends)):
        friend = friends[i]
        # Прикажи оставшимся солдатам ретироваться!
        hero.command(friend, "move", {"x":friend.pos.x - 5, "y":friend.pos.y - 1})

I’m sorry to have taken so long to reply. Please could you clarify your problem? I’m afraid I don’t understand at all.
Thanks
-Danny