1
0
mirror of https://github.com/veden/Rampant.git synced 2024-12-26 20:54:12 +02:00

see changelog

This commit is contained in:
Aaron Veden 2018-10-19 22:17:37 -07:00
parent 46c929d84c
commit a9183dcb44
7 changed files with 152 additions and 59 deletions

View File

@ -217,10 +217,10 @@ function upgrade.attempt(natives)
game.surfaces[natives.activeSurface].print("Rampant - Version 0.16.22")
global.version = constants.VERSION_57
end
if (global.version < constants.VERSION_68) then
if (global.version < constants.VERSION_69) then
game.surfaces[natives.activeSurface].print("Rampant - Version 0.16.33")
global.version = constants.VERSION_68
game.surfaces[natives.activeSurface].print("Rampant - Version 0.16.34")
global.version = constants.VERSION_69
end
return starting ~= global.version, natives

View File

@ -1,3 +1,22 @@
---------------------------------------------------------------------------------------------------
Version: 0.16.34
Date: 10. 19. 2018
Improvements:
- Reworked dispersion to process pheromone in two phases.
- Switch to all adjacent neighbors instead of cardinal neighbors for dispersion
Tweaks:
- Reduced chunks process per interval from 400 to 300
- Increased building pheromone generator by 10x
- Reduced Retreat pheromone max level from 20000 to 17000
- Reduced Retreat pheromone min level from 1500 to 1000
- Increased death generator from 75 to 125
- Increased movement persistance from 0.875 to 0.975
- Increased player persistance from 0.98 to 0.97
- Increased resource persistance from 0.99 to 0.97
Bugfixes:
- Fix for unit groups not being able to move off of impassable terrain
- Fix for incorrect variable name in interop
---------------------------------------------------------------------------------------------------
Version: 0.16.33
Date: 9. 25. 2018

View File

@ -29,6 +29,8 @@ 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
local WATER_TILE_NAMES = constants.WATER_TILE_NAMES
local MOVEMENT_PHEROMONE = constants.MOVEMENT_PHEROMONE
@ -213,6 +215,13 @@ local function rebuildMap()
map.position = {x=0,
y=0}
map.scentStaging = {}
for x=1,PROCESS_QUEUE_SIZE+1 do
map.scentStaging[x] = {0,0,0,0}
end
map.position2Top = {0, 0}
map.position2Bottom = {0, 0}
--this is shared between two different queries
@ -356,9 +365,8 @@ script.on_nth_tick(INTERVAL_PROCESS,
local tick = event.tick
local gameRef = game
local surface = gameRef.surfaces[natives.activeSurface]
processPlayers(gameRef.players, map, surface, natives, tick)
processMap(map, surface, natives, tick, gameRef.forces.enemy.evolution_factor)
end)

View File

