# \[SOLVED\] Need help with Humantron

**URL:** <https://discourse.codecombat.com/t/solved-need-help-with-humantron/21003>\
**Category:** Level Help\
**Created:** [April 15, 2020, 5:50pm UTC](https://discourse.codecombat.com/t/solved-need-help-with-humantron/21003 "2020-04-15T17:50:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ry4n\_17](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ry4n_17/32/11794_2.png) [@Ry4n\_17](https://discourse.codecombat.com/u/Ry4n_17)\
**Post date:** [April 15, 2020, 5:50pm UTC](https://discourse.codecombat.com/t/solved-need-help-with-humantron/21003/1 "2020-04-15T17:50:59Z")

</div>

```python
# Form the rectangle of units around the peasant.
# You need 2 archers and 2 soldiers.

# This function can be helpful.
def summonAndSend(type, x, y):
    hero.summon(type)
    unit = hero.built[len(hero.built)-1]
    hero.command(unit, "move", {"x": x, "y": y})

# The rectangle should be formed around the peasant.
centerUnit = hero.findNearest(hero.findFriends())
# It's the center of the rectangle.
center = centerUnit.pos
# Also you need the height and width.
rectWidth = centerUnit.rectWidth
rectHeight = centerUnit.rectHeight

# First "soldier" to the left bottom corner of the rectangle.
leftBottomX = center.x - rectWidth / 2
leftBottomY = center.y - rectHeight / 2
summonAndSend("soldier", leftBottomX, leftBottomY)

# An "archer" to the left top corner.
leftTopX = center.x - rectWidth / 2
leftTopY = center.y + rectHeight / 2
summonAndSend("archer", leftTopX, leftTopY)

# Summon and send a "soldier" to the right top corner.
rightTopX = center.x - rectWidth / 2
rightTopY = center.y - rectHeight / 2
summonAndSend("soldier", rightTopX, rightTopY)
# Summon and send an "archer" to the right bottom corner.
rightBottomX = center.x - rectWidth / 2
rightBottomY = center.y - rectHeight / 2
summonAndSend("archer", rightBottomX, rightBottomY)
# Now hide or fight.
enemy = hero.findNearestEnemy()
if enemy:
    hero.attack(enemy)

```

dont understand whats wrong, no error at all just dosent work

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [April 15, 2020, 6:22pm UTC](https://discourse.codecombat.com/t/solved-need-help-with-humantron/21003/2 "2020-04-15T18:22:49Z")

</div>

Your code looks good, except, have you tried the other hint provided in the final comment?

```python
# Now hide or fight.

```

You’ve already tried fighting…

---

<div class="post-metadata">

**Author:** ![Ry4n\_17](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ry4n_17/32/11794_2.png) [@Ry4n\_17](https://discourse.codecombat.com/u/Ry4n_17)\
**Post date:** [April 16, 2020, 2:23pm UTC](https://discourse.codecombat.com/t/solved-need-help-with-humantron/21003/3 "2020-04-16T14:23:12Z")

</div>

But my soldiers dont form right the archers are good but my soldiers both of them go to bottom left

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [April 16, 2020, 2:55pm UTC](https://discourse.codecombat.com/t/solved-need-help-with-humantron/21003/4 "2020-04-16T14:55:55Z")

</div>

Aha…sneaky. Lines 29 & 30 and 33 & 34…your addition and subtraction is a little off.

---

<div class="post-metadata">

**Author:** ![Ry4n\_17](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ry4n_17/32/11794_2.png) [@Ry4n\_17](https://discourse.codecombat.com/u/Ry4n_17)\
**Post date:** [April 16, 2020, 10:36pm UTC](https://discourse.codecombat.com/t/solved-need-help-with-humantron/21003/5 "2020-04-16T22:36:29Z")

</div>

Omg im so close just about to solve it!

---

<div class="post-metadata">

**Author:** ![Ry4n\_17](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ry4n_17/32/11794_2.png) [@Ry4n\_17](https://discourse.codecombat.com/u/Ry4n_17)\
**Post date:** [April 16, 2020, 10:41pm UTC](https://discourse.codecombat.com/t/solved-need-help-with-humantron/21003/6 "2020-04-16T22:41:37Z")

</div>

```python
# Form the rectangle of units around the peasant.
# You need 2 archers and 2 soldiers.

# This function can be helpful.
def summonAndSend(type, x, y):
    hero.summon(type)
    unit = hero.built[len(hero.built)-1]
    hero.command(unit, "move", {"x": x, "y": y})

# The rectangle should be formed around the peasant.
centerUnit = hero.findNearest(hero.findFriends())
# It's the center of the rectangle.
center = centerUnit.pos
# Also you need the height and width.
rectWidth = centerUnit.rectWidth
rectHeight = centerUnit.rectHeight

# First "soldier" to the left bottom corner of the rectangle.
leftBottomX = center.x - rectWidth / 2
leftBottomY = center.y - rectHeight / 2
summonAndSend("soldier", leftBottomX, leftBottomY)

# An "archer" to the left top corner.
leftTopX = center.x - rectWidth / 2
leftTopY = center.y + rectHeight / 2
summonAndSend("archer", leftTopX, leftTopY)

# Summon and send a "soldier" to the right top corner.
rightTopX = center.x - rectWidth / -2
rightTopY = center.y - rectHeight / -2
summonAndSend("soldier", rightTopX, rightTopY)
# Summon and send an "archer" to the right bottom corner.
rightBottomX = center.x - rectWidth / -2
rightBottomY = center.y - rectHeight / 2
summonAndSend("archer", rightBottomX, rightBottomY)
# Now hide or fight.
enemy = hero.findNearestEnemy()
if enemy:
    hero.attack(enemy)

```

the code works each soldier and archer goes to its place… BUT either the big human dies or i die what can i do

---

<div class="post-metadata">

**Author:** ![brooksy125](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/brooksy125/32/9966_2.png) [@brooksy125](https://discourse.codecombat.com/u/brooksy125)\
**Post date:** [April 17, 2020, 2:21am UTC](https://discourse.codecombat.com/t/solved-need-help-with-humantron/21003/7 "2020-04-17T02:21:07Z")

</div>

There are different levels of difficulty when you hit the submit button. Try to submit a few times and you might get a seed that works.

Otherwise, you need to get better armor and weapons to give your hero a better chance. Also, consider retreating if you heroes health starts to get low.

---

<div class="post-metadata">

**Author:** ![Ry4n\_17](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ry4n_17/32/11794_2.png) [@Ry4n\_17](https://discourse.codecombat.com/u/Ry4n_17)\
**Post date:** [April 17, 2020, 2:56pm UTC](https://discourse.codecombat.com/t/solved-need-help-with-humantron/21003/8 "2020-04-17T14:56:47Z")

</div>

thanks i just solved it!
