1 Star 0 Fork 0

MaHe666/myScreepsCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
memory.init.js 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
MaHe666 提交于 2022-04-17 20:23 . 更新
const variable_homeSignal = require("variable.homeSignal");
const memory_Init = {
init:function (){
this.room_source_energyContainer()
this.room_mineral_mineralContainer()
},
room_source_energyContainer:function (){
let distance = Math.sqrt(5)
for (let r of variable_homeSignal.homeRooms){
let set = new Set();
for (let s of r.room.find(FIND_SOURCES)){
let data = {
sourceId:s.id,
containerId:''
}
let c = s.pos.findInRange(FIND_STRUCTURES,distance,{
filter: o => o.structureType == STRUCTURE_CONTAINER
})
if (c.length == 1){
data.containerId = c[0].id
set.add(data)
}
}
r.room.memory.energyAndEnergyContainer = Array.from(set)
}
},
room_mineral_mineralContainer:function (){
let distance = Math.sqrt(5)
for (let r of variable_homeSignal.homeRooms){
let set = new Set();
for (let m of r.room.find(FIND_MINERALS)){
let data = {
mineralId:m.id,
containerId: ''
}
let c = m.pos.findInRange(FIND_STRUCTURES,distance,{
filter: o => o.structureType == STRUCTURE_CONTAINER
})
if (c.length == 1){
data.containerId = c[0].id
set.add(data)
}
}
r.room.memory.mineralAndMineralContainer = Array.from(set)
}
}
}
module.exports = memory_Init
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mahe666/my-screeps-code.git
git@gitee.com:mahe666/my-screeps-code.git
mahe666
my-screeps-code
myScreepsCode
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385