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)
     
    本攻略发于极客战记官方教学栏目,原文地址为:
  • 相关阅读:
    Thinkphp5 对接百度云对象存储 BOS (上传、删除)
    php 删除富文本编辑器保存内容中的其他代码(保留中文)
    ffmreg thinkphp 控制器 获取音频视频详细信息(获取时长)
    selenium+testng+java+poi进行excel的数据参数化
    linux中磁盘配额管理
    linux中挂载和卸载文件系统
    linux中vi编辑器的练习
    Linux基础命令
    Nginx流量复制
    Python脚本
  • 原文地址:https://www.cnblogs.com/codecombat/p/13563393.html
Copyright © 2011-2022 走看看