zoukankan      html  css  js  c++  java
  • 「网易官方」极客战记(codecombat)攻略-沙漠-沉睡的食人魔-while-ogres-were-sleeping

    (点击图片进入关卡)

    明智地选择你的目标。不要唤醒沉睡的食人魔。

    简介

    食人魔们正在睡觉,所以小心行事:

    首先,仅攻击 enemy.team 是 "ogres" 并且 enemy.health 小于 10 的食人魔。

    第二,只有当 coin.value 小于 5 且 hero.distanceTo(coin) 小于 7 时才收集硬币。

    第三,仅攻击 enemy.health 小于 10 且 enemy.type 是 "skeleton" 的骷髅怪。

    默认代码

    # 敌人在睡觉。这是捣蛋的最好时机!
    points = [{"x": 21, "y": 8}, {"x": 33, "y": 8},
        {"x": 45, "y": 8}, {"x": 57, "y": 8}, {"x": 68, "y": 8},
        {"x": 68, "y": 18}, {"x": 68, "y": 28},
        {"x": 68, "y": 38}, {"x": 68, "y": 48},
        {"x": 68, "y": 58}, {"x": 56, "y": 58},
        {"x": 44, "y": 58}, {"x": 32, "y": 58},
        {"x": 20, "y": 58}, {"x": 10, "y": 60}]

     

    pointIndex = 0;

     

    while pointIndex < len(points):
        point = points[pointIndex];
        hero.moveXY(point["x"], point["y"])
        enemy = hero.findNearestEnemy()
        coin = hero.findNearestItem()
        # 只有当敌人是“ogres”时才进攻。
        # 敌人的健康不到10

     

        # 收集硬币如果coin.value小于5
        # 其距离小于7

     

        # 只有当enemy.health不到10时才会攻击
        # 敌人的类型是“skeleton”。

     

        pointIndex += 1
    # 很快的获取最多的金币
    while True:
        coins = hero.findItems()
        coinIndex = 0

     

        # 把这个封装进循环里枚举所有的硬币

     

        coin = coins[coinIndex]
        # 金币价值3点。
        if coin.value == 3:
            # 只捡金币。

     

            pass

    概览

    食人魔正在沙漠中睡觉。 一个完美的突击时机!

    在他们的营地周围行进,仅击败特定敌人,且仅收集特定硬币。

    记住 < , > , <= , 和 >= 是比较两个元素并返回布尔值 true 或 false 的运算符。

    enemy = hero.findNearestEnemy()
    # 按照下面这样来读:
    # 如果距离小于10m,且敌人血量小于10!
    if hero.distanceTo(enemy) < 10 and enemy.health < 10:
        # 打败这个很弱的食人魔!

    沉睡的食人魔解法

    # 敌人在睡觉。这是捣蛋的最好时机!
    points = [{"x": 21, "y": 8}, {"x": 33, "y": 8},
        {"x": 45, "y": 8}, {"x": 57, "y": 8}, {"x": 68, "y": 8},
        {"x": 68, "y": 18}, {"x": 68, "y": 28},
        {"x": 68, "y": 38}, {"x": 68, "y": 48},
        {"x": 68, "y": 58}, {"x": 56, "y": 58},
        {"x": 44, "y": 58}, {"x": 32, "y": 58},
        {"x": 20, "y": 58}, {"x": 10, "y": 60}]

     

    pointIndex = 0;

     

    while pointIndex < len(points):
        point = points[pointIndex];
        hero.moveXY(point["x"], point["y"])
        enemy = hero.findNearestEnemy()
        coin = hero.findNearestItem()
        # 只有当敌人是“ogres”时才进攻。
        # 敌人的健康不到10
        if enemy.team=="ogres" and enemy.health<10:
            hero.attack(enemy)
        # 如果coin.value小于5,则收集一枚硬币
        # 其距离小于7
        if coin.value<5 and hero.distanceTo(coin)<7:
            hero.moveXY(coin.pos.x, coin.pos.y)
        # 只有在敌方健康少于10的情况下才能进行攻击
        # 并且敌人的类型是 "skeleton"
        if enemy.health<10 and enemy.type=="skeleton":
            hero.attack(enemy)
        pointIndex += 1
     
    本攻略发于极客战记官方教学栏目,原文地址为:
  • 相关阅读:
    你真的懂@ResponseBody和@RequestBody吗?
    Codeforces Beta Round #7 D. Palindrome Degree manacher算法+dp
    hihocoder #1032 : 最长回文子串 Manacher算法
    CSU 1808: 地铁 最短路
    UVALive 6912 Prime Switch 暴力枚举+贪心
    Codeforces Beta Round #9 (Div. 2 Only) D. How many trees? dp
    UVALive 6913 I Want That Cake 博弈+dp
    UVALive
    Codeforces Round #245 (Div. 1) B. Working out dp
    HDU 5834 Magic boy Bi Luo with his excited tree 树形dp
  • 原文地址:https://www.cnblogs.com/codecombat/p/13403507.html
Copyright © 2011-2022 走看看