# Strategic problems with my army

#1

Im playing the Clouddrip Brawl, where I have to summon many soldiers to attack many enemies. However I have found some problems along the way:

1.-My soldiers stop atacking after one kill, they just stand still. Then it is like I have to walk near them to revive them.
2.-My soldiers attack different enemies (many soldiers die, few enemies die). It would be much more effective if they all attack one single enemy.
3.-Sometimes, a soldier is attacking an enemy, enemy is not dead and soldier starts attacking another enemy.

Here is my code, thanks for the help:

loop:
enemies = self.findEnemies()
enemy = self.findNearest(enemies)
coins = self.findItems()
coin = self.findNearest(coins)
friends = self.findFriends()
friend = self.findNearest(friends)

if coin:
self.move(coin.pos)

if self.gold > 20:
self.summon("soldier")
if enemy:
self.command(friend, "attack", enemy)
if enemy:
self.command(friend, "attack", enemy)

#2

Just a few things I see:

1. You’re commanding “friend” which you’ve defined as your nearest friend. Try using a for loop to command all friends.

2. You’re telling your soldiers to attack the nearest enemy to you, which because you’re moving to collect coins will be changing constantly. That’s why they sometimes don’t finish off an enemy and move on to another one. You could set enemy as friend.findNearestEnemy() to get them to attack the enemy nearest to them.

3. Not really what you asked, but try collecting the higher value coins instead of just the nearest coin. More gold means more soldiers

#3

According to your code, your troops will only attack while you have more 20 than twenty gold. Try this:

if self.gold > 20:
self.summon("soldier")
if friends:
while enemy.health >= 0:
self.command(friend, "attack", enemy)