1.删除无用注释.2.增加路径显示

This commit is contained in:
facat 2020-10-24 15:57:44 +08:00
parent be69dc8697
commit e64cf48aa7
3 changed files with 6 additions and 10 deletions

View File

@ -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' }
}
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
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) {

View File

@ -1,8 +1,8 @@
module.exports = {
visualPath(my_pos, target_pos) {
// visualize the path
const path = PathFinder.search(my_pos, target_pos).path;
// let path = PathFinder.search(my_pos, target_pos).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' });
}
}

View File

@ -31,7 +31,7 @@ module.exports = {
return
}
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);
} else {
//find dropped source
@ -44,7 +44,7 @@ module.exports = {
} else {
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);
}
}
@ -52,14 +52,14 @@ module.exports = {
if (working_target.memory.role == 'builder') {
if (creep.store.energy > 0) {
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);
} else {
creep.drop(RESOURCE_ENERGY)
}
} else {
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);
}
}