zoukankan      html  css  js  c++  java
  • 【网易官方】极客战记(codecombat)攻略-森林-伪装者chameleons

    那些食人魔是伪装大师。

    简介

    食人魔躲在这个房间里。他们可以伪装成宝石或硬币。 要找到伪装的食人魔,你需要真正靠近物品。

    收集所有物品并在看到食人魔时保护自己。 使用最近的项目 pos , x 和 y 来找到移动的位置。

    默认代码

    # 食人魔伪装成了硬币或者宝石!
    while True:
        enemy = hero.findNearestEnemy()
        # 如果你看见了敌人-攻击它:

     

        item = hero.findNearestItem()
        # 如果你看见硬币或者宝石-移动到它的XY坐标:

    概览

    记住,项目有对象,它们有属性像 pos 。事实上, pos 也是一个对象,包含另外 2 个 * 属性像 x 和 y 。

    例如,如果你想找到朋友的头发长度和颜色:

    friend = hero.findNearestFriend();
    if friend:
        hair = friend.hair # Access the friend's hair property.
        hairLength = hair.size # Access the hair property's size property.
        hairColor = hair.color # Access the hair property's color property.
        hero.say("You have " + hairLength + " " + hairColor + " colored hair!")

    使用它来移动到各种硬币的 X 和 Y 位置!

    伪装者 解法

    # 食人魔伪装成了硬币或者宝石!
    while True:
        enemy = hero.findNearestEnemy()
        # 如果你看见了敌人-攻击它:
        if enemy:
            hero.attack(enemy)

     

        item = hero.findNearestItem()
        # 如果你看见硬币或者宝石-移动到它的XY坐标:
        if item:
            pos = item.pos
            hero.moveXY(pos.x, pos.y)
     
     
    本攻略发于极客战记官方教学栏目,原文地址为:
  • 相关阅读:
    Many Equal Substrings CF
    Seek the Name, Seek the Fame POJ
    人人都是好朋友(离散化 + 并查集)
    建设道路
    day_30
    day_29作业
    day_29
    day_28
    day_27
    day_26作业
  • 原文地址:https://www.cnblogs.com/codecombat/p/12321439.html
Copyright © 2011-2022 走看看