zoukankan      html  css  js  c++  java
  • 「网易官方」极客战记(codecombat)攻略-山峰-动物园管理员-zoo-keeper

    (点击图片进入关卡)

    保护雪人的笼子免遭食人魔的蓄意破坏。

    简介

    不要让食人魔打开盒子!

    默认代码

    # 保护笼子。
    # 放一个士兵在每一个 X 的位置
    points = []
    points[0] = {"x": 33, "y": 42}
    points[1] = {"x": 47, "y": 42}
    points[2] = {"x": 33, "y": 26}
    points[3] = {"x": 47, "y": 26}
    # 1.收集80金币。
    # 2.建造4个士兵。
    for i in range(4):
        hero.summon("soldier")

     

    # 3.派你的士兵到特定的位置上。
    while True:
        friends = hero.findFriends()
        for j in range(len(friends)):
            point = points[j]
            friend = friends[j]
            enemy = friend.findNearestEnemy()
            if enemy and enemy.team == "ogres" and friend.distanceTo(enemy) < 5:
                # 命令友方攻击。
                pass

     

            else:
                # 命令的朋友移动到特定点上。
                pass

    概览

    这个关卡显示了如何在 for 循环中使用一系列数字来访问多个相关数组。

    你还会看到如何让士兵保卫某个地点。

    收集硬币时,可以停在 80,因为每个士兵的费用为 20。

    动物园管理员解法

    # 保护笼子。
    # 放一个士兵在每一个 X 的位置
    points = []
    points[0] = {"x": 33, "y": 42}
    points[1] = {"x": 47, "y": 42}
    points[2] = {"x": 33, "y": 26}
    points[3] = {"x": 47, "y": 26}
    # 1.收集80金币。
    while hero.gold < 80:
        coin = hero.findNearest(hero.findItems())
        if coin:
            hero.move(coin.pos)
    # 2.建造4个士兵。
    for i in range(4):
        hero.summon("soldier")

     

    # 3.派你的士兵到特定的位置上。
    while True:
        friends = hero.findFriends()
        for j in range(len(friends)):
            point = points[j]
            friend = friends[j]
            enemy = friend.findNearestEnemy()
            if enemy and enemy.team == "ogres" and friend.distanceTo(enemy) < 5:
                # 命令友方攻击。
                hero.command(friend, "attack", enemy)

     

            else:
                # 命令的朋友移动到特定点上。
                hero.command(friend, "move", point)
     
    本攻略发于极客战记官方教学栏目,原文地址为:
  • 相关阅读:
    Flask学习笔记(3)-数据库迁移
    windows脚本批处理传输文件到linux脚本
    @TableLogic表逻辑处理注解(逻辑删除)
    使用thumbnailator给图片加水印
    Spring Cloud Stream 使用延迟消息实现定时任务(RabbitMQ)
    centos修改时区,同步时间
    定时清理缓存
    redis基本命令
    运行jar包shell脚本
    硬盘扩容后,建立新分区,将已有的目录挂载到新分区下
  • 原文地址:https://www.cnblogs.com/codecombat/p/13563393.html
Copyright © 2011-2022 走看看