极客战记/codecombat-狩猎派对/hunting-party
1、角色
2、装备

3、目标


4、默认代码

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})

6、运行

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