From 3e56e0a9e2e4018dac1d1ca4eea84942274883d7 Mon Sep 17 00:00:00 2001 From: Aaron Veden Date: Sun, 18 Feb 2018 16:21:18 -0800 Subject: [PATCH] see changelog --- Upgrade.lua | 9 +++++---- changelog.txt | 20 +++++++++++++++++--- config.lua | 2 +- control.lua | 2 +- info.json | 2 +- libs/AIPlanning.lua | 8 +++++--- libs/ChunkUtils.lua | 4 ++++ libs/Constants.lua | 13 +++++++------ libs/MathUtils.lua | 4 ++++ libs/PheromoneUtils.lua | 2 +- tests.lua | 13 ++----------- visual.rkt | 8 +++++++- 12 files changed, 55 insertions(+), 32 deletions(-) diff --git a/Upgrade.lua b/Upgrade.lua index d544105..64dbae3 100755 --- a/Upgrade.lua +++ b/Upgrade.lua @@ -108,7 +108,6 @@ function upgrade.attempt(natives) natives.formSquadThreshold = 0 natives.attackWaveSize = 0 natives.attackWaveDeviation = 0 - natives.attackWaveLowerBound = 0 natives.attackWaveUpperBound = 0 natives.unitRefundAmount = 0 natives.attackWaveThreshold = 0 @@ -197,10 +196,12 @@ function upgrade.attempt(natives) game.surfaces[1].print("Rampant - Version 0.16.16") global.version = constants.VERSION_51 end - if (global.version < constants.VERSION_56) then + if (global.version < constants.VERSION_57) then + + natives.attackWaveLowerBound = 1 - game.surfaces[1].print("Rampant - Version 0.16.21") - global.version = constants.VERSION_56 + game.surfaces[1].print("Rampant - Version 0.16.22") + global.version = constants.VERSION_57 end return starting ~= global.version, natives diff --git a/changelog.txt b/changelog.txt index 0cbaeeb..0aca9eb 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,11 +1,25 @@ --------------------------------------------------------------------------------------------------- +Version: 0.16.22 +Date: 2. 18. 2018 + Tweaks: + - Death pheromone persistance increased from 0.9 to 0.99 + - Death pheromone per death increased from 600 to 3000 + - Death Retreat threshold switched to linear interpolation between, 2.5 deaths @ 0%, 400 @ 100% evolution + - Increased player pheromone weight for squad movement from 100 to 500 + - Decreased victory scent multipler from 100000 to 10000 + - Increased ai max stored points from 10000 to 12500 + Bugfixes: + - Nests and worms not getting counted correctly when upgrading + Framework: + - Fixed exportaistate visualizer +--------------------------------------------------------------------------------------------------- Version: 0.16.21 Date: 2. 16. 2018 Improvements: - - All other robots now take damage from biter projectiles and explosions (https://mods.factorio.com/mod/Rampant/discussion/5a81bd380333a5000c939c7f) - - Removed necessary squad roll during map processing + - All other robots now take damage from biter projectiles and explosions (https://mods.factorio.com/mod/Rampant/discussion/5a81bd380333a5000c939c7f) + - Removed necessary squad roll during map processing Optimizations: - - Switched over to the nth tick functions for logic and processing + - Switched over to the nth tick functions for logic and processing --------------------------------------------------------------------------------------------------- Version: 0.16.20 diff --git a/config.lua b/config.lua index a7ecafb..b559694d1 100755 --- a/config.lua +++ b/config.lua @@ -24,7 +24,7 @@ config.ionCannonPresent = settings.startup["ion-cannon-radius"] ~= nil config.attackWaveScaling = function (natives) return mCeil(gaussianRandomRange(natives.attackWaveSize, natives.attackWaveDeviation, - natives.attackWaveLowerBound, + 1, natives.attackWaveUpperBound)) end diff --git a/control.lua b/control.lua index 4cb8e54..57ce837 100755 --- a/control.lua +++ b/control.lua @@ -639,7 +639,7 @@ remote.add_interface("rampantTests", colorResourcePoints = tests.colorResourcePoints, entityStats = tests.entityStats, stepAdvanceTendrils = tests.stepAdvanceTendrils, - exportAiState = tests.exportAiState(onTick) + exportAiState = tests.exportAiState() } ) diff --git a/info.json b/info.json index efb5042..871c355 100755 --- a/info.json +++ b/info.json @@ -1,7 +1,7 @@ { "name" : "Rampant", "factorio_version" : "0.16", - "version" : "0.16.21", + "version" : "0.16.22", "title" : "Rampant", "author" : "Veden", "homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445", diff --git a/libs/AIPlanning.lua b/libs/AIPlanning.lua index b30ef15..cd0ae90 100755 --- a/libs/AIPlanning.lua +++ b/libs/AIPlanning.lua @@ -33,7 +33,8 @@ local AI_MAX_TEMPERAMENT_DURATION = constants.AI_MAX_TEMPERAMENT_DURATION local BASE_RALLY_CHANCE = constants.BASE_RALLY_CHANCE local BONUS_RALLY_CHANCE = constants.BONUS_RALLY_CHANCE -local RETREAT_MOVEMENT_PHEROMONE_LEVEL = constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL +local RETREAT_MOVEMENT_PHEROMONE_LEVEL_MIN = constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MIN +local RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX = constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX local TICKS_A_MINUTE = constants.TICKS_A_MINUTE @@ -47,6 +48,8 @@ local mFloor = math.floor local mRandom = math.random +local linearInterpolation = mathUtils.linearInterpolation + local mMax = math.max -- module code @@ -65,12 +68,11 @@ function aiPlanning.planning(natives, evolution_factor, tick, surface, connected end local attackWaveMaxSize = natives.attackWaveMaxSize - natives.retreatThreshold = -(evolution_factor * RETREAT_MOVEMENT_PHEROMONE_LEVEL) + natives.retreatThreshold = linearInterpolation(evolution_factor, RETREAT_MOVEMENT_PHEROMONE_LEVEL_MIN, RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX) natives.rallyThreshold = BASE_RALLY_CHANCE + (evolution_factor * BONUS_RALLY_CHANCE) natives.formSquadThreshold = mMax((0.25 * evolution_factor), 0.10) natives.attackWaveSize = attackWaveMaxSize * (evolution_factor ^ 1.66667) natives.attackWaveDeviation = (attackWaveMaxSize * 0.5) * 0.333 - natives.attackWaveLowerBound = 1 natives.attackWaveUpperBound = attackWaveMaxSize + (attackWaveMaxSize * 0.25) natives.unitRefundAmount = AI_UNIT_REFUND * evolution_factor natives.kamikazeThreshold = NO_RETREAT_BASE_PERCENT + (evolution_factor * NO_RETREAT_EVOLUTION_BONUS_MAX) diff --git a/libs/ChunkUtils.lua b/libs/ChunkUtils.lua index 60c026f..aaa8838 100755 --- a/libs/ChunkUtils.lua +++ b/libs/ChunkUtils.lua @@ -298,6 +298,8 @@ function chunkUtils.initialScan(chunk, natives, surface, map, tick, evolutionFac if upgradeEntity(nests[i], surface, alignment, natives, evolutionFactor) then nestCount = nestCount + 1 end + else + nestCount = nestCount + 1 end else if upgradeEntity(nests[i], surface, alignment, natives, evolutionFactor) then @@ -313,6 +315,8 @@ function chunkUtils.initialScan(chunk, natives, surface, map, tick, evolutionFac if upgradeEntity(worms[i], surface, alignment, natives, evolutionFactor) then wormCount = wormCount + 1 end + else + wormCount = wormCount + 1 end else if upgradeEntity(worms[i], surface, alignment, natives, evolutionFactor) then diff --git a/libs/Constants.lua b/libs/Constants.lua index d1b08bc..8d3b545 100755 --- a/libs/Constants.lua +++ b/libs/Constants.lua @@ -20,7 +20,7 @@ constants.VERSION_38 = 38 constants.VERSION_41 = 41 constants.VERSION_44 = 44 constants.VERSION_51 = 51 -constants.VERSION_56 = 56 +constants.VERSION_57 = 57 -- misc @@ -28,7 +28,8 @@ constants.WATER_TILE_NAMES = { "water", "deepwater", "water-green", "deepwater-g constants.MAGIC_MAXIMUM_NUMBER = 1e99 -- used in loops trying to find the lowest/highest score constants.MAGIC_MAXIMUM_BASE_NUMBER = 100000000 -constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL = 18000 +constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MIN = 7500 +constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX = 1200000 constants.PROCESS_QUEUE_SIZE = 400 constants.SCAN_QUEUE_SIZE = 5 @@ -50,7 +51,7 @@ constants.INTERVAL_RETREAT = constants.TICKS_A_SECOND * 10 constants.RESOURCE_GENERATOR_INCREMENT = 0.001 -constants.PLAYER_PHEROMONE_MULTIPLER = 100 +constants.PLAYER_PHEROMONE_MULTIPLER = 500 constants.DEV_CUSTOM_AI = false @@ -85,7 +86,7 @@ constants.AI_VENGENCE_SQUAD_COST = 45 constants.AI_SETTLER_COST = 75 constants.AI_BASE_BUILDING_COST = 500 constants.AI_TUNNEL_COST = 100 -constants.AI_MAX_POINTS = 10000 +constants.AI_MAX_POINTS = 12500 constants.AI_MAX_OVERFLOW_POINTS = constants.AI_MAX_POINTS * 3 constants.RAIDING_MINIMUM_BASE_THRESHOLD = 250 @@ -222,14 +223,14 @@ constants.NO_RETREAT_SQUAD_SIZE_BONUS_MAX = 0.40 -- pheromone amounts constants.MOVEMENT_PHEROMONE_GENERATOR_AMOUNT = 500 -constants.DEATH_PHEROMONE_GENERATOR_AMOUNT = 600 +constants.DEATH_PHEROMONE_GENERATOR_AMOUNT = 3000 constants.PLAYER_PHEROMONE_GENERATOR_AMOUNT = 300 constants.IMPASSABLE_TERRAIN_GENERATOR_AMOUNT = -0.1 -- pheromone diffusion amounts -constants.MOVEMENT_PHEROMONE_PERSISTANCE = 0.9 +constants.MOVEMENT_PHEROMONE_PERSISTANCE = 0.99 constants.BASE_PHEROMONE_PERSISTANCE = 0.99 constants.PLAYER_PHEROMONE_PERSISTANCE = 0.98 constants.RESOURCE_PHEROMONE_PERSISTANCE = 0.99 diff --git a/libs/MathUtils.lua b/libs/MathUtils.lua index 368ec60..ae8c06f 100755 --- a/libs/MathUtils.lua +++ b/libs/MathUtils.lua @@ -53,6 +53,10 @@ function mathUtils.xorRandom(state) end end +function mathUtils.linearInterpolation(percent, min, max) + return ((max - min) * percent) + min +end + --[[ Used for gaussian random numbers --]] diff --git a/libs/PheromoneUtils.lua b/libs/PheromoneUtils.lua index 87d6b49..c269092 100755 --- a/libs/PheromoneUtils.lua +++ b/libs/PheromoneUtils.lua @@ -51,7 +51,7 @@ end function pheromoneUtils.victoryScent(chunk, entityType) local value = BUILDING_PHEROMONES[entityType] if value then - chunk[MOVEMENT_PHEROMONE] = chunk[MOVEMENT_PHEROMONE] + (value * 100000) + chunk[MOVEMENT_PHEROMONE] = chunk[MOVEMENT_PHEROMONE] + (value * 10000) end end diff --git a/tests.lua b/tests.lua index 673df78..1138428 100755 --- a/tests.lua +++ b/tests.lua @@ -347,7 +347,7 @@ function tests.entityStats(name, d) a.destroy() end -function tests.exportAiState(onTick) +function tests.exportAiState() local printState = function () local chunks = global.map.processQueue @@ -381,19 +381,10 @@ function tests.exportAiState(onTick) interval = tonumber(interval) end - local wrappedTick = function (event) - if (event.tick % interval == 0) then - printState() - end - onTick(event) - end - printState() if (interval > 0) then - script.on_event(defines.events.on_tick, wrappedTick) - elseif (interval == 0) then - script.on_event(defines.events.on_tick, onTick) + script.on_nth_tick(interval, printState) end end end diff --git a/visual.rkt b/visual.rkt index 457cb92..a2e6693 100755 --- a/visual.rkt +++ b/visual.rkt @@ -242,7 +242,13 @@ 100 50)))) (define g (inexact->exact (round (* v 255)))) - (send dc set-brush (make-object color% r g 0) 'solid)) + (send dc + set-brush + (make-object color% + (min (max r 0) 255) + (min (max g 0) 255) + 0) + 'solid)) (new radio-box%