Pender invited you to test on a series of trials. Can you pass? Try here:
I’ve finished it’s really good, to be honest, it’s not pretty easy.
Nice, I like this. I used a summonOrder with soldiers, then archers and griffins, then paladins, then peasants. With a cap peasant number of 3.
It’s fun to watch the battles.
Danny
Was very good. I used Grim Determination to help me with this and a few tweaks to suit the peasant. Overall, I am very impressed. How do you make your own levels?
In the level editor: https://codecombat.com/editor/level and click play your own level.
You can read this topic: [Guide] Level Editor (OLD)
Danny
def summonTroops():
# These are just an example. Feel free to use griffin riders and/or other units!
if hero.gold >= 40:
hero.summon("archer");
hero.summon("soldier")
def commandAS():
enemy = hero.findNearestEnemy()
archers = hero.findByType("archer")
soldiers = hero.findByType("soldier")
for archer in archers:
if enemy:
hero.command(archer, "attack", enemy)
else:
hero.command(archer, "move", Vector(36,30))
for soldier in soldiers:
if enemy:
hero.command(soldier, "attack", enemy)
else:
hero.command(soldier, "move", Vector(36,30))
def commandP():
item = peasant.findNearestItem()
peasant = hero.findNearest(hero.findByType("peasant"))
if item:
hero.command(peasant, "move", item.pos)
while True:
summonTroops()
peasant = hero.findNearest(hero.findByType("peasant"))
enemy = hero.findNearestEnemy()
archers = hero.findByType("archer")
soldiers = hero.findByType("soldier")
commandAS()
commandP()
# Iterate over all troops using a for loop. Make peasants collect coins. Combat troops fight.
It says try hero.findNearestItem()
Lydia
The peasant can’t find the nearest item if you haven’t defined peasant yet.
Did you finish the level with a free hero without casualties? Obviously i need to improve my code…
P.S.
Picture with the guys i didn’t know. I think we all be very happy to see them helping others in the forum. Congratulations!
Code
def summonTroops():
# These are just an example. Feel free to use griffin riders and/or other units!
if hero.gold >= 40:
hero.summon("archer");
hero.summon("soldier")
def commandAS():
enemy = hero.findNearestEnemy()
archers = hero.findByType("archer")
soldiers = hero.findByType("soldier")
for archer in archers:
if enemy:
hero.command(archer, "attack", enemy)
else:
hero.command(archer, "move", Vector(36,30))
for soldier in soldiers:
if enemy:
hero.command(soldier, "attack", enemy)
else:
hero.command(soldier, "move", Vector(36,30))
def commandP():
peasant = hero.findNearest(hero.findByType("peasant"))
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
while True:
summonTroops()
peasant = hero.findNearest(hero.findByType("peasant"))
enemy = hero.findNearestEnemy()
archers = hero.findByType("archer")
soldiers = hero.findByType("soldier")
commandAS()
commandP()
# Iterate over all troops using a for loop. Make peasants collect coins. Combat troops fight.
It runs smoothly for a while, but after that, it says
Lydia
Archers are pretty weak to shamans, as shaman energy balls can one-tap them. Have you tried griffin riders? They have ~150 HP and deal slightly more damage with double the cost. I think they might be able to survive without a single casualty with good tactics involved.
Thanks, I will try. I think placing paladins at the right spots will also be successful.
Sup3r_fly7291 is me.