@ -21,7 +21,7 @@ constants.VERSION_41 = 41
constants.VERSION_44 = 44
constants.VERSION_51 = 51
constants.VERSION_57 = 57
constants.VERSION_68 = 68
constants.VERSION_69 = 69
-- misc
@ -29,10 +29,10 @@ 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_MIN = 1500
constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX = 20000
constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MIN = 1000
constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX = 17000
constants.PROCESS_QUEUE_SIZE = 400
constants.PROCESS_QUEUE_SIZE = 300
constants.SCAN_QUEUE_SIZE = 5
constants.BASE_QUEUE_SIZE = 1
constants.SQUAD_QUEUE_SIZE = 2
@ -244,18 +244,18 @@ constants.NO_RETREAT_SQUAD_SIZE_BONUS_MAX = 0.40
-- pheromone amounts
constants.MOVEMENT_PHEROMONE_GENERATOR_AMOUNT = 500
constants.DEATH_PHEROMONE_GENERATOR_AMOUNT = 75
constants.DEATH_PHEROMONE_GENERATOR_AMOUNT = 125
constants.PLAYER_PHEROMONE_GENERATOR_AMOUNT = 300
constants.IMPASSABLE_TERRAIN_GENERATOR_AMOUNT = -0.1
-- pheromone diffusion amounts
constants.MOVEMENT_GENERATOR_PERSISTANCE = 0.875
constants.MOVEMENT_GENERATOR_PERSISTANCE = 0.975
constants.MOVEMENT_PHEROMONE_PERSISTANCE = 0.99
constants.BASE_PHEROMONE_PERSISTANCE = 0.99
constants.PLAYER_PHEROMONE_PERSISTANCE = 0.98
constants.RESOURCE_PHEROMONE_PERSISTANCE = 0.99
constants.PLAYER_PHEROMONE_PERSISTANCE = 0.97
constants.RESOURCE_PHEROMONE_PERSISTANCE = 0.97
-- chunk attributes
@ -297,34 +297,34 @@ constants.MAX_PENALTY_BEFORE_PURGE = 20000
-- player building pheromones
constants.BUILDING_PHEROMONES = {}
constants.BUILDING_PHEROMONES["generator"] = 80
constants.BUILDING_PHEROMONES["pump"] = 20
constants.BUILDING_PHEROMONES["reactor"] = 160
constants.BUILDING_PHEROMONES["offshore-pump"] = 20
constants.BUILDING_PHEROMONES["transport-belt"] = 10
constants.BUILDING_PHEROMONES["accumulator"] = 100
constants.BUILDING_PHEROMONES["solar-panel"] = 80
constants.BUILDING_PHEROMONES["boiler"] = 120
constants.BUILDING_PHEROMONES["assembling-machine"] = 100
constants.BUILDING_PHEROMONES["roboport"] = 100
constants.BUILDING_PHEROMONES["beacon"] = 100
constants.BUILDING_PHEROMONES["furnace"] = 120
constants.BUILDING_PHEROMONES["programmable-speaker"] = 80
constants.BUILDING_PHEROMONES["mining-drill"] = 350
constants.BUILDING_PHEROMONES["rocket-silo"] = 1200
constants.BUILDING_PHEROMONES["lamp"] = 40
constants.BUILDING_PHEROMONES["radar"] = 200
constants.BUILDING_PHEROMONES["lab"] = 150
constants.BUILDING_PHEROMONES["splitter"] = 15
constants.BUILDING_PHEROMONES["generator"] = 800
constants.BUILDING_PHEROMONES["pump"] = 200
constants.BUILDING_PHEROMONES["reactor"] = 1600
constants.BUILDING_PHEROMONES["offshore-pump"] = 200
constants.BUILDING_PHEROMONES["transport-belt"] = 100
constants.BUILDING_PHEROMONES["accumulator"] = 1000
constants.BUILDING_PHEROMONES["solar-panel"] = 800
constants.BUILDING_PHEROMONES["boiler"] = 1200
constants.BUILDING_PHEROMONES["assembling-machine"] = 1000
constants.BUILDING_PHEROMONES["roboport"] = 1000
constants.BUILDING_PHEROMONES["beacon"] = 1000
constants.BUILDING_PHEROMONES["furnace"] = 1200
constants.BUILDING_PHEROMONES["programmable-speaker"] = 800
constants.BUILDING_PHEROMONES["mining-drill"] = 3500
constants.BUILDING_PHEROMONES["rocket-silo"] = 12000
constants.BUILDING_PHEROMONES["lamp"] = 400
constants.BUILDING_PHEROMONES["radar"] = 2000
constants.BUILDING_PHEROMONES["lab"] = 1500
constants.BUILDING_PHEROMONES["splitter"] = 150
-- player defense pheromones
constants.BUILDING_PHEROMONES["ammo-turret"] = 100
constants.BUILDING_PHEROMONES["wall"] = 5
constants.BUILDING_PHEROMONES["electric-turret"] = 200
constants.BUILDING_PHEROMONES["fluid-turret"] = 280
constants.BUILDING_PHEROMONES["turret"] = 100
constants.BUILDING_PHEROMONES["artillery-turret"] = 1000
constants.BUILDING_PHEROMONES["ammo-turret"] = 1000
constants.BUILDING_PHEROMONES["wall"] = 50
constants.BUILDING_PHEROMONES["electric-turret"] = 2000
constants.BUILDING_PHEROMONES["fluid-turret"] = 2800
constants.BUILDING_PHEROMONES["turret"] = 1000
constants.BUILDING_PHEROMONES["artillery-turret"] = 10000
constants.RETREAT_FILTER = {}
constants.RETREAT_FILTER[constants.SQUAD_RETREATING] = true

View File

