【问题标题】:How to find all swamp squares in a screeps room?如何在 screeps 房间中找到所有沼泽方块?
【发布时间】:2022-03-24 09:20:38
【问题描述】:

似乎只有两种类型的地形(到目前为止),平原和沼泽。除了对地图上的每个方格使用Room.lookAt(x,y) 之外,还有其他方法可以找到所有沼泽方格吗?

【问题讨论】:

    标签: javascript screeps


    【解决方案1】:

    您可以像这样使用Room.lookForAtArea 方法:

    var terrain = creep.room.lookForAtArea('terrain', 0, 0, 49, 49);
    terrain[5][10] == 'plain'; // tile at y=5 x=10 is plain land
    terrain[25][40] == 'swamp'; // tile at y=25 x=40 is a swamp
    

    【讨论】:

      【解决方案2】:

      game docs 没有提及任何具体内容。在我看来,您需要遍历 50x50 矩阵(地图上的每个正方形)并将数据存储在 Memory 中,您可以稍后通过 filter 来形成沼泽瓷砖的集合。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-09-17
        • 2018-09-26
        • 1970-01-01
        • 2010-10-28
        • 1970-01-01
        • 1970-01-01
        • 2017-06-02
        • 2017-03-21
        相关资源
        最近更新 更多