2019-02-16 06:17:30 +02:00
if aiPlanningG then
return aiPlanningG
end
2016-10-15 02:00:18 +02:00
local aiPlanning = { }
-- imports
local constants = require ( " Constants " )
local mathUtils = require ( " MathUtils " )
2017-06-01 03:46:53 +02:00
2016-10-15 02:00:18 +02:00
-- constants
2021-11-25 21:11:46 +02:00
local AGGRESSIVE_CAN_ATTACK_WAIT_MAX_DURATION = constants.AGGRESSIVE_CAN_ATTACK_WAIT_MAX_DURATION
local AGGRESSIVE_CAN_ATTACK_WAIT_MIN_DURATION = constants.AGGRESSIVE_CAN_ATTACK_WAIT_MIN_DURATION
local ACTIVE_NESTS_PER_AGGRESSIVE_GROUPS = constants.ACTIVE_NESTS_PER_AGGRESSIVE_GROUPS
2017-06-01 03:46:53 +02:00
local NO_RETREAT_BASE_PERCENT = constants.NO_RETREAT_BASE_PERCENT
local NO_RETREAT_EVOLUTION_BONUS_MAX = constants.NO_RETREAT_EVOLUTION_BONUS_MAX
2016-10-15 02:00:18 +02:00
local AI_STATE_PEACEFUL = constants.AI_STATE_PEACEFUL
local AI_STATE_AGGRESSIVE = constants.AI_STATE_AGGRESSIVE
2018-02-10 09:57:04 +02:00
local AI_STATE_RAIDING = constants.AI_STATE_RAIDING
2018-02-14 10:28:42 +02:00
local AI_STATE_MIGRATING = constants.AI_STATE_MIGRATING
2019-02-09 07:48:00 +02:00
local AI_STATE_ONSLAUGHT = constants.AI_STATE_ONSLAUGHT
2018-02-19 06:18:04 +02:00
local AI_STATE_SIEGE = constants.AI_STATE_SIEGE
2017-06-01 03:46:53 +02:00
local AI_UNIT_REFUND = constants.AI_UNIT_REFUND
2016-10-15 02:00:18 +02:00
local AI_MAX_POINTS = constants.AI_MAX_POINTS
local AI_POINT_GENERATOR_AMOUNT = constants.AI_POINT_GENERATOR_AMOUNT
local AI_MIN_STATE_DURATION = constants.AI_MIN_STATE_DURATION
local AI_MAX_STATE_DURATION = constants.AI_MAX_STATE_DURATION
2017-06-01 03:46:53 +02:00
local BASE_RALLY_CHANCE = constants.BASE_RALLY_CHANCE
local BONUS_RALLY_CHANCE = constants.BONUS_RALLY_CHANCE
2018-02-19 02:21:18 +02:00
local RETREAT_MOVEMENT_PHEROMONE_LEVEL_MIN = constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MIN
local RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX = constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX
2020-04-03 05:47:26 +02:00
local MINIMUM_AI_POINTS = constants.MINIMUM_AI_POINTS
2017-06-01 03:46:53 +02:00
2016-10-15 02:00:18 +02:00
-- imported functions
local randomTickEvent = mathUtils.randomTickEvent
2018-02-14 10:28:42 +02:00
local linearInterpolation = mathUtils.linearInterpolation
2017-06-16 03:30:26 +02:00
local mFloor = math.floor
2021-11-25 21:11:46 +02:00
local mCeil = math.ceil
2017-06-16 03:30:26 +02:00
2017-07-01 06:36:23 +02:00
local mRandom = math.random
2016-10-15 02:00:18 +02:00
local mMax = math.max
2019-12-09 05:31:51 +02:00
local mMin = math.min
2016-10-15 02:00:18 +02:00
-- module code
2021-05-01 22:50:40 +02:00
local function getTimeStringFromTick ( tick )
local tickToSeconds = tick / 60
2021-11-26 05:27:39 +02:00
local days = mFloor ( tickToSeconds / 86400 )
local hours = mFloor ( ( tickToSeconds % 86400 ) / 3600 )
local minutes = mFloor ( ( tickToSeconds % 3600 ) / 60 )
local seconds = mFloor ( tickToSeconds % 60 )
2021-05-01 22:50:40 +02:00
return days .. " d " .. hours .. " h " .. minutes .. " m " .. seconds .. " s "
end
2021-02-20 09:31:36 +02:00
function aiPlanning . planning ( map , evolution_factor , tick )
local universe = map.universe
map.evolutionLevel = evolution_factor
universe.evolutionLevel = evolution_factor
2019-12-16 03:16:56 +02:00
2020-04-03 05:47:26 +02:00
local maxPoints = mMax ( AI_MAX_POINTS * evolution_factor , MINIMUM_AI_POINTS )
2021-04-30 07:24:14 +02:00
universe.maxPoints = maxPoints
2017-06-01 03:46:53 +02:00
2021-02-20 09:31:36 +02:00
if not universe.ranIncompatibleMessage and universe.newEnemies and
2021-02-14 06:49:54 +02:00
( game.active_mods [ " bobenemies " ] or game.active_mods [ " Natural_Evolution_Enemies " ] ) then
2021-02-20 09:31:36 +02:00
universe.ranIncompatibleMessage = true
2020-04-28 05:41:18 +02:00
game.print ( { " description.rampant-bobs-nee-newEnemies " } )
2019-12-07 07:57:20 +02:00
end
2019-10-19 21:13:48 +02:00
local maxOverflowPoints = maxPoints * 3
2017-06-01 03:46:53 +02:00
2021-02-20 09:31:36 +02:00
local attackWaveMaxSize = universe.attackWaveMaxSize
universe.retreatThreshold = linearInterpolation ( evolution_factor ,
2021-02-21 01:31:48 +02:00
RETREAT_MOVEMENT_PHEROMONE_LEVEL_MIN ,
RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX )
2021-02-20 09:31:36 +02:00
universe.rallyThreshold = BASE_RALLY_CHANCE + ( evolution_factor * BONUS_RALLY_CHANCE )
2021-04-16 22:47:43 +02:00
universe.formSquadThreshold = mMax ( ( 0.35 * evolution_factor ) , 0.1 )
2021-02-20 09:31:36 +02:00
universe.attackWaveSize = attackWaveMaxSize * ( evolution_factor ^ 1.4 )
universe.attackWaveDeviation = ( universe.attackWaveSize * 0.333 )
universe.attackWaveUpperBound = universe.attackWaveSize + ( universe.attackWaveSize * 0.35 )
2021-11-25 21:11:46 +02:00
if ( map.canAttackTick < tick ) then
map.maxAggressiveGroups = mCeil ( map.activeNests / ACTIVE_NESTS_PER_AGGRESSIVE_GROUPS )
map.sentAggressiveGroups = 0
map.canAttackTick = randomTickEvent ( tick ,
AGGRESSIVE_CAN_ATTACK_WAIT_MIN_DURATION ,
AGGRESSIVE_CAN_ATTACK_WAIT_MAX_DURATION )
end
2021-02-20 09:31:36 +02:00
if ( universe.attackWaveSize < 1 ) then
universe.attackWaveSize = 2
universe.attackWaveDeviation = 1
universe.attackWaveUpperBound = 3
2020-04-03 05:47:26 +02:00
end
2019-02-03 08:01:28 +02:00
2021-02-20 09:31:36 +02:00
universe.settlerWaveSize = linearInterpolation ( evolution_factor ^ 1.66667 ,
2021-02-21 01:31:48 +02:00
universe.expansionMinSize ,
universe.expansionMaxSize )
2021-02-20 09:31:36 +02:00
universe.settlerWaveDeviation = ( universe.settlerWaveSize * 0.33 )
2019-02-06 08:25:43 +02:00
2021-02-20 09:31:36 +02:00
universe.settlerCooldown = mFloor ( linearInterpolation ( evolution_factor ^ 1.66667 ,
2021-02-21 01:31:48 +02:00
universe.expansionMaxTime ,
universe.expansionMinTime ) )
2019-02-03 08:01:28 +02:00
2021-02-20 09:31:36 +02:00
universe.unitRefundAmount = AI_UNIT_REFUND * evolution_factor
universe.kamikazeThreshold = NO_RETREAT_BASE_PERCENT + ( evolution_factor * NO_RETREAT_EVOLUTION_BONUS_MAX )
2018-01-21 09:42:47 +02:00
2021-04-30 07:24:14 +02:00
local points = ( ( AI_POINT_GENERATOR_AMOUNT * mRandom ( ) ) + ( map.activeNests * 0.003 ) +
( AI_POINT_GENERATOR_AMOUNT * mMax ( evolution_factor ^ 2.5 , 0.1 ) ) )
if ( map.temperament < 0.05 ) or ( map.temperament > 0.95 ) then
points = points + 0.3
elseif ( map.temperament < 0.25 ) or ( map.temperament > 0.75 ) then
points = points + 0.2
elseif ( map.temperament < 0.40 ) or ( map.temperament > 0.60 ) then
points = points + 0.1
end
2019-02-03 08:01:28 +02:00
2021-02-20 09:31:36 +02:00
if ( map.state == AI_STATE_ONSLAUGHT ) then
2019-02-09 07:48:00 +02:00
points = points * 2
end
2021-04-30 07:24:14 +02:00
points = points * universe.aiPointsScaler
2021-11-26 21:56:19 +02:00
map.baseIncrement = points * 30
2019-02-03 08:01:28 +02:00
2021-02-20 09:31:36 +02:00
local currentPoints = map.points
2019-12-16 03:16:56 +02:00
2019-10-19 21:13:48 +02:00
if ( currentPoints < maxPoints ) then
2021-02-20 09:31:36 +02:00
map.points = currentPoints + points
2019-10-19 21:13:48 +02:00
end
2019-12-09 05:31:51 +02:00
2019-10-19 21:13:48 +02:00
if ( currentPoints > maxOverflowPoints ) then
2021-02-20 09:31:36 +02:00
map.points = maxOverflowPoints
2016-10-15 02:00:18 +02:00
end
2019-02-03 08:01:28 +02:00
2021-02-20 09:31:36 +02:00
if ( map.stateTick <= tick ) then
2019-12-09 05:31:51 +02:00
local roll = mRandom ( )
2021-02-20 09:31:36 +02:00
if ( map.temperament < 0.05 ) then -- 0 - 0.05
if universe.enabledMigration then
2021-03-29 07:00:49 +02:00
if ( roll < 0.7 ) and universe.siegeAIToggle then
map.state = AI_STATE_SIEGE
else
map.state = AI_STATE_MIGRATING
end
2019-12-09 05:31:51 +02:00
else
2021-02-20 09:31:36 +02:00
if universe.raidAIToggle then
2019-12-16 03:16:56 +02:00
if ( roll < 0.85 ) then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_AGGRESSIVE
2019-12-16 03:16:56 +02:00
else
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_RAIDING
2019-12-16 03:16:56 +02:00
end
2019-12-09 05:31:51 +02:00
else
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_AGGRESSIVE
2019-12-09 05:31:51 +02:00
end
end
2021-02-20 09:31:36 +02:00
elseif ( map.temperament < 0.20 ) then -- 0.05 - 0.2
if ( universe.enabledMigration ) then
2021-03-29 07:00:49 +02:00
if ( roll < 0.4 ) and universe.siegeAIToggle then
map.state = AI_STATE_SIEGE
2019-12-16 03:16:56 +02:00
else
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_MIGRATING
2019-12-16 03:16:56 +02:00
end
else
2021-02-20 09:31:36 +02:00
if universe.raidAIToggle then
2019-12-16 03:16:56 +02:00
if ( roll < 0.95 ) then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_AGGRESSIVE
2019-12-16 03:16:56 +02:00
else
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_RAIDING
2019-12-16 03:16:56 +02:00
end
else
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_AGGRESSIVE
2019-12-16 03:16:56 +02:00
end
2019-12-09 05:31:51 +02:00
end
2021-02-20 09:31:36 +02:00
elseif ( map.temperament < 0.4 ) then -- 0.2 - 0.4
if ( universe.enabledMigration ) then
2019-12-16 03:16:56 +02:00
if ( roll < 0.2 ) then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_AGGRESSIVE
2019-12-16 03:16:56 +02:00
elseif ( roll < 0.8 ) then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_MIGRATING
2021-04-16 22:47:43 +02:00
elseif universe.peacefulAIToggle then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_PEACEFUL
2021-04-16 22:47:43 +02:00
else
map.state = AI_STATE_MIGRATING
2019-12-16 03:16:56 +02:00
end
2019-12-09 05:31:51 +02:00
else
2019-12-16 03:16:56 +02:00
if ( roll < 0.6 ) then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_AGGRESSIVE
2021-04-16 22:47:43 +02:00
elseif universe.peacefulAIToggle then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_PEACEFUL
2021-04-16 22:47:43 +02:00
else
map.state = AI_STATE_AGGRESSIVE
2019-12-16 03:16:56 +02:00
end
2019-12-09 05:31:51 +02:00
end
2021-02-20 09:31:36 +02:00
elseif ( map.temperament < 0.6 ) then -- 0.4 - 0.6
2021-02-21 01:31:48 +02:00
if ( roll < 0.4 ) then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_AGGRESSIVE
2021-04-16 22:47:43 +02:00
elseif universe.peacefulAIToggle then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_PEACEFUL
2021-04-16 22:47:43 +02:00
else
if universe.enabledMigration then
map.state = AI_STATE_MIGRATING
else
map.state = AI_STATE_AGGRESSIVE
end
2019-12-16 03:16:56 +02:00
end
2021-02-20 09:31:36 +02:00
elseif ( map.temperament < 0.8 ) then -- 0.6 - 0.8
2021-03-29 07:00:49 +02:00
if ( roll < 0.4 ) then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_AGGRESSIVE
2021-03-29 07:00:49 +02:00
elseif ( roll < 0.6 ) then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_ONSLAUGHT
2021-03-29 07:00:49 +02:00
elseif ( roll < 0.8 ) then
map.state = AI_STATE_RAIDING
2021-04-16 22:47:43 +02:00
elseif universe.peacefulAIToggle then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_PEACEFUL
2021-04-16 22:47:43 +02:00
else
map.state = AI_STATE_AGGRESSIVE
2019-12-16 03:16:56 +02:00
end
2021-03-29 07:00:49 +02:00
elseif ( map.temperament < 0.95 ) then -- 0.8 - 0.95
2021-02-20 09:31:36 +02:00
if ( universe.enabledMigration and universe.raidAIToggle ) then
2021-05-01 22:50:40 +02:00
if ( roll < 0.20 ) and universe.siegeAIToggle then
2021-03-29 07:00:49 +02:00
map.state = AI_STATE_SIEGE
2021-05-01 22:50:40 +02:00
elseif ( roll < 0.45 ) then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_RAIDING
2021-05-01 22:50:40 +02:00
elseif ( roll < 0.85 ) then
2021-03-29 07:00:49 +02:00
map.state = AI_STATE_ONSLAUGHT
2019-12-16 03:16:56 +02:00
else
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_AGGRESSIVE
2019-12-16 03:16:56 +02:00
end
2021-02-20 09:31:36 +02:00
elseif ( universe.enabledMigration ) then
2021-05-01 22:50:40 +02:00
if ( roll < 0.20 ) and universe.siegeAIToggle then
2021-03-29 07:00:49 +02:00
map.state = AI_STATE_SIEGE
2021-05-01 22:50:40 +02:00
elseif ( roll < 0.75 ) then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_ONSLAUGHT
2019-12-16 03:16:56 +02:00
else
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_AGGRESSIVE
2019-12-16 03:16:56 +02:00
end
2021-02-20 09:31:36 +02:00
elseif ( universe.raidAIToggle ) then
2021-05-01 22:50:40 +02:00
if ( roll < 0.45 ) then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_ONSLAUGHT
2021-05-01 22:50:40 +02:00
elseif ( roll < 0.75 ) then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_RAIDING
2019-12-16 03:16:56 +02:00
else
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_AGGRESSIVE
2019-12-16 03:16:56 +02:00
end
else
2021-05-01 22:50:40 +02:00
if ( roll < 0.65 ) then
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_ONSLAUGHT
2019-12-16 03:16:56 +02:00
else
2021-02-20 09:31:36 +02:00
map.state = AI_STATE_AGGRESSIVE
2019-12-16 03:16:56 +02:00
end
2019-10-19 21:13:48 +02:00
end
2021-03-29 07:00:49 +02:00
else
if ( universe.enabledMigration and universe.raidAIToggle ) then
2021-05-01 22:50:40 +02:00
if ( roll < 0.30 ) and universe.siegeAIToggle then
2021-03-29 07:00:49 +02:00
map.state = AI_STATE_SIEGE
2021-05-01 22:50:40 +02:00
elseif ( roll < 0.65 ) then
2021-03-29 07:00:49 +02:00
map.state = AI_STATE_RAIDING
else
map.state = AI_STATE_ONSLAUGHT
end
elseif ( universe.enabledMigration ) then
2021-05-01 22:50:40 +02:00
if ( roll < 0.30 ) and universe.siegeAIToggle then
2021-03-29 07:00:49 +02:00
map.state = AI_STATE_SIEGE
else
map.state = AI_STATE_ONSLAUGHT
end
elseif ( universe.raidAIToggle ) then
2021-05-01 22:50:40 +02:00
if ( roll < 0.45 ) then
2021-03-29 07:00:49 +02:00
map.state = AI_STATE_ONSLAUGHT
else
map.state = AI_STATE_RAIDING
end
else
map.state = AI_STATE_ONSLAUGHT
end
2019-10-19 21:13:48 +02:00
end
2019-12-09 05:31:51 +02:00
2021-02-20 09:31:36 +02:00
map.destroyPlayerBuildings = 0
map.lostEnemyUnits = 0
map.lostEnemyBuilding = 0
map.rocketLaunched = 0
map.builtEnemyBuilding = 0
map.ionCannonBlasts = 0
map.artilleryBlasts = 0
2021-02-09 07:55:16 +02:00
2021-02-20 09:31:36 +02:00
map.stateTick = randomTickEvent ( tick , AI_MIN_STATE_DURATION , AI_MAX_STATE_DURATION )
2021-04-16 15:54:58 +02:00
if universe.printAIStateChanges then
2021-04-30 15:15:29 +02:00
game.print ( map.surface . name .. " : AI is now: " .. constants.stateEnglish [ map.state ] .. " , Next state change is in " .. string.format ( " %.2f " , ( map.stateTick - tick ) / ( 60 * 60 ) ) .. " minutes @ " .. getTimeStringFromTick ( map.stateTick ) .. " playtime " )
2021-04-16 15:54:58 +02:00
end
2017-04-22 01:33:17 +02:00
end
2016-10-15 02:00:18 +02:00
end
2021-02-20 09:31:36 +02:00
function aiPlanning . temperamentPlanner ( map )
local destroyPlayerBuildings = map.destroyPlayerBuildings
local lostEnemyUnits = map.lostEnemyUnits
local lostEnemyBuilding = map.lostEnemyBuilding
local rocketLaunched = map.rocketLaunched
local builtEnemyBuilding = map.builtEnemyBuilding
local ionCannonBlasts = map.ionCannonBlasts
local artilleryBlasts = map.artilleryBlasts
local activeNests = map.activeNests
local activeRaidNests = map.activeRaidNests
2019-12-09 05:31:51 +02:00
2021-02-20 09:31:36 +02:00
local currentTemperament = map.temperamentScore
2019-12-09 05:31:51 +02:00
local delta = 0
if activeNests > 0 then
2021-03-29 07:00:49 +02:00
local val = ( 0.03 * activeNests )
2019-12-09 05:31:51 +02:00
delta = delta + val
else
2021-02-21 01:31:48 +02:00
delta = delta - 0.014463
2021-02-09 07:55:16 +02:00
end
2019-12-09 05:31:51 +02:00
2021-02-09 07:55:16 +02:00
if destroyPlayerBuildings > 0 then
if currentTemperament > 0 then
2021-02-21 01:31:48 +02:00
delta = delta - ( 0.014463 * destroyPlayerBuildings )
2021-02-09 07:55:16 +02:00
else
2021-02-21 01:31:48 +02:00
delta = delta + ( 0.014463 * destroyPlayerBuildings )
2019-12-09 05:31:51 +02:00
end
end
if activeRaidNests > 0 then
2021-04-30 07:24:14 +02:00
local val = ( 0.0006 * activeRaidNests )
2019-12-09 05:31:51 +02:00
delta = delta - val
else
2021-04-30 07:24:14 +02:00
delta = delta - 0.01
2019-12-09 05:31:51 +02:00
end
if lostEnemyUnits > 0 then
2021-02-09 07:55:16 +02:00
local multipler
2021-02-20 09:31:36 +02:00
if map.evolutionLevel < 0.3 then
2021-02-21 01:31:48 +02:00
multipler = 0.000434
2021-02-20 09:31:36 +02:00
elseif map.evolutionLevel < 0.5 then
2021-02-21 01:31:48 +02:00
multipler = 0.000217
2021-02-20 09:31:36 +02:00
elseif map.evolutionLevel < 0.7 then
2021-02-21 01:31:48 +02:00
multipler = 0.000108
2021-02-20 09:31:36 +02:00
elseif map.evolutionLevel < 0.9 then
2021-02-21 01:31:48 +02:00
multipler = 0.000054
2021-02-20 09:31:36 +02:00
elseif map.evolutionLevel < 0.9 then
2021-02-21 01:31:48 +02:00
multipler = 0.000027
2021-02-28 21:28:48 +02:00
else
multipler = 0.0000135
2021-02-09 07:55:16 +02:00
end
local val = ( multipler * lostEnemyUnits )
2019-12-09 05:31:51 +02:00
if ( currentTemperament > 0 ) then
delta = delta - val
else
delta = delta + val
end
end
if lostEnemyBuilding > 0 then
2021-02-21 01:31:48 +02:00
local val = ( 0.072317 * lostEnemyBuilding )
2021-02-09 07:55:16 +02:00
if ( currentTemperament > 0 ) then
delta = delta - val
else
delta = delta + val
2021-02-14 06:49:54 +02:00
end
2019-12-09 05:31:51 +02:00
end
if ( builtEnemyBuilding > 0 ) then
2021-02-21 01:31:48 +02:00
local val = ( 0.004339 * builtEnemyBuilding )
2019-12-09 05:31:51 +02:00
if ( currentTemperament > 0 ) then
delta = delta - val
else
delta = delta + val
end
else
2021-02-21 01:31:48 +02:00
delta = delta - 0.007232
2019-12-09 05:31:51 +02:00
end
if ( rocketLaunched > 0 ) then
2021-02-21 01:31:48 +02:00
local val = ( 0.289268 * rocketLaunched )
2019-12-09 05:31:51 +02:00
delta = delta + val
end
if ( ionCannonBlasts > 0 ) then
2021-02-21 01:31:48 +02:00
local val = ( 0.144634 * ionCannonBlasts )
2019-12-09 05:31:51 +02:00
delta = delta + val
end
if ( artilleryBlasts > 0 ) then
2021-02-21 01:31:48 +02:00
local val = ( 0.144634 * artilleryBlasts )
2019-12-09 05:31:51 +02:00
delta = delta + val
end
2021-04-16 22:47:43 +02:00
local universe = map.universe
delta = delta * universe.temperamentRateModifier
2021-02-21 01:31:48 +02:00
map.temperamentScore = mMin ( 10000 , mMax ( - 10000 , currentTemperament + delta ) )
map.temperament = ( ( map.temperamentScore + 10000 ) * 0.00005 )
2019-12-16 03:16:56 +02:00
2021-04-16 22:47:43 +02:00
if universe.debugTemperament then
if game.tick % 240 == 0 then
game.print ( " Rampant Stats: " )
game.print ( " aN: " .. map.activeNests .. " , aRN: " .. map.activeRaidNests .. " , dPB: " .. map.destroyPlayerBuildings ..
" , lEU: " .. map.lostEnemyUnits .. " , lEB: " .. map.lostEnemyBuilding .. " , rL: " .. map.rocketLaunched .. " , bEB: " .. map.builtEnemyBuilding ..
" , iCB: " .. map.ionCannonBlasts .. " , aB: " .. map.artilleryBlasts )
2021-04-30 18:04:59 +02:00
game.print ( " temp: " .. map.temperament .. " , tempScore: " .. map.temperamentScore .. " , points: " .. map.points .. " , state: " .. constants.stateEnglish [ map.state ] .. " , surface: " .. map.surface . index .. " [ " .. map.surface . name .. " ] " )
2021-04-16 22:47:43 +02:00
game.print ( " aS: " .. universe.squadCount .. " , aB: " .. universe.builderCount .. " , atkSize: " .. universe.attackWaveSize .. " , stlSize: " .. universe.settlerWaveSize .. " , formGroup: " .. universe.formSquadThreshold )
end
end
2019-12-09 05:31:51 +02:00
end
2019-02-16 06:17:30 +02:00
aiPlanningG = aiPlanning
2016-10-15 02:00:18 +02:00
return aiPlanning