def chooseStrategy():
enemy = hero.findNearestEnemy()
# If you can summon a griffin-rider, return "griffin-rider"
if hero.gold >= hero.costOf("griffin-rider"):
hero.summon("griffin-rider")
return "griffin-rider"
# If there is a fangrider on your side of the mines, return "fight-back"
if enemy and enemy.type is "fangrider" and enemy.pos.x < 37:
return "fight-back"
# Otherwise, return "collect-coins"
else:
return "collect-coins"
def commandAttack():
# Command your griffin riders to attack ogres.
friends = hero.findFriends()
enemy = hero.findNearestEnemy()
for friend in friends:
if enemy and friend:
hero.command(friend, "attack", enemy)
def pickUpCoin():
# Collect coins
item = hero.findNearestItem()
if item:
hero.move(item.pos)
def heroAttack():
fang = hero.findByType("fangrider")
enemy = hero.findNearest(fang)
# Your hero should attack fang riders that cross the minefield.
eX = enemy.pos.x
if enemy.type == "fangrider" and eX < 25:
hero.attack(enemy)
while True:
strategy = chooseStrategy()
# Call a function, depending on what the current strategy is.
if strategy == "griffin-rider":
commandAttack()
elif strategy == "fight-back":
heroAttack()
elif strategy == "collect-coins":
pickUpCoin()
def heroAttack():
fang = hero.findByType("fangrider")
enemy = hero.findNearest(fang)
# Your hero should attack fang riders that cross the minefield.
eX = enemy.pos.x
if enemy.type == "fangrider" and eX < 25:
hero.attack(enemy)
def chooseStrategy():
enemy = hero.findNearestEnemy()
# If you can summon a griffin-rider, return "griffin-rider"
if hero.gold >= hero.costOf("griffin-rider"):
hero.summon("griffin-rider")
return "griffin-rider"
# If there is a fangrider on your side of the mines, return "fight-back"
if enemy and enemy.type is "fangrider":
return "fight-back"
# Otherwise, return "collect-coins"
else:
return "collect-coins"
def commandAttack():
# Command your griffin riders to attack ogres.
friends = hero.findFriends()
enemy = hero.findNearestEnemy()
for friend in friends:
if enemy and friend:
hero.command(friend, "attack", enemy)
def pickUpCoin():
# Collect coins
item = hero.findNearestItem()
if item:
hero.move(item.pos)
def heroAttack():
fang = hero.findByType("fangrider")
enemy = hero.findNearest(fang)
# Your hero should attack fang riders that cross the minefield.
eX = enemy.pos.x
if enemy.type == "fangrider" and eX < 25:
hero.attack(enemy)
while True:
strategy = chooseStrategy()
# Call a function, depending on what the current strategy is.
if strategy == "griffin-rider":
commandAttack()
elif strategy == "fight-back":
heroAttack()
elif strategy == "collect-coins":
pickUpCoin()
but it still doesn’t work, the problem I think is something with the commanding though