ok im back (20 chars)
@JoPro_8000 pls come
uhhhhhhhhhhhhhh anybody on
I am post your new code now
huh I don’t get what your saying
Did you do what I said?
Lydia
my new code:
# Ogres are trying to take out your reindeer!
# Keep your archers back while summoning soldiers to attack.
def pickUpCoin():
# Collect coins.
item = hero.findNearestItem()
if item:
hero.move(item.pos)
pass
def summonTroops():
# Summon soldiers if you have the gold.
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
pass
# This function has an argument named soldier.
# Arguments are like variables.
# The value of an argument is determined when the function is called.
def commandSoldier():
friends = hero.findFriends()
for soldier in friends:
enemy = soldier.findNearestEnemy()
if enemy:
hero.command(soldier, "attack", enemy)
pass
# Write a commandArcher function to tell your archers what to do!
# It should take one argument that will represent the archer passed to the function when it's called.
# Archers should only attack enemies who are closer than 25 meters, otherwise, stay still.
def commandArcher():
friends = hero.findFriends()
for archer in friends:
enemy = archer.findNearestEnemy()
if enemy:
if hero.distanceTo(enemy) <= 25:
if friend.type == "archer":
hero.command(friend, "attack", enemy)
else:
hero.command(archer, "move", {'x':24, 'y':47})
pass
while True:
pickUpCoin()
summonTroops()
friends = hero.findFriends()
for friend in friends:
if friend.type == "soldier":
# This friend will be assigned to the variable soldier in commandSoldier
commandSoldier(friend)
elif friend.type == "archer":
# Be sure to command your archers.
commandArcher(friend)
pass
Make these changed
Lydia
I didn’t get what you were saying
Did you actually read it? If you did, you would know perfectly what to do
Lydia
uhh I read it like 10 times
you command archer thing should be like this
def commandArcher():
friends = hero.findByType("archer", hero.findFriends())
for friend in friends:
enemy = friend.findNearestEnemy()
if enemy:
if hero.distanceTo(enemy) <= 25:
if friend.type == "archer":
hero.command(friend, "attack", enemy)
else:
hero.command(archer, "move", {'x':24, 'y':47})
pass
I get that you need help but this topic now has 113 posts at some point you should be able to figure it out
It just doesn’t make sense tho
Oh and do you do python If yes do use use warrior? @Luke10
Looks here to help you for your CommandArcher() function.
I use python and yes I use warriors I never use rangers or wizards
so I should delete my entire commandArcher and add that?
yup this is just modified version.
@Luke10 can you help me too since I use warrior and python because milton use pender