I just started it an im confused
Can you show me your code?
Andrei
3 Likes
defendPoints = [{"x": 35, "y": 63},{"x": 61, "y": 63},{"x": 32, "y": 26},{"x": 64, "y": 26}]
summonTypes = ["soldier","soldier","soldier","soldier","archer","archer","archer","archer"]
# You start with 360 gold to build a mixture of soldiers and archers.
# self.built is an array of the troops you have built, ever.
# Here we use "len(self.built) % len(summonTypes)" to wrap around the summonTypes array
def summonTroops():
type = summonTypes[len(hero.built) % len(summonTypes)]
if hero.gold >= hero.costOf(type):
hero.summon(type)
def commandTroops():
friends = hero.findFriends()
for i in range(len(friends)):
friend = friends[i]
# Use % to wrap around defendPoints based on friendIndex
# Command your minion to defend the defendPoint
while True:
summonTroops()
commandTroops()
# Use % to wrap around defendPoints based on friendIndex
# Command your minion to defend the defendPoint
I don’t understand this
After this put something like this:
posd = defendPoints[i%len(defendPoints)]
And after that command your friend to defend the posd position.
Andrei
3 Likes
ok done that one whats next
Can I see the code?
Andrei
3 Likes
defendPoints = [{"x": 35, "y": 63},{"x": 61, "y": 63},{"x": 32, "y": 26},{"x": 64, "y": 26}]
summonTypes = ["soldier","soldier","soldier","soldier","archer","archer","archer","archer"]
# You start with 360 gold to build a mixture of soldiers and archers.
# self.built is an array of the troops you have built, ever.
# Here we use "len(self.built) % len(summonTypes)" to wrap around the summonTypes array
def summonTroops():
type = summonTypes[len(hero.built) % len(summonTypes)]
if hero.gold >= hero.costOf(type):
hero.summon(type)
def commandTroops():
friends = hero.findFriends()
for i in range(len(friends)):
friend = friends[i]
# Use % to wrap around defendPoints based on friendIndex
posd = defendPoints[i%len(defendPoints)]
# Command your minion to defend the defendPoint
while True:
summonTroops()
commandTroops()
1 Like
hello are you still there Andrei
1 Like
After this command the friend to defend the posd.
Andrei
3 Likes
Have you completed the level, @liam_cutts? If not, try to send me your recent code.
Andrei
3 Likes
no I haven’t done it yet
1 Like
Can I see your code?
Andrei
3 Likes
can you show me the code to make then defend
1 Like
Here it is:
hero.command(friend, "defend", posd)
Andrei
3 Likes
Have you completed the level?
Andrei
3 Likes
no my soldiers die still
no
Try resummiting, maybe it was just an unlucky seed.
Andrei
3 Likes
And can you delete this code because it is a working code?
Andrei
3 Likes
ok its done now thanks
1 Like