# The goal is to survive for 30 seconds, and keep the mines intact for at least 30 seconds.
def chooseStrategy():
enemies = hero.findEnemies()
# If you can summon a griffin-rider, return "griffin-rider"
# The goal is to survive for 30 seconds, and keep the mines intact for at least 30 seconds.
def chooseStrategy():
enemies = hero.findEnemies()
# If you can summon a griffin-rider, return "griffin-rider"
if hero.gold>= hero.costOf("griffin-rider"):
return "griffin-rider"
# If there is a fangrider on your side of the mines, return "fight-back"
enemy=hero.findByType("fangrider")
if enemy:
return "fight-back"
# Otherwise, return "collect-coins"
else:
return "collect-coins"
def commandAttack():
# Command your griffin riders to attack ogres.
friends = hero.findFriends()
friend = hero.findByType("griffin-rider")
if friend:
hero.command(friend, "attack", enemy)
pass
def pickUpCoin():
# Collect coins
pass
def heroAttack():
# Your hero should attack fang riders that cross the minefield.
pass
while True:
commandAttack()
strategy = chooseStrategy()
# Call a function, depending on what the current strategy is.
# If there is a fangrider on your side of the mines, return "fight-back"
# Otherwise, return "collect-coins"
def commandAttack():
# Command your griffin riders to attack ogres.
pass
def pickUpCoin():
# Collect coins
pass
def heroAttack():
# Your hero should attack fang riders that cross the minefield.
pass
while True:
commandAttack()
strategy = chooseStrategy()
# Call a function, depending on what the current strategy is.
First off, loop:
is not an useable function anymore. Second, the #8th line of your code has indented twice.
accidentally posted the wrong code whoops
All of your strategies cannot be defined as a string, and you did not mention them in your code. You have to define your strategy, like “griffin-rider”
Here is an example:
def griffin_rider():
griffin = hero.findByType("griffin-rider")
for griffin in griffins:
friendEnemy = griffin.findNearestEnemy()
if friendEnemy:
# And on with your code
while True:
griffin_rider()
friends = hero.findFriends() # Define again, griffin cannot find enemies alone
for friend in friends:
# Your action, remember to attack as well
# Tip, look for the best target, what is next to a fangrider?
alright ill try changing that
You defined chooseStrategy twice, try deleting one to avoid errors.
You also gotta write some code, instead of passing.
The return string is to help you define the next usage, but you should NOT use it itself, you still have to use the defination.