极客战记/codecombat-狩猎派对/hunting-party

2025-10-15 08:13:12

1、角色

2、装备

极客战记/codecombat-狩猎派对/hunting-party

3、目标

极客战记/codecombat-狩猎派对/hunting-party

极客战记/codecombat-狩猎派对/hunting-party

4、默认代码

极客战记/codecombat-狩猎派对/hunting-party

5、代码

# 命令你的部队向东移动,攻击任何看到的食人魔。

# 使用 for 循环和 findFriends方法。

# 你能在你的士兵上使用findNearestEnemy()来获取他们的而不是你的最近的敌人。

while True:

    friends = hero.findFriends()

    for j in range(len(friends)):

        friend = friends[j]

        if friend.type=="soldier":

            x=friend.pos.x+10

        elif friend.type=="archer":

            x=friend.pos.x+5   

        y=friend.pos.y

        enemy = friend.findNearestEnemy()

        if enemy:

            if friend.health<friend.maxHealth*0.5:

                x=13

                hero.command(friend, "move", {"x": x, "y": y})

                continue

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

        else:

            hero.command(friend, "move", {"x": x, "y": y})

极客战记/codecombat-狩猎派对/hunting-party

6、运行

极客战记/codecombat-狩猎派对/hunting-party

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