[Official] Netease Wars geeks (codecombat) Raiders - Forest - gold dust coincrumbs

 

Storage room filled with treasure, traps, and a quick orc guards.

Brief introduction

Can you escape from the storage room was not the ogre in the case of the guards caught? Follow the trail of coins.

Check the enemy like a 'type', like, you can check the 'item' position or 'pos'. You can even find the x and y coordinates 'item of the pos'.

When you click "Submit" maze changes. Using the location of the item instead of hard-coded coordinates.

The default code

# Follow the trajectory of the coin came to a red X export
while True:
    # You can find the nearest enemy.
    item = hero.findNearestItem()
    if item:
        # This will pos items, that is, coordinates stored in a variable.
        itemPosition = item.pos
        # The X and Y coordinates of objects into variables.
        itemX = itemPosition.x
        Items = itemPosition.y
        # Now, moving XY moving to Project X and Project Y:

Overview

Your new glasses comes findNearestItem methods that you can use to make your hero to find gold in the vicinity of (gem what can be), but the job was a hero in the field of view.

You can move to a place like this article:

item = hero.findNearestItem()
if item:
    position = item.pos
    x = position.x
    y = position.y
    hero.moveXY(x, y)

每个物品都是一个 对象 (object),对象是一种数据类型, 就像字符串 或者 数字。对象包含了其他的数据,我们称之为 属性 (property).

每个物品 (以及单元) 对象都有一个 pos 属性,代表它的位置。 而每个 pos 本身也是一个对象,拥有 x 和 y 属性,这些可以用于 moveXY 和 buildXY 。

金币屑 解法

# 跟随硬币的轨迹来到红色 X 标记的出口
while True:
    # 这能找到最近的敌人。
    item = hero.findNearestItem()
    if item:
        # 这将物品的 pos,就是坐标,存储在变量中。
        itemPosition = item.pos
        # 将物品的 X 和 Y 坐标放进变量。
        itemX = itemPosition.x
        itemY = itemPosition.y
        # 现在,使用移动XY移动到项目X和项目Y:
        hero.moveXY(itemX, itemY)
 
 
本攻略发于极客战记官方教学栏目,原文地址为:

Guess you like

Origin www.cnblogs.com/codecombat/p/12306275.html