# your goal is to protect Reynaldo# find the lowest-life Samurai Def lowesthealthpaladin (): lowesthealth = 99999 lowestfriend = none Friends = hero.findfriends () for friend in friends: if friend.type != "Paladin": continue if friend.health < lowesthealth and friend.health < friend.maxhealth: lowesthealth = friend.health lowestFriend = friend return lowestfrienddef commandpeasant (peasant): item = peasant.findnearestitem () if item: hero.command (peasant, " Move ", item.pos) Def commandgriffin (Griffin): target = Hero.findnearest (Hero.findbytype (' Warlock ')) if target: hero.command (griffin, "attack", target) else: target = griffin.findnearestenemy () Def commandPaladin (Paladin): # use function lowesthealthpaladin () Find the warrior with the lowest health value and cure # You can use paladin.cancast ("Heal") and command (paladin, "cast", "Heal", Target) # Samurai can also defend: command (paladin, "shield") # Don't forget they can also attack target = hero.findnearest (Hero.findbytype (' Warlock ')) if paladin.health&nbSp;< 250: hero.command (paladin, "shield") else: if paladin.cancast ("Heal"): healtarget = lowesthealthpaladin () # and healtarget and healtarget.health < 400: if healtarget: hero.command (paladin, "cast", "Heal", healtarget) else: target = paladin.findnearestenemy () &Nbsp; hero.command (paladin, "attack", target) def commandfriends (): # command your teammates friends = hero.findfriends () for friend in friends : if friend.type == "Peasant": commandpeasant (Friend) if friend.type == "Griffin-rider": Commandgriffin (Friend) if friend.type == "Paladin": commandpaladin (Friend) while true: commandfriends () # Summon Griffin Knight if hero.gold >= hero.costof ("Griffin-rider"): hero.summon ("Griffin-rider")
This article is from the "Ops" blog, please make sure to keep this source http://67263992.blog.51cto.com/3718090/1886941
Codecombat's grim determination