codecombat zero-sum

summonTypes = ["paladin","paladin","soldier","paladin"]

cummonTypes = ["archer"]

dummonTypes = ["griffin-rider"]

def lowestHealthPaladin():

    lowestHealth = 99999

    lowestFriend = None

    friends = hero.findFriends()

    for friend in friends:

        if friend.health < lowestHealth and friend.health < friend.maxHealth/1.5:

            if friend.type == "paladin":

                

                lowestHealth = friend.health

                lowestFriend = friend

    return lowestFriend

def commandPaladin(paladin):

    # 使用函数 lowestHealthPaladin() 找到生命值最低的武士,并治疗

    # 你能使用 paladin.canCast("heal") 和 command(paladin, "cast", "heal", target)

    # 武士也能防御:command(paladin, "shield")

    # 不要忘了他们还能攻击

    low = lowestHealthPaladin()

    paladins = hero.findByType("paladin")

    for paladin in paladins:

        if low:

            

            if paladin.canCast("heal"):

                if paladin.team == hero.team:

                    

                    hero.command(paladin, "cast", "heal", low)

            else:

                hero.command(low, "shield")

def commandFriends():

    # 指挥你的队友

    friends = hero.findFriends()

    for friend in friends:

        if friend.type == "paladin":

            commandPaladin(friend)

def summonTroops():

    # 用%取模来循环预设的征兵方案 len(self.built)

    type = summonTypes[len(hero.built) % len(summonTypes)]

    tcpe = cummonTypes[len(hero.built) % len(cummonTypes)]

    ucpe = dummonTypes[len(hero.built) % len(dummonTypes)]

    if hero.gold > hero.costOf(type):

        if hero.time < 90:

            hero.summon(type)

    if hero.time > 50:

        if hero.time < 65:

            if hero.gold > hero.costOf("archer"):

                hero.summon("archer")

    if hero.time > 100:

        if hero.gold > hero.costOf(ucpe):

            hero.summon(ucpe)

 

while True:

    item = hero.findNearestItem()

    enemy = hero.findNearestEnemy()

    enemies = hero.findEnemies()

    summonTroops()

    if item:

        hero.move(item.pos)

        if hero.isReady("jump"):

            hero.jumpTo(item.pos)

    friends = hero.findFriends()

    for friend in friends:

        if friend and friend.type != "cage":

            

            e = friend.findNearestEnemy()

            commandPaladin(friend)

            if friend.type != "yeti":

                if friend.type !="decoy":

                    

                    

                    if friend.type != "cage":

                        if friend.type != "peasant":

                            if e: 

                                if e.type != "cage":

                                    hero.command(friend, "attack", e)

                                    if friend.type == "archer":

                                            

                                        distance = friend.distanceTo(e)

                                        if distance < 5:

                                                hero.command(friend, "move", hero.pos)

                                        else:

                                            hero.command(friend, "attack", e)

                                else:

                                    if friend.type != "peasant":

                                        if friend.type != "paladin":

                                                hero.command(friend, "move", hero.pos)

                                        if friend.type == "paladin":

                                                hero.command(friend, "shield", hero)

                            else:

                                hero.command(friend, "defend", hero.pos)

                    if friend.type == "peasant":

                        sa = friend.findNearestItem()

                        if sa:

                            hero.command(friend, "move", sa.pos)

    # 你的英雄能收集金币并招募部队。

    # 在站场上,她也可以命令你的盟友。

    if hero.canCast("goldstorm"):

        hero.cast("goldstorm")

    if hero.isReady("reset-cooldown"):

        hero.resetCooldown("goldstorm")

    if hero.canCast("raise-dead"):

        corpses = hero.findCorpses()

        for b in corpses:

            c = hero.distanceTo(b)

            if c < 10:

                if hero.canCast("raise-dead"):

                    hero.cast("raise-dead")

    if hero.isReady("mana-blast"):

        if enemy:

            distance = hero.distanceTo(enemy)

            if distance < 10:

                hero.manaBlast()

 

 

ps(发挥首领之星的作用)

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值