@ -43,6 +43,7 @@ local BASE_PROCESS_INTERVAL = constants.BASE_PROCESS_INTERVAL
local scents = pheromoneUtils.scents
local processPheromone = pheromoneUtils.processPheromone
local commitPheromone = pheromoneUtils.commitPheromone
local playerScent = pheromoneUtils.playerScent
local formSquads = aiAttackWave.formSquads
@ -106,19 +107,19 @@ function mapProcessor.processMap(map, surface, natives, tick, evolutionFactor)
end
local newEnemies = natives.newEnemies
local scentStaging = map.scentStaging
local squads = canAttack(natives, surface) and (0.11 <= roll) and (roll <= 0.35) and (natives.points >= AI_SQUAD_COST)
local settlers = canMigrate(natives, surface) and (0.90 <= roll) and (natives.points >= AI_SETTLER_COST)
local processQueue = map.processQueue
local endIndex = mMin(index + PROCESS_QUEUE_SIZE, #processQueue)
local i = 1
for x=index,endIndex do
local chunk = processQueue[x]
local chunk = processQueue[x]
if (chunk[CHUNK_TICK] ~= tick) then
chunk[CHUNK_TICK] = tick
processPheromone(map, chunk)
processPheromone(map, chunk, scentStaging[i])
if (getNestCount(map, chunk) > 0) then
if squads then
@ -134,10 +135,22 @@ function mapProcessor.processMap(map, surface, natives, tick, evolutionFactor)
if base and ((tick - base.tick) > BASE_PROCESS_INTERVAL) and (mRandom() < 0.10) then
processBase(map, chunk, surface, natives, tick, base, evolutionFactor)
end
end
end
end
i = i + 1
end
i = 1
for x=index,endIndex do
local chunk = processQueue[x]
if (chunk[CHUNK_TICK] ~= tick) then
chunk[CHUNK_TICK] = tick
commitPheromone(map, chunk, scentStaging[i])
scents(map, chunk)
end
i = i + 1
end
if (endIndex == #processQueue) then
@ -162,6 +175,8 @@ function mapProcessor.processPlayers(players, map, surface, natives, tick)
local allowingAttacks = canAttack(natives, surface)
local scentStaging = map.scentStaging
local squads = allowingAttacks and (0.11 <= roll) and (roll <= 0.20) and (natives.points >= AI_SQUAD_COST)
for i=1,#playerOrdering do
@ -175,6 +190,8 @@ function mapProcessor.processPlayers(players, map, surface, natives, tick)
end
end
local i = 1
-- not looping everyone because the cost is high enough already in multiplayer
if (#playerOrdering > 0) then
local player = players[playerOrdering[1]]
@ -188,12 +205,10 @@ function mapProcessor.processPlayers(players, map, surface, natives, tick)
for x=playerChunk.x - PROCESS_PLAYER_BOUND, playerChunk.x + PROCESS_PLAYER_BOUND, 32 do
for y=playerChunk.y - PROCESS_PLAYER_BOUND, playerChunk.y + PROCESS_PLAYER_BOUND, 32 do
local chunk = getChunkByXY(map, x, y)
local chunk = getChunkByXY(map, x, y)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) and (chunk[CHUNK_TICK] ~= tick) then
chunk[CHUNK_TICK] = tick
processPheromone(map, chunk)
processPheromone(map, chunk, scentStaging[i])
if (getNestCount(map, chunk) > 0) then
if squads then
@ -202,10 +217,22 @@ function mapProcessor.processPlayers(players, map, surface, natives, tick)
if vengence then
vengence = formSquads(map, surface, natives, chunk, AI_VENGENCE_SQUAD_COST)
end
end
end
end
i = i + 1
end
end
i = 1
for x=playerChunk.x + PROCESS_PLAYER_BOUND, playerChunk.x - PROCESS_PLAYER_BOUND, -32 do
for y=playerChunk.y + PROCESS_PLAYER_BOUND, playerChunk.y - PROCESS_PLAYER_BOUND, -32 do
local chunk = getChunkByXY(map, x, y)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) and (chunk[CHUNK_TICK] ~= tick) then
chunk[CHUNK_TICK] = tick
commitPheromone(map, chunk, scentStaging[i])
scents(map, chunk)
end
i = i + 1
end
end
end

View File

@ -110,7 +110,7 @@ function movementUtils.scoreNeighborsForSettling(map, chunk, neighborDirectionCh
for x=1,8 do
local neighborChunk = neighborDirectionChunks[x]
if (neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and canMoveChunkDirection(map, x, chunk, neighborChunk) then
local score = scoreFunction(squad, neighborChunk)
local score = scoreFunction(squad, neighborChunk)
if (score > highestScore) then
highestScore = score
highestChunk = neighborChunk

View File

@ -72,7 +72,16 @@ function pheromoneUtils.playerScent(playerChunk)
playerChunk[PLAYER_PHEROMONE] = playerChunk[PLAYER_PHEROMONE] + PLAYER_PHEROMONE_GENERATOR_AMOUNT
end
function pheromoneUtils.processPheromone(map, chunk)
function pheromoneUtils.commitPheromone(map, chunk, staging)
chunk[MOVEMENT_PHEROMONE] = staging[MOVEMENT_PHEROMONE]
chunk[BASE_PHEROMONE] = staging[BASE_PHEROMONE]
chunk[PLAYER_PHEROMONE] = staging[PLAYER_PHEROMONE]
chunk[RESOURCE_PHEROMONE] = staging[RESOURCE_PHEROMONE]
decayDeathGenerator(map, chunk)
end
function pheromoneUtils.processPheromone(map, chunk, staging)
local chunkMovement = chunk[MOVEMENT_PHEROMONE]
local chunkBase = chunk[BASE_PHEROMONE]
@ -82,14 +91,12 @@ function pheromoneUtils.processPheromone(map, chunk)
local clear = (getEnemyStructureCount(map, chunk) == 0)
local tempNeighbors = getCardinalChunks(map, chunk.x, chunk.y)
local tempNeighbors = getNeighborChunks(map, chunk.x, chunk.y)
local movementTotal = 0
local baseTotal = 0
local playerTotal = 0
local resourceTotal = 0
decayDeathGenerator(map, chunk)
local neighbor = tempNeighbors[1]
if not neighbor.name then
@ -122,14 +129,46 @@ function pheromoneUtils.processPheromone(map, chunk)
playerTotal = playerTotal + (neighbor[PLAYER_PHEROMONE] - chunkPlayer)
resourceTotal = resourceTotal + (neighbor[RESOURCE_PHEROMONE] - chunkResource)
end
neighbor = tempNeighbors[5]
if not neighbor.name then
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
baseTotal = baseTotal + (neighbor[BASE_PHEROMONE] - chunkBase)
playerTotal = playerTotal + neighbor[PLAYER_PHEROMONE] - chunkPlayer
resourceTotal = resourceTotal + (neighbor[RESOURCE_PHEROMONE] - chunkResource)
end
neighbor = tempNeighbors[6]
if not neighbor.name then
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
baseTotal = baseTotal + (neighbor[BASE_PHEROMONE] - chunkBase)
playerTotal = playerTotal + (neighbor[PLAYER_PHEROMONE] - chunkPlayer)
resourceTotal = resourceTotal + (neighbor[RESOURCE_PHEROMONE] - chunkResource)
end
neighbor = tempNeighbors[7]
if not neighbor.name then
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
baseTotal = baseTotal + (neighbor[BASE_PHEROMONE] - chunkBase)
playerTotal = playerTotal + (neighbor[PLAYER_PHEROMONE] - chunkPlayer)
resourceTotal = resourceTotal + (neighbor[RESOURCE_PHEROMONE] - chunkResource)
end
chunk[MOVEMENT_PHEROMONE] = (chunkMovement + (0.125 * movementTotal)) * MOVEMENT_PHEROMONE_PERSISTANCE * chunkPathRating
chunk[BASE_PHEROMONE] = (chunkBase + (0.35 * baseTotal)) * BASE_PHEROMONE_PERSISTANCE * chunkPathRating
chunk[PLAYER_PHEROMONE] = (chunkPlayer + (0.25 * playerTotal)) * PLAYER_PHEROMONE_PERSISTANCE * chunkPathRating
neighbor = tempNeighbors[8]
if not neighbor.name then
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
baseTotal = baseTotal + (neighbor[BASE_PHEROMONE] - chunkBase)
playerTotal = playerTotal + (neighbor[PLAYER_PHEROMONE] - chunkPlayer)
resourceTotal = resourceTotal + (neighbor[RESOURCE_PHEROMONE] - chunkResource)
end
staging[MOVEMENT_PHEROMONE] = (chunkMovement + (0.125 * movementTotal)) * MOVEMENT_PHEROMONE_PERSISTANCE * chunkPathRating
staging[BASE_PHEROMONE] = (chunkBase + (0.125 * baseTotal)) * BASE_PHEROMONE_PERSISTANCE * chunkPathRating
staging[PLAYER_PHEROMONE] = (chunkPlayer + (0.125 * playerTotal)) * PLAYER_PHEROMONE_PERSISTANCE * chunkPathRating
if clear then
chunk[RESOURCE_PHEROMONE] = (chunkResource + (0.35 * resourceTotal)) * RESOURCE_PHEROMONE_PERSISTANCE * chunkPathRating
staging[RESOURCE_PHEROMONE] = (chunkResource + (0.125 * resourceTotal)) * RESOURCE_PHEROMONE_PERSISTANCE * chunkPathRating
else
chunk[RESOURCE_PHEROMONE] = (chunkResource + (0.35 * resourceTotal)) * 0.01
staging[RESOURCE_PHEROMONE] = (chunkResource + (0.125 * resourceTotal)) * 0.01
end
end