1.删除无用注释.2.增加路径显示
This commit is contained in:
parent
be69dc8697
commit
e64cf48aa7
4
main.js
4
main.js
|
|
@ -189,10 +189,6 @@ function assign_builder_to_controller() {
|
||||||
Memory.WorkingTarget[`RoomController_${Game.spawns['Spawn1'].room.controller.id}`] = { id: Game.spawns['Spawn1'].room.controller.id, working_creep_names: [], cate: 'ROOM_CONTROLLER' }
|
Memory.WorkingTarget[`RoomController_${Game.spawns['Spawn1'].room.controller.id}`] = { id: Game.spawns['Spawn1'].room.controller.id, working_creep_names: [], cate: 'ROOM_CONTROLLER' }
|
||||||
}
|
}
|
||||||
let room_controller_mem = _.filter(Memory.WorkingTarget, { cate: 'ROOM_CONTROLLER' })
|
let room_controller_mem = _.filter(Memory.WorkingTarget, { cate: 'ROOM_CONTROLLER' })
|
||||||
//先移除已经失效的creep
|
|
||||||
_.each(room_controller_mem, function (m) {
|
|
||||||
_.remove(m.working_creep_names, creep_name => !Game.creeps[creep_name])//如果一个creep已经不存在了,就从列表中移除
|
|
||||||
})
|
|
||||||
//寻找creep为0的room controller
|
//寻找creep为0的room controller
|
||||||
let room_controller_need_creep_array = _.filter(room_controller_mem, m => m.working_creep_names.length == 0 && m.cate=='ROOM_CONTROLLER')
|
let room_controller_need_creep_array = _.filter(room_controller_mem, m => m.working_creep_names.length == 0 && m.cate=='ROOM_CONTROLLER')
|
||||||
if (room_controller_need_creep_array.length > 0) {
|
if (room_controller_need_creep_array.length > 0) {
|
||||||
|
|
|
||||||
4
path.js
4
path.js
|
|
@ -1,8 +1,8 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
visualPath(my_pos, target_pos) {
|
visualPath(my_pos, target_pos) {
|
||||||
// visualize the path
|
// visualize the path
|
||||||
const path = PathFinder.search(my_pos, target_pos).path;
|
// let path = PathFinder.search(my_pos, target_pos).path;
|
||||||
// console.log(path)
|
// console.log(path)
|
||||||
Game.map.visual.poly(path, { stroke: '#ffffff', strokeWidth: .8, opacity: .2, lineStyle: 'dashed' });
|
// Game.map.visual.poly(path, { stroke: '#ffffff', strokeWidth: 8, opacity: .2, lineStyle: 'dashed' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -31,7 +31,7 @@ module.exports = {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (utils.distance(working_target_pos, my_pos) > 1.5) {//在附近就是1或者1.414
|
if (utils.distance(working_target_pos, my_pos) > 1.5) {//在附近就是1或者1.414
|
||||||
creep.moveTo(working_target_pos);
|
creep.moveTo(working_target_pos,{visualizePathStyle: {stroke: '#ffffff'}});
|
||||||
path.visualPath(creep.pos, working_target_pos);
|
path.visualPath(creep.pos, working_target_pos);
|
||||||
} else {
|
} else {
|
||||||
//find dropped source
|
//find dropped source
|
||||||
|
|
@ -44,7 +44,7 @@ module.exports = {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (creep.transfer(Game.spawns['Spawn1'], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
|
if (creep.transfer(Game.spawns['Spawn1'], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
|
||||||
creep.moveTo(Game.spawns['Spawn1']);
|
creep.moveTo(Game.spawns['Spawn1'],{visualizePathStyle: {stroke: '#ffffff'}});
|
||||||
path.visualPath(creep.pos, Game.spawns['Spawn1'].pos);
|
path.visualPath(creep.pos, Game.spawns['Spawn1'].pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -52,14 +52,14 @@ module.exports = {
|
||||||
if (working_target.memory.role == 'builder') {
|
if (working_target.memory.role == 'builder') {
|
||||||
if (creep.store.energy > 0) {
|
if (creep.store.energy > 0) {
|
||||||
if (utils.distance(working_target_pos, my_pos) > 1.5) {//在附近就是1或者1.414
|
if (utils.distance(working_target_pos, my_pos) > 1.5) {//在附近就是1或者1.414
|
||||||
creep.moveTo(working_target_pos);
|
creep.moveTo(working_target_pos,{visualizePathStyle: {stroke: '#ffffff'}});
|
||||||
path.visualPath(creep.pos, working_target_pos);
|
path.visualPath(creep.pos, working_target_pos);
|
||||||
} else {
|
} else {
|
||||||
creep.drop(RESOURCE_ENERGY)
|
creep.drop(RESOURCE_ENERGY)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (creep.withdraw(Game.spawns['Spawn1'], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
|
if (creep.withdraw(Game.spawns['Spawn1'], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
|
||||||
creep.moveTo(Game.spawns['Spawn1']);
|
creep.moveTo(Game.spawns['Spawn1'],{visualizePathStyle: {stroke: '#ffffff'}});
|
||||||
path.visualPath(creep.pos, Game.spawns['Spawn1'].pos);
|
path.visualPath(creep.pos, Game.spawns['Spawn1'].pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue