zoukankan      html  css  js  c++  java
  • 【网易官方】极客战记(codecombat)攻略-森林-有用的对手useful-competitors

    战场上满是硬币和毒药。 使用 peons 过滤毒药并收集硬币!

    简介

    检查物品的 type ,确保英雄没捡到 "poison" (毒药)。

    默认代码

    # 这片金币地中暗藏了致命的毒药。
    # 兽人正在进攻,而苦力尝试偷你的金币!
    while True:
        enemy = hero.findNearestEnemy()
        if enemy:
            # 只在敌人类型不是 "peon" 的时候攻击。
            if enemy.type != "peon":
                hero.attack(enemy)
            item = hero.findNearestItem()
            if item:
                # 只在物品的类型不是 "poison" 的时候收集。

     

            pass

    概览

    在这关你需要用到 非(not) 操作符筛选敌人和物品!

    非(not) 取一个值的逻辑相反 (logical inverse) 然后返回:

    # 非(Not) 在 Python 里写作: "not".
    hero.say(not False) # The hero says 'True'
    hero.say(not True) # The hero says 'False'

    在条件中使用可以这样:

    if not hero.isReady('cleave'):
        # 在 cleave 还在冷却时做点啥
    else:
        # Cleave 准备好啦。

    有用的对手 解法

    # 这片金币地中暗藏了致命的毒药。
    # 兽人正在进攻,而苦力尝试偷你的金币!
    while True:
        enemy = hero.findNearestEnemy()
        if enemy:
            # 只在敌人类型不是 "peon" 的时候攻击。
            if enemy.type != "peon":
                hero.attack(enemy)
            item = hero.findNearestItem()
            if item:
                # 只在物品的类型不是 "poison" 的时候收集。
                if item.type != "poison":
                    hero.moveXY(item.pos.x, item.pos.y)
     
     
    本攻略发于极客战记官方教学栏目,原文地址为:
  • 相关阅读:
    PHP 缓存技术
    redis雪崩
    【Redis】- 缓存击穿
    Memcache 与 Memcached 的区别
    数据库设计:范式与反范式
    Thinkphp5多数据库切换
    PHP 分布式集群中session共享问题以及session有效期的设置
    Nginx使用upstream实现动静分离
    rsync 服务快速部署手册
    tp5 为什么使用单例模式
  • 原文地址:https://www.cnblogs.com/codecombat/p/12360110.html
Copyright © 2011-2022 走看看