while True:
item = hero.findNearestItem()
if item:
hero.move(item.pos)
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
for friend in hero.findFriends():
if friend.type == "soldier":
enemy = friend.findNearestEnemy()
# Careful! If your soldiers are defeated, a warlock will appear!
# Если нет, прикажи следовать в правую часть карты.
if (enemy):
hero.command(friend, "attack", enemy)
else:
hero.command(friend, "move", {'x': 69, 'y': 37})