# Help on Mixed Units tactics python

**URL:** <https://discourse.codecombat.com/t/help-on-mixed-units-tactics-python/8685>\
**Category:** Uncategorized\
**Created:** [August 18, 2016, 3:56pm UTC](https://discourse.codecombat.com/t/help-on-mixed-units-tactics-python/8685 "2016-08-18T15:56:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Awsomedude1](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@Awsomedude1](https://discourse.codecombat.com/u/Awsomedude1)\
**Post date:** [August 18, 2016, 3:56pm UTC](https://discourse.codecombat.com/t/help-on-mixed-units-tactics-python/8685/1 "2016-08-18T15:56:27Z")

</div>

Hi, I need help on Mixed Units tactics in python. Here is my code:

```python
# Practice using modulo to loop over an array

# Choose the mix and order of units you want to summon by populating this array:
summonTypes = ["soldier", "soldier", "soldier", "soldier", "archer", "archer", "archer", "archer"]
def summonTroops():
    # Use % to wrap around the summonTypes array based on len(self.built)
    #type = summonTypes[???]
    type = summonTypes[len(self.built) % len(summonTypes)]
def collectCoins():
    coin = hero.findNearest(hero.findEnemies())
    if coin:
        hero.move(coin.pos)
        
def commandTroops():
    friend = hero.findNearest(hero.findFriends())
    enemy = hero.findNearest(hero.findEnemies())
    if enemy and friend.type is not "palisade":
        if friend:
            hero.command(friend, "attack", enemy)
        
while True:
    summonTroops()
    collectCoins()
    commandTroops()

```

---

<div class="post-metadata">

**Author:** ![Harry\_the\_Wanderer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/harry_the_wanderer/32/5369_2.png) [@Harry\_the\_Wanderer](https://discourse.codecombat.com/u/Harry_the_Wanderer)\
**Post date:** [August 18, 2016, 6:03pm UTC](https://discourse.codecombat.com/t/help-on-mixed-units-tactics-python/8685/2 "2016-08-18T18:03:29Z")

</div>

@Awsomedude1

In your **summonTroops** you should be actually summoning a troop.

use:  
hero.summon()

* * *
In your \*\*commandTroops\*\* I don't see a loop iterating through all of the troops to command them to attack. You only command the closest troop.

---

<div class="post-metadata">

**Author:** ![Gabbek](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/gabbek/32/4419_2.png) [@Gabbek](https://discourse.codecombat.com/u/Gabbek)\
**Post date:** [August 18, 2016, 6:04pm UTC](https://discourse.codecombat.com/t/help-on-mixed-units-tactics-python/8685/3 "2016-08-18T18:04:22Z")

</div>

In your **summonTroops** you should either do something with the chosen type of unit or return it so that the other part of your code can do something with it.

Your **collectCoins** has some issues - have a close look at it.
