From ec14f37ace7cb4a6994484a32b2be5f09bf34ba2 Mon Sep 17 00:00:00 2001 From: Aaron Veden Date: Sat, 9 Mar 2019 19:57:58 -0800 Subject: [PATCH] investigate new flee --- control.lua | 30 +++++++++++++++++++----------- libs/ChunkProcessor.lua | 7 ------- libs/SquadDefense.lua | 4 ++-- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/control.lua b/control.lua index 5660b98..2faf699 100755 --- a/control.lua +++ b/control.lua @@ -17,9 +17,7 @@ local interop = require("libs/Interop") local tests = require("tests") local chunkUtils = require("libs/ChunkUtils") local upgrade = require("Upgrade") --- local mathUtils = require("libs/MathUtils") local config = require("config") --- local stringUtils = require("StringUtils") -- constants @@ -27,10 +25,8 @@ local TRIPLE_CHUNK_SIZE = constants.TRIPLE_CHUNK_SIZE local INTERVAL_LOGIC = constants.INTERVAL_LOGIC local INTERVAL_PLAYER_PROCESS = constants.INTERVAL_PLAYER_PROCESS local INTERVAL_MAP_PROCESS = constants.INTERVAL_MAP_PROCESS --- local INTERVAL_CHUNK = constants.INTERVAL_CHUNK local INTERVAL_SCAN = constants.INTERVAL_SCAN local INTERVAL_SQUAD = constants.INTERVAL_SQUAD --- local INTERVAL_SPAWNER = constants.INTERVAL_SPAWNER local PROCESS_QUEUE_SIZE = constants.PROCESS_QUEUE_SIZE @@ -50,6 +46,10 @@ local DEFINES_COMMAND_GROUP = defines.command.group local DEFINES_COMMAND_BUILD_BASE = defines.command.build_base local DEFINES_COMMAND_ATTACK_AREA = defines.command.attack_area local DEFINES_COMMAND_GO_TO_LOCATION = defines.command.go_to_location +local DEFINES_COMMMAD_COMPOUND = defines.command.compound +local DEFINES_COMMAND_FLEE = defines.command.flee + +local DEFINES_COMPOUND_COMMAND_RETURN_LAST = defines.compound_command.return_last local CHUNK_SIZE = constants.CHUNK_SIZE @@ -105,18 +105,11 @@ local squadsBeginAttack = squadAttack.squadsBeginAttack local retreatUnits = squadDefense.retreatUnits -local getChunkBase = chunkPropertyUtils.getChunkBase - --- local isSpawnerEgg = stringUtils.isSpawnerEgg - local accountPlayerEntity = chunkUtils.accountPlayerEntity local unregisterEnemyBaseStructure = chunkUtils.unregisterEnemyBaseStructure local registerEnemyBaseStructure = chunkUtils.registerEnemyBaseStructure local makeImmortalEntity = chunkUtils.makeImmortalEntity --- local getChunkSpawnerEggTick = chunkPropertyUtils.getChunkSpawnerEggTick --- local setChunkSpawnerEggTick = chunkPropertyUtils.setChunkSpawnerEggTick - local upgradeEntity = baseUtils.upgradeEntity local rebuildNativeTables = baseUtils.rebuildNativeTables @@ -299,6 +292,21 @@ local function rebuildMap() use_group_distraction = false } + map.fleeCommand = { + type = DEFINES_COMMAND_FLEE, + from = nil, + distraction = DEFINES_DISTRACTION_NONE + } + + map.compoundRetreatCommand = { + type = DEFINES_COMMMAD_COMPOUND, + structure_type = DEFINES_COMPOUND_COMMAND_RETURN_LAST, + commands = { + map.fleeCommand, + map.retreatCommand + } + } + map.formGroupCommand = { type = DEFINES_COMMAND_GROUP, group = nil, distraction = DEFINES_DISTRACTION_NONE } diff --git a/libs/ChunkProcessor.lua b/libs/ChunkProcessor.lua index e1b837a..1b99384 100755 --- a/libs/ChunkProcessor.lua +++ b/libs/ChunkProcessor.lua @@ -8,24 +8,17 @@ local chunkProcessor = {} local chunkUtils = require("ChunkUtils") local mathUtils = require("MathUtils") local constants = require("Constants") -local squadDefense = require("SquadDefense") --- local unitGroupUtils = require("UnitGroupUtils") -- constants local CHUNK_SIZE = constants.CHUNK_SIZE --- local RETREAT_GRAB_RADIUS = constants.RETREAT_GRAB_RADIUS --- local SPAWNER_EGG_TIMEOUT = constants.SPAWNER_EGG_TIMEOUT - local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK local MAX_TICKS_BEFORE_SORT_CHUNKS = constants.MAX_TICKS_BEFORE_SORT_CHUNKS -- imported functions --- local retreatUnits = squadDefense.retreatUnits - local createChunk = chunkUtils.createChunk local initialScan = chunkUtils.initialScan local chunkPassScan = chunkUtils.chunkPassScan diff --git a/libs/SquadDefense.lua b/libs/SquadDefense.lua index 92af7ee..663c9aa 100755 --- a/libs/SquadDefense.lua +++ b/libs/SquadDefense.lua @@ -56,9 +56,9 @@ local function scoreRetreatLocation(map, neighborChunk) -(getPlayerBaseGenerator(map, neighborChunk) * 1000)) end -function aiDefense.retreatUnits(chunk, position, squad, map, surface, natives, tick, radius, artilleryBlast, force) +function aiDefense.retreatUnits(chunk, position, squad, map, surface, natives, tick, radius, artilleryBlast) if (tick - getRetreatTick(map, chunk) > INTERVAL_RETREAT) and - ((getEnemyStructureCount(map, chunk) == 0) or artilleryBlast or force) + ((getEnemyStructureCount(map, chunk) == 0) or artilleryBlast) then local performRetreat = false local enemiesToSquad = nil